@deftai/directive-core 0.66.2 → 0.68.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 (147) hide show
  1. package/dist/agents-md-advisory/evaluate.d.ts +44 -0
  2. package/dist/agents-md-advisory/evaluate.js +115 -0
  3. package/dist/agents-md-advisory/index.d.ts +2 -0
  4. package/dist/agents-md-advisory/index.js +2 -0
  5. package/dist/agents-md-budget/evaluate.d.ts +38 -0
  6. package/dist/agents-md-budget/evaluate.js +152 -0
  7. package/dist/agents-md-budget/index.d.ts +2 -0
  8. package/dist/agents-md-budget/index.js +2 -0
  9. package/dist/check/index.d.ts +1 -1
  10. package/dist/check/index.js +1 -1
  11. package/dist/check/orchestrator.d.ts +14 -4
  12. package/dist/check/orchestrator.js +30 -6
  13. package/dist/codebase/map.d.ts +1 -0
  14. package/dist/codebase/map.js +5 -2
  15. package/dist/doctor/checks.js +11 -11
  16. package/dist/doctor/constants.d.ts +7 -2
  17. package/dist/doctor/constants.js +17 -1
  18. package/dist/doctor/flags.js +5 -1
  19. package/dist/doctor/main.js +99 -8
  20. package/dist/doctor/payload-staleness.js +15 -6
  21. package/dist/doctor/types.d.ts +7 -0
  22. package/dist/forward-coverage/evaluate.d.ts +55 -0
  23. package/dist/forward-coverage/evaluate.js +254 -0
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +1 -0
  26. package/dist/init-deposit/constants.d.ts +14 -0
  27. package/dist/init-deposit/constants.js +10 -0
  28. package/dist/init-deposit/hygiene.d.ts +50 -0
  29. package/dist/init-deposit/hygiene.js +176 -0
  30. package/dist/init-deposit/init-deposit.d.ts +1 -0
  31. package/dist/init-deposit/init-deposit.js +7 -1
  32. package/dist/init-deposit/refresh.d.ts +2 -0
  33. package/dist/init-deposit/refresh.js +48 -30
  34. package/dist/init-deposit/scaffold.d.ts +3 -4
  35. package/dist/init-deposit/scaffold.js +3 -24
  36. package/dist/intake/github-auth-modes.d.ts +1 -0
  37. package/dist/intake/github-auth-modes.js +1 -0
  38. package/dist/intake/issue-ingest.d.ts +6 -2
  39. package/dist/intake/issue-ingest.js +65 -9
  40. package/dist/integration-e2e/helpers.d.ts +0 -1
  41. package/dist/integration-e2e/helpers.js +3 -7
  42. package/dist/layout/lifecycle-ref.d.ts +15 -0
  43. package/dist/layout/lifecycle-ref.js +55 -0
  44. package/dist/platform/agents-consumer-header.d.ts +13 -0
  45. package/dist/platform/agents-consumer-header.js +57 -0
  46. package/dist/platform/agents-md.d.ts +28 -0
  47. package/dist/platform/agents-md.js +38 -1
  48. package/dist/platform/index.d.ts +1 -0
  49. package/dist/platform/index.js +1 -0
  50. package/dist/policy/agents-md-advisory.d.ts +52 -0
  51. package/dist/policy/agents-md-advisory.js +63 -0
  52. package/dist/policy/agents-md-budget.d.ts +24 -0
  53. package/dist/policy/agents-md-budget.js +89 -0
  54. package/dist/policy/index.d.ts +1 -0
  55. package/dist/policy/index.js +1 -0
  56. package/dist/policy/resolve.js +56 -46
  57. package/dist/pr-merge-readiness/ci-gate.d.ts +28 -0
  58. package/dist/pr-merge-readiness/ci-gate.js +79 -0
  59. package/dist/pr-merge-readiness/compute.d.ts +15 -1
  60. package/dist/pr-merge-readiness/compute.js +129 -9
  61. package/dist/pr-merge-readiness/gh.d.ts +8 -0
  62. package/dist/pr-merge-readiness/gh.js +30 -5
  63. package/dist/pr-merge-readiness/index.d.ts +5 -1
  64. package/dist/pr-merge-readiness/index.js +3 -0
  65. package/dist/pr-merge-readiness/main.d.ts +3 -0
  66. package/dist/pr-merge-readiness/main.js +73 -6
  67. package/dist/pr-merge-readiness/mergeability.d.ts +43 -0
  68. package/dist/pr-merge-readiness/mergeability.js +105 -0
  69. package/dist/pr-merge-readiness/output.js +20 -0
  70. package/dist/pr-merge-readiness/slizard-gate.d.ts +47 -0
  71. package/dist/pr-merge-readiness/slizard-gate.js +119 -0
  72. package/dist/pr-monitor/index.d.ts +1 -1
  73. package/dist/pr-monitor/index.js +1 -1
  74. package/dist/pr-monitor/monitor.d.ts +8 -2
  75. package/dist/pr-monitor/monitor.js +35 -6
  76. package/dist/pr-wait-mergeable/wrappers.d.ts +12 -1
  77. package/dist/pr-wait-mergeable/wrappers.js +13 -5
  78. package/dist/pr-watch/constants.d.ts +33 -0
  79. package/dist/pr-watch/constants.js +33 -0
  80. package/dist/pr-watch/index.d.ts +6 -0
  81. package/dist/pr-watch/index.js +6 -0
  82. package/dist/pr-watch/main.d.ts +21 -0
  83. package/dist/pr-watch/main.js +206 -0
  84. package/dist/pr-watch/probe.d.ts +13 -0
  85. package/dist/pr-watch/probe.js +100 -0
  86. package/dist/pr-watch/types.d.ts +47 -0
  87. package/dist/pr-watch/types.js +2 -0
  88. package/dist/pr-watch/watch.d.ts +12 -0
  89. package/dist/pr-watch/watch.js +122 -0
  90. package/dist/preflight-cache/evaluate.d.ts +1 -0
  91. package/dist/preflight-cache/evaluate.js +17 -10
  92. package/dist/render/project-render.d.ts +16 -2
  93. package/dist/render/project-render.js +155 -97
  94. package/dist/scope/capacity-stamp.d.ts +24 -2
  95. package/dist/scope/capacity-stamp.js +80 -28
  96. package/dist/scope/decomposed-refs.js +2 -2
  97. package/dist/scope/project-definition-sync.js +3 -3
  98. package/dist/scope/vbrief-ref.d.ts +2 -1
  99. package/dist/scope/vbrief-ref.js +3 -2
  100. package/dist/spec-authority/constants.d.ts +6 -0
  101. package/dist/spec-authority/constants.js +11 -0
  102. package/dist/spec-authority/resolver.js +3 -3
  103. package/dist/swarm/finalize-cohort-cli.d.ts +5 -0
  104. package/dist/swarm/finalize-cohort-cli.js +100 -0
  105. package/dist/swarm/finalize-cohort.d.ts +39 -0
  106. package/dist/swarm/finalize-cohort.js +589 -0
  107. package/dist/swarm/index.d.ts +2 -0
  108. package/dist/swarm/index.js +2 -0
  109. package/dist/swarm/launch.d.ts +13 -0
  110. package/dist/swarm/launch.js +19 -7
  111. package/dist/swarm/routing-verify.d.ts +1 -1
  112. package/dist/swarm/routing-verify.js +11 -10
  113. package/dist/swarm/routing.d.ts +9 -0
  114. package/dist/swarm/routing.js +46 -0
  115. package/dist/swarm/verify-review-clean-cli.js +25 -1
  116. package/dist/swarm/verify-review-clean.d.ts +9 -1
  117. package/dist/swarm/verify-review-clean.js +76 -3
  118. package/dist/triage/queue/index.d.ts +1 -0
  119. package/dist/triage/queue/index.js +1 -0
  120. package/dist/triage/queue/project.d.ts +6 -1
  121. package/dist/triage/queue/project.js +9 -4
  122. package/dist/triage/queue/reconcile-live-state.d.ts +42 -0
  123. package/dist/triage/queue/reconcile-live-state.js +54 -0
  124. package/dist/triage/scope/mutations-core.js +91 -81
  125. package/dist/triage/scope/resolve.js +4 -3
  126. package/dist/triage/scope-drift/add-ignore.js +33 -32
  127. package/dist/triage/scope-drift/scope-rules.js +3 -3
  128. package/dist/triage/subscribe/index.js +51 -45
  129. package/dist/triage/welcome/writers.js +79 -64
  130. package/dist/vbrief-build/project-definition-io.js +8 -3
  131. package/dist/vbrief-validate/paths.js +8 -4
  132. package/dist/vbrief-validate/precutover.d.ts +1 -1
  133. package/dist/vbrief-validate/precutover.js +12 -10
  134. package/dist/verify-source/biome-config.d.ts +41 -0
  135. package/dist/verify-source/biome-config.js +97 -0
  136. package/dist/verify-source/index.d.ts +1 -0
  137. package/dist/verify-source/index.js +1 -0
  138. package/dist/xbrief-migrate/agents-header.d.ts +69 -0
  139. package/dist/xbrief-migrate/agents-header.js +179 -0
  140. package/dist/xbrief-migrate/fs-helpers.d.ts +3 -0
  141. package/dist/xbrief-migrate/fs-helpers.js +11 -0
  142. package/dist/xbrief-migrate/index.d.ts +1 -0
  143. package/dist/xbrief-migrate/index.js +1 -0
  144. package/dist/xbrief-migrate/migrate-project.js +29 -10
  145. package/package.json +15 -7
  146. package/dist/install-upgrade/index.d.ts +0 -13
  147. package/dist/install-upgrade/index.js +0 -251
@@ -1,251 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
2
- import { join, relative, resolve } from "node:path";
3
- import { locateManifest, manifestTagToVersion, parseInstallManifest } from "../doctor/manifest.js";
4
- import { readCorePackageVersion } from "../engine-version.js";
5
- import { buildInstallManifestText, CANONICAL_INSTALL_ROOT, } from "../init-deposit/scaffold.js";
6
- import { resolveLifecycleRoot } from "../layout/resolve.js";
7
- import { agentsRefreshPlan } from "../platform/agents-md.js";
8
- import { DEV_FALLBACK } from "../platform/constants.js";
9
- import { resolveVersion } from "../platform/resolve-version.js";
10
- import { detectPreCutoverLegacy, frozenPreCutoverMigrationGuidance, } from "../vbrief-validate/precutover.js";
11
- import { detectLegacyVbriefLayout, emitXbriefMigration, isPatchOnlyUpgrade, renderXbriefMigrationLine, runXbriefMigration, } from "../xbrief-migrate/index.js";
12
- const ENGINE_PACKAGE_FALLBACK = "0.0.0";
13
- /**
14
- * Resolve the framework version for an upgrade (#2053).
15
- *
16
- * `resolveVersion({ frameworkRoot })` reads env / install-manifest / .deft-version
17
- * / git against the *engine* framework root. When `deft install-upgrade` runs from
18
- * a global npm install, that root is the npm package directory — which carries no
19
- * install manifest, no bare marker, and is not its own git repo — so the chain
20
- * dead-ends at `0.0.0-dev`. Recover by auto-detecting the *consumer project's*
21
- * deposited manifest, then fall back to the engine package.json version, before
22
- * surrendering to the dev fallback.
23
- */
24
- function resolveUpgradeVersion(frameworkRoot, projectRoot) {
25
- const primary = resolveVersion({ frameworkRoot });
26
- if (primary !== DEV_FALLBACK)
27
- return primary;
28
- const manifestPath = locateManifest(projectRoot, null);
29
- if (manifestPath) {
30
- try {
31
- const tag = manifestTagToVersion(parseInstallManifest(readFileSync(manifestPath, "utf8")));
32
- if (tag)
33
- return tag;
34
- }
35
- catch {
36
- // fall through to package.json fallback
37
- }
38
- }
39
- const pkgVersion = readCorePackageVersion();
40
- if (pkgVersion && pkgVersion !== ENGINE_PACKAGE_FALLBACK)
41
- return pkgVersion;
42
- return DEV_FALLBACK;
43
- }
44
- /**
45
- * The consumer's deposited framework install root (`.deft/core`, then legacy
46
- * `deft/`), if present. Used as the AGENTS.md render root and manifest target so
47
- * the refresh renders from the *deposited* templates that match the installed
48
- * payload -- not the (possibly newer) templates bundled in a global npm engine.
49
- */
50
- function resolveInstallRoot(projectRoot) {
51
- for (const candidate of [join(projectRoot, ".deft", "core"), join(projectRoot, "deft")]) {
52
- try {
53
- if (statSync(candidate).isDirectory())
54
- return candidate;
55
- }
56
- catch {
57
- // try next candidate
58
- }
59
- }
60
- return null;
61
- }
62
- /** Prior `managed_by` provenance sentinel from an install manifest, if any (#2056). */
63
- function readManagedByAt(installRoot) {
64
- const manifestPath = join(installRoot, "VERSION");
65
- if (!existsSync(manifestPath) || !statSync(manifestPath).isFile())
66
- return null;
67
- try {
68
- const value = (parseInstallManifest(readFileSync(manifestPath, "utf8")).managed_by ?? "").trim();
69
- return value || null;
70
- }
71
- catch {
72
- return null;
73
- }
74
- }
75
- function versionMarkerPaths(projectRoot) {
76
- return [
77
- join(resolveLifecycleRoot(projectRoot), ".deft-version"),
78
- join(projectRoot, ".deft-version"),
79
- ];
80
- }
81
- function readVersionMarker(projectRoot) {
82
- for (const candidate of versionMarkerPaths(projectRoot)) {
83
- if (!existsSync(candidate) || !statSync(candidate).isFile())
84
- continue;
85
- try {
86
- const value = readFileSync(candidate, "utf8").trim();
87
- if (value)
88
- return value;
89
- }
90
- catch {
91
- // try next candidate
92
- }
93
- }
94
- return null;
95
- }
96
- function writeVersionMarker(targetDir, version) {
97
- if (version === DEV_FALLBACK)
98
- return;
99
- try {
100
- mkdirSync(targetDir, { recursive: true });
101
- writeFileSync(join(targetDir, ".deft-version"), `${version}\n`, "utf8");
102
- }
103
- catch {
104
- // best-effort, mirrors Python
105
- }
106
- }
107
- function deriveInstallRootString(installRoot, projectRoot) {
108
- try {
109
- return relative(projectRoot, installRoot).split("\\").join("/") || CANONICAL_INSTALL_ROOT;
110
- }
111
- catch {
112
- return resolve(installRoot).split("\\").join("/");
113
- }
114
- }
115
- function writeInstallManifestAt(installRoot, projectRoot, version) {
116
- if (version.replace(/^v/, "") === DEV_FALLBACK)
117
- return null;
118
- const priorManagedBy = readManagedByAt(installRoot);
119
- const fields = {
120
- ref: version.startsWith("v") ? version : `v${version}`,
121
- sha: "content-package",
122
- tag: version.startsWith("v") ? version : `v${version}`,
123
- installRoot: deriveInstallRootString(installRoot, projectRoot),
124
- fetchedAt: new Date().toISOString().replace(/\.\d{3}Z$/, "Z"),
125
- fetchedBy: "deft-upgrade",
126
- ...(priorManagedBy ? { managedBy: priorManagedBy } : {}),
127
- };
128
- try {
129
- mkdirSync(installRoot, { recursive: true });
130
- const body = buildInstallManifestText(fields);
131
- const path = join(installRoot, "VERSION");
132
- writeFileSync(path, body, "utf8");
133
- return path;
134
- }
135
- catch {
136
- return null;
137
- }
138
- }
139
- function migrateLegacyInstallManifest(projectRoot, canonicalManifestPath) {
140
- if (canonicalManifestPath === null)
141
- return;
142
- const canonical = resolve(canonicalManifestPath);
143
- const expectedParent = resolve(projectRoot, ".deft", "core");
144
- if (resolve(canonical, "..") !== expectedParent)
145
- return;
146
- const legacy = join(projectRoot, ".deft", "VERSION");
147
- if (!existsSync(legacy) || !statSync(legacy).isFile())
148
- return;
149
- try {
150
- const legacyVersion = manifestTagToVersion(parseInstallManifest(readFileSync(legacy, "utf8")));
151
- const canonicalVersion = manifestTagToVersion(parseInstallManifest(readFileSync(canonical, "utf8")));
152
- if (legacyVersion !== null && legacyVersion === canonicalVersion)
153
- return;
154
- renameSync(legacy, join(projectRoot, ".deft", "VERSION.premigrate"));
155
- }
156
- catch {
157
- // best-effort
158
- }
159
- }
160
- function runAgentsRefresh(projectRoot, frameworkRoot, io) {
161
- const plan = agentsRefreshPlan(projectRoot, { frameworkRoot });
162
- const state = String(plan.state ?? "unknown");
163
- if (state === "current") {
164
- io.writeOut("AGENTS.md managed section is current — no changes.\n");
165
- return 0;
166
- }
167
- if (state === "template-missing" || state === "template-malformed" || state === "unreadable") {
168
- io.writeErr(`agents:refresh failed: ${state}\n`);
169
- return 2;
170
- }
171
- const newContent = plan.new_content;
172
- if (typeof newContent !== "string") {
173
- io.writeErr("agents:refresh failed: plan produced no new_content\n");
174
- return 2;
175
- }
176
- const path = String(plan.path ?? join(projectRoot, "AGENTS.md"));
177
- writeFileSync(path, newContent, "utf8");
178
- io.writeOut(`AGENTS.md updated (state=${state}).\n`);
179
- return 0;
180
- }
181
- function handleLegacyXbriefLayout(args, io, recorded, normalizedVersion) {
182
- const detection = detectLegacyVbriefLayout(args.projectRoot);
183
- if (!detection.legacyLayout) {
184
- return 0;
185
- }
186
- io.writeOut(`${renderXbriefMigrationLine(args.projectRoot)}\n`);
187
- const patchInert = isPatchOnlyUpgrade(recorded, normalizedVersion);
188
- if (!args.migrate || patchInert) {
189
- return 0;
190
- }
191
- const outcome = runXbriefMigration({
192
- projectRoot: args.projectRoot,
193
- frameworkRoot: args.frameworkRoot,
194
- force: args.force,
195
- }, io);
196
- const code = emitXbriefMigration(outcome, io, { projectRoot: args.projectRoot });
197
- return code;
198
- }
199
- /** Port of ``run upgrade`` / ``task install:upgrade`` for the consumer task surface (#1061 / #2022). */
200
- export function runInstallUpgrade(args, io) {
201
- const projectRoot = resolve(args.projectRoot);
202
- const frameworkRoot = resolve(args.frameworkRoot);
203
- const version = resolveUpgradeVersion(frameworkRoot, projectRoot);
204
- const normalizedVersion = version.startsWith("v") ? version.slice(1) : version;
205
- // Render AGENTS.md from the deposited install root so the managed section
206
- // matches the installed payload, not the engine's bundled templates (which a
207
- // global npm `deft` may carry at a different version). Falls back to the engine
208
- // framework root when no deposit is present.
209
- const installRoot = resolveInstallRoot(projectRoot);
210
- const agentsRoot = installRoot ?? frameworkRoot;
211
- io.writeOut(`Deft CLI v${normalizedVersion} - Upgrade\n\n`);
212
- const recorded = readVersionMarker(projectRoot);
213
- if (recorded === normalizedVersion) {
214
- io.writeOut(`Project already at ${normalizedVersion}. Nothing to do.\n`);
215
- const xbriefCode = handleLegacyXbriefLayout(args, io, recorded, normalizedVersion);
216
- if (xbriefCode !== 0)
217
- return xbriefCode;
218
- return runAgentsRefresh(projectRoot, agentsRoot, io);
219
- }
220
- const legacy = detectPreCutoverLegacy(projectRoot);
221
- if (legacy.length > 0) {
222
- io.writeOut(`Pre-v0.20 document model detected (${legacy.join(", ")}). ${frozenPreCutoverMigrationGuidance()}\n`);
223
- }
224
- const vbriefDir = resolveLifecycleRoot(projectRoot);
225
- const targetDir = existsSync(vbriefDir) && statSync(vbriefDir).isDirectory() ? vbriefDir : projectRoot;
226
- writeVersionMarker(targetDir, normalizedVersion);
227
- const writtenManifestPath = installRoot !== null
228
- ? writeInstallManifestAt(installRoot, projectRoot, normalizedVersion)
229
- : null;
230
- migrateLegacyInstallManifest(projectRoot, writtenManifestPath);
231
- if (normalizedVersion === DEV_FALLBACK) {
232
- // #2053: the marker + manifest writers above no-op on the dev fallback, so do
233
- // not claim a marker update that never happened.
234
- io.writeOut("Could not resolve a published framework version (resolved 0.0.0-dev); " +
235
- ".deft-version marker and install manifest were left unchanged. On a consumer " +
236
- "install, ensure <project>/.deft/core/VERSION carries a real tag, or upgrade the " +
237
- "engine with `npm i -g @deftai/directive@latest`.\n");
238
- }
239
- else if (recorded === null) {
240
- io.writeOut(`Recorded framework version ${normalizedVersion} in .deft-version.\n`);
241
- }
242
- else {
243
- io.writeOut(`Updated .deft-version from ${recorded} to ${normalizedVersion}.\n`);
244
- }
245
- io.writeOut(`If legacy SPECIFICATION.md or PROJECT.md content remains, see UPGRADING.md § Frozen pre-v0.20 document-model migration (#2068).\n`);
246
- const xbriefCode = handleLegacyXbriefLayout(args, io, recorded, normalizedVersion);
247
- if (xbriefCode !== 0)
248
- return xbriefCode;
249
- return runAgentsRefresh(projectRoot, agentsRoot, io);
250
- }
251
- //# sourceMappingURL=index.js.map