@deftai/directive-core 0.66.1 → 0.66.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.
@@ -2,6 +2,7 @@
2
2
  export declare function resolvePath(pathStr: string, cwd?: string): string;
3
3
  /** Best-effort version string (mirrors Python `_resolve_version`). */
4
4
  export declare function resolveVersion(frameworkRoot?: string): string;
5
+ export declare function resolveFrameworkRootForProject(projectRoot: string, explicitRoot?: string | null): string;
5
6
  /** Return the deft framework repo root (the directory containing `main.md`). */
6
7
  export declare function resolveDefaultFrameworkRoot(): string;
7
8
  /** Directory containing doctor implementation (Python: scripts/). */
@@ -32,6 +32,61 @@ export function resolveVersion(frameworkRoot) {
32
32
  }
33
33
  return "dev";
34
34
  }
35
+ /**
36
+ * Resolve the framework root for a CLI command running against `projectRoot`.
37
+ *
38
+ * Priority: explicit `--deft-root` / `--framework-root` → `DEFT_ROOT` env →
39
+ * maintainer source checkout at `projectRoot` (when `main.md` + framework markers
40
+ * are present, even if a dogfood `.deft/core` deposit also exists) → consumer
41
+ * deposit (`.deft/core`, legacy `deft/`) → maintainer checkout walk
42
+ * (`resolveDefaultFrameworkRoot`).
43
+ *
44
+ * Refs #2146 (npm global `deft` must not default to `node_modules/vbrief/schemas`).
45
+ */
46
+ function isFrameworkSourceCheckoutAt(projectRoot) {
47
+ try {
48
+ if (!statSync(join(projectRoot, "main.md")).isFile()) {
49
+ return false;
50
+ }
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ return DEFT_REPO_POSITIVE_MARKERS.every((marker) => {
56
+ try {
57
+ return statSync(join(projectRoot, marker)).isFile();
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ });
63
+ }
64
+ export function resolveFrameworkRootForProject(projectRoot, explicitRoot) {
65
+ const explicit = explicitRoot?.trim();
66
+ if (explicit) {
67
+ return resolve(explicit);
68
+ }
69
+ const envRoot = process.env.DEFT_ROOT?.trim();
70
+ if (envRoot) {
71
+ return resolve(envRoot);
72
+ }
73
+ const root = resolve(projectRoot);
74
+ if (isFrameworkSourceCheckoutAt(root)) {
75
+ return root;
76
+ }
77
+ for (const rel of [join(".deft", "core"), "deft"]) {
78
+ const candidate = join(root, rel);
79
+ try {
80
+ if (statSync(candidate).isDirectory()) {
81
+ return candidate;
82
+ }
83
+ }
84
+ catch {
85
+ // try next candidate
86
+ }
87
+ }
88
+ return resolveDefaultFrameworkRoot();
89
+ }
35
90
  /** Return the deft framework repo root (the directory containing `main.md`). */
36
91
  export function resolveDefaultFrameworkRoot() {
37
92
  const envRoot = process.env.DEFT_ROOT?.trim();
@@ -38,6 +38,8 @@ import { LEGACY_ARTIFACT_DIR, LEGACY_ARTIFACT_SUFFIX, MIGRATED_ARTIFACT_DIR, MIG
38
38
  export const LEGACY_REFERENCE_PREFIX = "x-vbrief/";
39
39
  /** Default allowlist: sanctioned data-plane trees that legitimately retain legacy tokens for back-compat. */
40
40
  export const BUILTIN_ALLOW_LIST = [
41
+ // Vendored npm deposit (#2146): C1 flatten maps content/vbrief/* -> .deft/core/vbrief/*.
42
+ ".deft/core/vbrief/**",
41
43
  // Shipped vBRIEF surface (#1875 C3) + conformance round-trip fixtures (#715).
42
44
  "content/vbrief/**",
43
45
  // Test fixtures exercising the legacy read path + pre-cutover migration (#2108 / #2110)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive-core",
3
- "version": "0.66.1",
3
+ "version": "0.66.2",
4
4
  "description": "TypeScript engine core for the Directive framework.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -237,8 +237,8 @@
237
237
  "provenance": true
238
238
  },
239
239
  "dependencies": {
240
- "@deftai/directive-content": "^0.66.1",
241
- "@deftai/directive-types": "^0.66.1",
240
+ "@deftai/directive-content": "^0.66.2",
241
+ "@deftai/directive-types": "^0.66.2",
242
242
  "archiver": "^8.0.0"
243
243
  },
244
244
  "scripts": {