@deftai/directive-core 0.86.0 → 0.87.0

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.
Files changed (35) hide show
  1. package/dist/check/gate-lists.js +1 -0
  2. package/dist/doctor/main.d.ts +6 -5
  3. package/dist/doctor/main.js +32 -18
  4. package/dist/doctor/taskfile.d.ts +8 -0
  5. package/dist/doctor/taskfile.js +19 -0
  6. package/dist/hooks/dispatcher.d.ts +21 -1
  7. package/dist/hooks/dispatcher.js +85 -15
  8. package/dist/intake/issue-emit.d.ts +45 -2
  9. package/dist/intake/issue-emit.js +420 -17
  10. package/dist/intake/issue-ingest.js +54 -4
  11. package/dist/platform/platform-capabilities.js +3 -0
  12. package/dist/review-monitor/constants.js +3 -2
  13. package/dist/review-monitor/tier-detection.d.ts +6 -2
  14. package/dist/review-monitor/tier-detection.js +27 -2
  15. package/dist/scope/transition.js +43 -0
  16. package/dist/session/release-availability.d.ts +2 -0
  17. package/dist/session/release-availability.js +23 -8
  18. package/dist/swarm/routing-set-cli.js +5 -10
  19. package/dist/swarm/routing.d.ts +3 -2
  20. package/dist/swarm/routing.js +16 -4
  21. package/dist/triage/help/registry-data.d.ts +7 -7
  22. package/dist/triage/help/registry-data.js +15 -6
  23. package/dist/triage/queue/index.d.ts +1 -0
  24. package/dist/triage/queue/index.js +1 -0
  25. package/dist/triage/queue/show.d.ts +69 -0
  26. package/dist/triage/queue/show.js +293 -0
  27. package/dist/triage/scope/cli.js +3 -0
  28. package/dist/triage/scope/coverage.d.ts +2 -0
  29. package/dist/triage/scope/coverage.js +18 -3
  30. package/dist/verify-source/index.d.ts +1 -0
  31. package/dist/verify-source/index.js +1 -0
  32. package/dist/verify-source/openclaw-tier1.d.ts +37 -0
  33. package/dist/verify-source/openclaw-tier1.js +100 -0
  34. package/dist/xbrief-migrate/migrate-project.js +9 -5
  35. package/package.json +3 -3
@@ -0,0 +1,293 @@
1
+ /**
2
+ * triage:show default + operator brief renderers (#1128 / #2890).
3
+ *
4
+ * Default format mirrors the pre-Python-removal `render_show` surface.
5
+ * `--format=operator` emits a pasteable Phase 3 candidate brief backbone;
6
+ * the agent still owns lean (not invented here).
7
+ */
8
+ import { existsSync, readFileSync } from "node:fs";
9
+ import { join, resolve } from "node:path";
10
+ import { CACHE_DIR_NAME, CACHE_SOURCE_GITHUB_ISSUE } from "./constants.js";
11
+ function parseLabels(raw) {
12
+ if (!Array.isArray(raw)) {
13
+ return [];
14
+ }
15
+ const labels = [];
16
+ for (const item of raw) {
17
+ if (typeof item === "object" && item !== null) {
18
+ const name = item.name;
19
+ if (typeof name === "string") {
20
+ labels.push(name);
21
+ }
22
+ }
23
+ else if (typeof item === "string") {
24
+ labels.push(item);
25
+ }
26
+ }
27
+ return labels;
28
+ }
29
+ /** Collapse CR/LF so cached attacker text cannot break markdown bullets (P2). */
30
+ export function oneLine(value) {
31
+ return value.replace(/\r?\n/gu, " ").trim();
32
+ }
33
+ /**
34
+ * Resolve a safe issue link. Always construct the canonical github.com path for
35
+ * `owner/name#N` rather than trusting payload URL substrings (CodeQL
36
+ * incomplete-url-substring-sanitization).
37
+ */
38
+ export function resolveIssueHtmlUrl(repo, number) {
39
+ return `https://github.com/${repo}/issues/${number}`;
40
+ }
41
+ /** Load a single cached issue (include closed) or null on miss. */
42
+ export function loadCachedIssueDetail(repo, number, options = {
43
+ projectRoot: process.cwd(),
44
+ }) {
45
+ if (!repo.includes("/")) {
46
+ throw new Error(`repo must be 'owner/name'; got '${repo}'`);
47
+ }
48
+ const parts = repo.split("/", 2);
49
+ const owner = parts[0];
50
+ const name = parts[1];
51
+ if (owner === undefined || name === undefined || owner.length === 0 || name.length === 0) {
52
+ throw new Error(`repo must be 'owner/name'; got '${repo}'`);
53
+ }
54
+ const source = options.source ?? CACHE_SOURCE_GITHUB_ISSUE;
55
+ const cacheBase = options.cacheRoot !== null && options.cacheRoot !== undefined && options.cacheRoot.length > 0
56
+ ? resolve(options.cacheRoot)
57
+ : join(resolve(options.projectRoot), CACHE_DIR_NAME);
58
+ const entryDir = join(cacheBase, source, owner, name, String(number));
59
+ const rawPath = join(entryDir, "raw.json");
60
+ if (!existsSync(rawPath)) {
61
+ return null;
62
+ }
63
+ let payload;
64
+ try {
65
+ const parsed = JSON.parse(readFileSync(rawPath, { encoding: "utf8" }));
66
+ if (typeof parsed !== "object" || parsed === null) {
67
+ return null;
68
+ }
69
+ payload = parsed;
70
+ }
71
+ catch {
72
+ return null;
73
+ }
74
+ const n = typeof payload.number === "number" ? payload.number : number;
75
+ const stateRaw = payload.state ?? "open";
76
+ const state = typeof stateRaw === "string" ? stateRaw.toLowerCase() : "open";
77
+ const title = typeof payload.title === "string" ? payload.title : "";
78
+ const body = typeof payload.body === "string" ? payload.body : "";
79
+ const updatedAt = typeof payload.updated_at === "string"
80
+ ? payload.updated_at
81
+ : typeof payload.updatedAt === "string"
82
+ ? payload.updatedAt
83
+ : "";
84
+ return {
85
+ number: n,
86
+ title,
87
+ state,
88
+ labels: parseLabels(payload.labels),
89
+ updatedAt,
90
+ body,
91
+ htmlUrl: resolveIssueHtmlUrl(repo, n),
92
+ };
93
+ }
94
+ /** Default triage:show text (audit/cache oriented). */
95
+ export function renderShow(options) {
96
+ const lines = [];
97
+ lines.push(`triage:show -- ${options.repo}#${options.number}`);
98
+ if (options.issue === null) {
99
+ lines.push("");
100
+ lines.push(" (issue not present in local cache)");
101
+ lines.push(" Run `task triage:bootstrap` to populate, or check the repo slug.");
102
+ return lines.join("\n");
103
+ }
104
+ const labels = options.issue.labels.map(oneLine);
105
+ lines.push(` title: ${oneLine(options.issue.title)}`);
106
+ lines.push(` state: ${oneLine(options.issue.state)}`);
107
+ lines.push(` labels: ${labels.length > 0 ? labels.join(", ") : "<none>"}`);
108
+ lines.push(` updated_at: ${oneLine(options.issue.updatedAt)}`);
109
+ lines.push("");
110
+ lines.push(` active xBRIEF reference: ${options.inActiveXbrief ? "yes" : "no"}`);
111
+ if (options.latestDecision !== null) {
112
+ const d = options.latestDecision;
113
+ lines.push(` latest decision: ${oneLine(String(d.decision ?? "?"))} at ${oneLine(String(d.timestamp ?? "?"))} by ${oneLine(String(d.actor ?? "?"))}`);
114
+ if (typeof d.reason === "string" && d.reason.length > 0) {
115
+ lines.push(` reason: ${oneLine(d.reason)}`);
116
+ }
117
+ }
118
+ else {
119
+ lines.push(" latest decision: <none -- untriaged>");
120
+ }
121
+ if (options.history.length > 0) {
122
+ lines.push("");
123
+ lines.push(` history (${options.history.length} entries, oldest first):`);
124
+ for (const entry of options.history) {
125
+ const decision = oneLine(String(entry.decision ?? "?")).padEnd(14);
126
+ lines.push(` - ${oneLine(String(entry.timestamp ?? "?"))} ${decision} by ${oneLine(String(entry.actor ?? "?"))}`);
127
+ }
128
+ }
129
+ return lines.join("\n");
130
+ }
131
+ /** Collapse blank lines and trim for summary extraction. */
132
+ function normalizeBody(body) {
133
+ return body.replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim();
134
+ }
135
+ /**
136
+ * Extract a short problem/context summary (2–5 lines) from issue body.
137
+ * Prefers text before the first `##` section; falls back to leading paragraphs.
138
+ */
139
+ export function extractBodySummary(body, maxLines = 5) {
140
+ const text = normalizeBody(body);
141
+ if (text.length === 0) {
142
+ return "(thin body / no summary)";
143
+ }
144
+ // Drop leading H1/title lines
145
+ let rest = text.replace(/^#[^\n]*\n+/u, "");
146
+ // Prefer content before first ## heading (often Summary/Description)
147
+ const firstSection = rest.search(/^##\s+/mu);
148
+ if (firstSection > 0) {
149
+ rest = rest.slice(0, firstSection).trim();
150
+ }
151
+ else if (firstSection === 0) {
152
+ // Body starts with ## — take the first section body
153
+ const next = rest.search(/\n##\s+/u);
154
+ const block = next === -1 ? rest : rest.slice(0, next);
155
+ rest = block.replace(/^##[^\n]*\n?/u, "").trim();
156
+ }
157
+ const paragraphs = rest
158
+ .split(/\n{2,}/u)
159
+ .map((p) => p.replace(/\s+/gu, " ").trim())
160
+ .filter((p) => p.length > 0 && !p.startsWith("#"));
161
+ if (paragraphs.length === 0) {
162
+ const lines = rest
163
+ .split("\n")
164
+ .map((l) => l.trim())
165
+ .filter((l) => l.length > 0 && !l.startsWith("#"));
166
+ if (lines.length === 0) {
167
+ return "(thin body / no summary)";
168
+ }
169
+ return lines.slice(0, maxLines).join("\n");
170
+ }
171
+ const out = [];
172
+ for (const para of paragraphs) {
173
+ if (out.length >= maxLines)
174
+ break;
175
+ // Soft-wrap long paragraphs into ~100-char lines for pasteability
176
+ if (para.length <= 120) {
177
+ out.push(para);
178
+ }
179
+ else {
180
+ const words = para.split(/\s+/u);
181
+ let line = "";
182
+ for (const w of words) {
183
+ const next = line.length === 0 ? w : `${line} ${w}`;
184
+ if (next.length > 100 && line.length > 0) {
185
+ out.push(line);
186
+ line = w;
187
+ if (out.length >= maxLines)
188
+ break;
189
+ }
190
+ else {
191
+ line = next;
192
+ }
193
+ }
194
+ if (line.length > 0 && out.length < maxLines) {
195
+ out.push(line);
196
+ }
197
+ }
198
+ }
199
+ return out.slice(0, maxLines).join("\n");
200
+ }
201
+ /**
202
+ * Extract acceptance-criteria bullets from body, or a thin-body note.
203
+ * Looks for AC / Acceptance headings and checkbox / bullet lists under them.
204
+ */
205
+ export function extractAcceptanceCriteria(body) {
206
+ const text = normalizeBody(body);
207
+ if (text.length === 0) {
208
+ return [];
209
+ }
210
+ const headingRe = /^#{1,3}\s*(?:acceptance\s*criteria|acceptance|ac\b|success\s*criteria)[^\n]*$/imu;
211
+ const match = headingRe.exec(text);
212
+ if (match === null || match.index === undefined) {
213
+ // Loose: checkbox list near top without a heading
214
+ const loose = [];
215
+ for (const line of text.split("\n")) {
216
+ const m = /^\s*[-*]\s*\[[ xX]\]\s+(.+)$/u.exec(line);
217
+ if (m?.[1] !== undefined) {
218
+ loose.push(m[1].trim());
219
+ }
220
+ }
221
+ return loose.slice(0, 12);
222
+ }
223
+ const after = text.slice(match.index + match[0].length);
224
+ // Stop only at a next ## (H2) peer section — keep ### subsections (A/B/C…) inside AC.
225
+ const nextPeer = after.search(/\n##\s+\S/u);
226
+ const section = nextPeer === -1 ? after : after.slice(0, nextPeer);
227
+ const bullets = [];
228
+ for (const line of section.split("\n")) {
229
+ const checkbox = /^\s*[-*]\s*\[[ xX]\]\s+(.+)$/u.exec(line);
230
+ if (checkbox?.[1] !== undefined) {
231
+ bullets.push(checkbox[1].trim());
232
+ continue;
233
+ }
234
+ // Prefer checkboxes under AC; plain bullets are also accepted
235
+ const bullet = /^\s*[-*]\s+(.+)$/u.exec(line);
236
+ if (bullet?.[1] !== undefined) {
237
+ // Skip nested subsection-only markers that are just headings-as-bullets
238
+ bullets.push(bullet[1].trim());
239
+ continue;
240
+ }
241
+ const numbered = /^\s*\d+[.)]\s+(.+)$/u.exec(line);
242
+ if (numbered?.[1] !== undefined) {
243
+ bullets.push(numbered[1].trim());
244
+ }
245
+ }
246
+ return bullets.slice(0, 12);
247
+ }
248
+ /** Operator-facing pasteable brief backbone for Phase 3 decisions (#2890). */
249
+ export function renderOperatorBrief(options) {
250
+ const lines = [];
251
+ lines.push(`triage:show --format=operator -- ${options.repo}#${options.number}`);
252
+ if (options.issue === null) {
253
+ lines.push("");
254
+ lines.push(" (issue not present in local cache)");
255
+ lines.push(" Run `task triage:bootstrap` / re-sync per Phase 0, or check the repo slug.");
256
+ return lines.join("\n");
257
+ }
258
+ const issue = options.issue;
259
+ const link = issue.htmlUrl ?? resolveIssueHtmlUrl(options.repo, options.number);
260
+ const labels = issue.labels.length > 0 ? issue.labels.map(oneLine).join(", ") : "<none>";
261
+ lines.push(`#${options.number} ${oneLine(issue.title)}`);
262
+ lines.push(`link: ${oneLine(link)}`);
263
+ lines.push(`labels: ${labels}`);
264
+ lines.push("");
265
+ lines.push("summary:");
266
+ for (const line of extractBodySummary(issue.body).split("\n")) {
267
+ lines.push(` ${oneLine(line)}`);
268
+ }
269
+ lines.push("");
270
+ const ac = extractAcceptanceCriteria(issue.body);
271
+ if (ac.length === 0) {
272
+ lines.push("acceptance criteria: (thin body / no AC)");
273
+ }
274
+ else {
275
+ lines.push("acceptance criteria:");
276
+ for (const item of ac) {
277
+ lines.push(` - ${oneLine(item)}`);
278
+ }
279
+ }
280
+ lines.push("");
281
+ if (options.latestDecision !== null) {
282
+ const d = options.latestDecision;
283
+ lines.push(`latest decision: ${oneLine(String(d.decision ?? "?"))} at ${oneLine(String(d.timestamp ?? "?"))} by ${oneLine(String(d.actor ?? "?"))}`);
284
+ }
285
+ else {
286
+ lines.push("latest decision: <none -- untriaged>");
287
+ }
288
+ lines.push(`active xBRIEF: ${options.inActiveXbrief ? "yes" : "no"}`);
289
+ lines.push("");
290
+ lines.push("lean: (agent-owned — not filled by triage:show)");
291
+ return lines.join("\n");
292
+ }
293
+ //# sourceMappingURL=show.js.map
@@ -232,9 +232,12 @@ export function runCliCapture(argv) {
232
232
  cacheRoot: args.cacheRoot !== undefined ? resolve(args.cacheRoot) : undefined,
233
233
  });
234
234
  const subHash = subscriptionHash(rules);
235
+ // When --cache-root is outside the project tree, contain against that root
236
+ // instead of projectRoot (tests and operators may redirect the cache) (#2869).
235
237
  const record = writeCoverageDenominator(path, {
236
238
  count: args.count,
237
239
  subscriptionHashValue: subHash,
240
+ projectRoot: args.cacheRoot !== undefined ? resolve(args.cacheRoot) : projectRoot,
238
241
  });
239
242
  stdout.push(`triage:scope: wrote coverage denominator count=${record.count} ` +
240
243
  `subscription-hash=${record.subscriptionHash} path=${path}\n`);
@@ -14,6 +14,8 @@ export declare function writeCoverageDenominator(path: string, options: {
14
14
  count: number;
15
15
  subscriptionHashValue: string;
16
16
  fetchedAt?: Date;
17
+ /** Project (or cache) root for symlink containment (#2869). */
18
+ projectRoot?: string;
17
19
  }): CoverageRecord;
18
20
  export declare function readCoverageDenominator(path: string, options: {
19
21
  currentHash: string;
@@ -1,5 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
- import { join, resolve } from "node:path";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { assertWriteTargetSafe } from "../../fs/projection-containment.js";
3
4
  import { CACHE_DIR_NAME, COVERAGE_FILENAME, DEFAULT_COVERAGE_TTL_HOURS, ENV_COVERAGE_TTL_HOURS, } from "./constants.js";
4
5
  import { parseIso, utcIso, utcNow } from "./time.js";
5
6
  export function coveragePath(source, repo, options = {}) {
@@ -29,14 +30,28 @@ export function writeCoverageDenominator(path, options) {
29
30
  if (!options.subscriptionHashValue) {
30
31
  throw new Error("subscription_hash_value must be a non-empty string");
31
32
  }
33
+ const absPath = resolve(path);
34
+ // Production CLI always passes projectRoot. When omitted (unit tests with a
35
+ // bare cacheRoot), walk up to the deepest existing ancestor so containment
36
+ // can realpath the root before mkdir creates intermediate dirs (#2869).
37
+ let containmentRoot = options.projectRoot !== undefined ? resolve(options.projectRoot) : dirname(absPath);
38
+ if (options.projectRoot === undefined) {
39
+ while (!existsSync(containmentRoot)) {
40
+ const parent = dirname(containmentRoot);
41
+ if (parent === containmentRoot)
42
+ break;
43
+ containmentRoot = parent;
44
+ }
45
+ }
46
+ assertWriteTargetSafe(containmentRoot, absPath);
32
47
  const stamp = utcIso(options.fetchedAt ?? null);
33
- mkdirSync(join(path, ".."), { recursive: true });
48
+ mkdirSync(dirname(absPath), { recursive: true });
34
49
  const payload = {
35
50
  count: options.count,
36
51
  fetched_at: stamp,
37
52
  subscription_hash: options.subscriptionHashValue,
38
53
  };
39
- writeFileSync(path, `${JSON.stringify(payload, Object.keys(payload).sort())}\n`, "utf8");
54
+ writeFileSync(absPath, `${JSON.stringify(payload, Object.keys(payload).sort())}\n`, "utf8");
40
55
  return {
41
56
  count: options.count,
42
57
  fetchedAt: stamp,
@@ -3,6 +3,7 @@ export * from "./code-structure-validate.js";
3
3
  export * from "./content-manifest.js";
4
4
  export { CANONICAL_SCHEMA_REL, type ContractDriftOptions, type ContractDriftResult, evaluateContractDrift, PUBLISHED_SCHEMA_REL, } from "./contract-drift.js";
5
5
  export * from "./cursor-tier1.js";
6
+ export * from "./openclaw-tier1.js";
6
7
  export * from "./python-call-scan.js";
7
8
  export * from "./rule-ownership-lint.js";
8
9
  export * from "./scm-boundary.js";
@@ -3,6 +3,7 @@ export * from "./code-structure-validate.js";
3
3
  export * from "./content-manifest.js";
4
4
  export { CANONICAL_SCHEMA_REL, evaluateContractDrift, PUBLISHED_SCHEMA_REL, } from "./contract-drift.js";
5
5
  export * from "./cursor-tier1.js";
6
+ export * from "./openclaw-tier1.js";
6
7
  export * from "./python-call-scan.js";
7
8
  export * from "./rule-ownership-lint.js";
8
9
  export * from "./scm-boundary.js";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Deterministic gate: assert that OpenClaw is enumerated as a Tier-1 descriptor
3
+ * in the swarm Phase 3 capability matrix and that routing accepts openclaw as a
4
+ * dispatch_provider (#2875). Without this gate the "OpenClaw -> Tier 1" mapping
5
+ * is prose-trusted; a doc edit that drops the sessions_spawn descriptor would
6
+ * silently re-open misclassification (OpenClaw falling through to grok-build or
7
+ * generic-terminal).
8
+ *
9
+ * Review-cycle skill markers for OpenClaw Approach 1 are owned by sibling #2876
10
+ * and are intentionally out of scope for this gate.
11
+ */
12
+ export interface OpenclawTier1Target {
13
+ /** Project-root-relative path to the surface file. */
14
+ readonly path: string;
15
+ /** Human label for the surface, used in failure output. */
16
+ readonly label: string;
17
+ /** Whitespace-normalized substrings that MUST all be present. */
18
+ readonly markers: readonly string[];
19
+ }
20
+ export declare const OPENCLAW_TIER1_TARGETS: readonly OpenclawTier1Target[];
21
+ export interface OpenclawTier1Finding {
22
+ readonly path: string;
23
+ readonly label: string;
24
+ readonly missingMarkers: readonly string[];
25
+ }
26
+ export interface OpenclawTier1Result {
27
+ readonly code: 0 | 1 | 2;
28
+ readonly findings: readonly OpenclawTier1Finding[];
29
+ readonly message: string;
30
+ readonly stream: "stdout" | "stderr";
31
+ }
32
+ export interface OpenclawTier1Options {
33
+ readonly targets?: readonly OpenclawTier1Target[];
34
+ readonly quiet?: boolean;
35
+ }
36
+ export declare function evaluateOpenclawTier1(projectRoot: string, options?: OpenclawTier1Options): OpenclawTier1Result;
37
+ //# sourceMappingURL=openclaw-tier1.d.ts.map
@@ -0,0 +1,100 @@
1
+ import { existsSync, readFileSync, statSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ export const OPENCLAW_TIER1_TARGETS = [
4
+ {
5
+ path: "content/skills/deft-directive-swarm/SKILL.md",
6
+ label: "swarm Phase 3 capability matrix",
7
+ markers: [
8
+ "Probe for the OpenClaw `sessions_spawn` tool",
9
+ "sessions_spawn",
10
+ "openclaw",
11
+ "Step 2f: OpenClaw Launch",
12
+ ],
13
+ },
14
+ {
15
+ path: "packages/core/src/swarm/routing.ts",
16
+ label: "swarm routing dispatch_provider",
17
+ // Prefer operative identifiers (function + return), not free-floating prose.
18
+ markers: [
19
+ "export function resolveDispatchProvider",
20
+ 'return "openclaw"',
21
+ "DEFT_HAS_SESSIONS_SPAWN",
22
+ "ROUTING_GATED_DISPATCH_PROVIDERS",
23
+ ],
24
+ },
25
+ {
26
+ path: "packages/core/src/swarm/routing-set-cli.ts",
27
+ label: "swarm:routing-set provider resolution",
28
+ markers: ["resolveDispatchProvider", "openclaw"],
29
+ },
30
+ ];
31
+ /** Collapse all runs of whitespace to a single space (substring-containment normalization). */
32
+ function normalizeWhitespace(text) {
33
+ return text.replace(/\s+/g, " ");
34
+ }
35
+ export function evaluateOpenclawTier1(projectRoot, options = {}) {
36
+ const root = resolve(projectRoot);
37
+ let isDir = false;
38
+ try {
39
+ isDir = statSync(root).isDirectory();
40
+ }
41
+ catch {
42
+ isDir = false;
43
+ }
44
+ if (!isDir) {
45
+ return {
46
+ code: 2,
47
+ findings: [],
48
+ message: `verify_openclaw_tier1: --project-root is not a directory: ${root}\n` +
49
+ " Recovery: pass an existing directory path.",
50
+ stream: "stderr",
51
+ };
52
+ }
53
+ const targets = options.targets ?? OPENCLAW_TIER1_TARGETS;
54
+ const findings = [];
55
+ for (const target of targets) {
56
+ const full = join(root, target.path);
57
+ if (!existsSync(full)) {
58
+ return {
59
+ code: 2,
60
+ findings: [...findings],
61
+ message: `verify_openclaw_tier1: required surface file not found: ${target.path}\n` +
62
+ " Recovery: run from the framework source root, or update OPENCLAW_TIER1_TARGETS if the path moved.",
63
+ stream: "stderr",
64
+ };
65
+ }
66
+ let normalized;
67
+ try {
68
+ normalized = normalizeWhitespace(readFileSync(full, { encoding: "utf8" }));
69
+ }
70
+ catch (err) {
71
+ const msg = err instanceof Error ? err.message : String(err);
72
+ return {
73
+ code: 2,
74
+ findings: [...findings],
75
+ message: `verify_openclaw_tier1: could not read ${target.path}: ${msg}`,
76
+ stream: "stderr",
77
+ };
78
+ }
79
+ const missing = target.markers.filter((marker) => !normalized.includes(normalizeWhitespace(marker)));
80
+ if (missing.length > 0) {
81
+ findings.push({ path: target.path, label: target.label, missingMarkers: missing });
82
+ }
83
+ }
84
+ if (findings.length > 0) {
85
+ const header = "verify_openclaw_tier1: OpenClaw is not fully enumerated as a Tier-1 descriptor (#2875).\n" +
86
+ " Root cause: an OpenClaw agent has a first-class backgroundable sub-agent primitive (sessions_spawn) and\n" +
87
+ " is therefore Tier 1 / Approach 1. If the matrix or routing surfaces drop the openclaw descriptor, an\n" +
88
+ " OpenClaw session silently degrades to grok-build misclassification or generic-terminal. Re-add the missing marker(s):";
89
+ const body = findings
90
+ .map((f) => ` ${f.path} (${f.label}) missing: ${f.missingMarkers.map((m) => `"${m}"`).join(", ")}`)
91
+ .join("\n");
92
+ return { code: 1, findings, message: `${header}\n${body}`, stream: "stderr" };
93
+ }
94
+ const msg = `verify_openclaw_tier1: OpenClaw enumerated as a Tier-1 descriptor in ${targets.length} surface(s) (#2875).`;
95
+ if (options.quiet) {
96
+ return { code: 0, findings: [], message: "", stream: "stdout" };
97
+ }
98
+ return { code: 0, findings: [], message: msg, stream: "stdout" };
99
+ }
100
+ //# sourceMappingURL=openclaw-tier1.js.map
@@ -108,7 +108,7 @@ function migrateLegacyTree(projectRoot, legacyDir, options) {
108
108
  // either removed (default) or retained for read-compat behind an explicit
109
109
  // deprecation marker so it never looks like an active source of truth (#2270).
110
110
  if (options.keepLegacy) {
111
- writeVbriefDeprecationMarker(legacyDir);
111
+ writeVbriefDeprecationMarker(projectRoot, legacyDir);
112
112
  }
113
113
  else {
114
114
  rmSync(legacyDir, { recursive: true, force: true });
@@ -120,13 +120,17 @@ function migrateLegacyTree(projectRoot, legacyDir, options) {
120
120
  throw err;
121
121
  }
122
122
  }
123
- /** Idempotently write the legacy-root deprecation marker (#2270). */
124
- function writeVbriefDeprecationMarker(legacyDir) {
123
+ /** Idempotently write the legacy-root deprecation marker (#2270 / #2869). */
124
+ function writeVbriefDeprecationMarker(projectRoot, legacyDir) {
125
+ const markerPath = join(legacyDir, VBRIEF_DEPRECATION_MARKER_FILENAME);
126
+ // Refuse leaf or parent-dir symlink escapes before mkdir/write (#2869).
127
+ assertWriteTargetSafe(projectRoot, legacyDir);
128
+ assertWriteTargetSafe(projectRoot, markerPath);
125
129
  mkdirSync(legacyDir, { recursive: true });
126
130
  if (hasVbriefDeprecationMarker(legacyDir)) {
127
131
  return;
128
132
  }
129
- writeFileSync(join(legacyDir, VBRIEF_DEPRECATION_MARKER_FILENAME), VBRIEF_DEPRECATION_MARKER_BODY, "utf8");
133
+ writeFileSync(markerPath, VBRIEF_DEPRECATION_MARKER_BODY, "utf8");
130
134
  }
131
135
  /**
132
136
  * Converge a leftover legacy `vbrief/` root to an unambiguous state (#2270).
@@ -147,7 +151,7 @@ export function convergeLegacyVbriefRoot(projectRoot, options) {
147
151
  rmSync(legacyDir, { recursive: true, force: true });
148
152
  return "removed";
149
153
  }
150
- writeVbriefDeprecationMarker(legacyDir);
154
+ writeVbriefDeprecationMarker(projectRoot, legacyDir);
151
155
  return "marker";
152
156
  }
153
157
  function renameOrReplace(src, dest) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive-core",
3
- "version": "0.86.0",
3
+ "version": "0.87.0",
4
4
  "description": "TypeScript engine core for the Directive framework.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -317,8 +317,8 @@
317
317
  "provenance": true
318
318
  },
319
319
  "dependencies": {
320
- "@deftai/directive-content": "^0.86.0",
321
- "@deftai/directive-types": "^0.86.0",
320
+ "@deftai/directive-content": "^0.87.0",
321
+ "@deftai/directive-types": "^0.87.0",
322
322
  "archiver": "^8.0.0"
323
323
  },
324
324
  "scripts": {