@deftai/directive 0.128.0 → 0.129.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.
- package/dist/bin.js +218 -113
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -427,15 +427,98 @@ Recovery: ${RECOVERY_GUIDANCE}
|
|
|
427
427
|
import { mkdirSync } from "node:fs";
|
|
428
428
|
|
|
429
429
|
// packages/cli/src/bookends.ts
|
|
430
|
-
import { existsSync as
|
|
431
|
-
import { join as
|
|
430
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
|
|
431
|
+
import { join as join7 } from "node:path";
|
|
432
|
+
|
|
433
|
+
// packages/cli/src/age-exclude.ts
|
|
434
|
+
import { existsSync as existsSync4, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
435
|
+
import { join as join3 } from "node:path";
|
|
436
|
+
var RUNTIME_AGE_EXCLUDE_PACKAGE = "@deftai/directive-runtime";
|
|
437
|
+
var PNPM_WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
438
|
+
var KEY_RE = /^(\s*)minimumReleaseAgeExclude:\s*(#.*)?$/;
|
|
439
|
+
var ITEM_RE = /^(\s*)-\s+(.*)$/;
|
|
440
|
+
var EXACT_VERSION_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
441
|
+
function indentOf(line) {
|
|
442
|
+
return line.length - line.trimStart().length;
|
|
443
|
+
}
|
|
444
|
+
function itemValue(raw) {
|
|
445
|
+
let v = raw.trim();
|
|
446
|
+
if (v.startsWith("'") || v.startsWith('"')) {
|
|
447
|
+
const q = v[0];
|
|
448
|
+
const end = v.indexOf(q, 1);
|
|
449
|
+
return end > 0 ? v.slice(1, end) : v;
|
|
450
|
+
}
|
|
451
|
+
const hash = v.search(/\s#/);
|
|
452
|
+
if (hash >= 0) v = v.slice(0, hash);
|
|
453
|
+
return v.trim();
|
|
454
|
+
}
|
|
455
|
+
function isRuntimeExact(value) {
|
|
456
|
+
const prefix = `${RUNTIME_AGE_EXCLUDE_PACKAGE}@`;
|
|
457
|
+
return value.startsWith(prefix) && EXACT_VERSION_RE.test(value.slice(prefix.length));
|
|
458
|
+
}
|
|
459
|
+
function upsertRuntimeAgeExcludeText(text, targetVersion) {
|
|
460
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
461
|
+
const lines = text.split(eol);
|
|
462
|
+
const keyIdx = lines.findIndex((l) => KEY_RE.test(l));
|
|
463
|
+
if (keyIdx < 0) return { changed: false, text, priorRuntimeItems: [] };
|
|
464
|
+
const keyIndent = indentOf(lines[keyIdx]);
|
|
465
|
+
const runtimeIdx = [];
|
|
466
|
+
const prior = [];
|
|
467
|
+
for (let i = keyIdx + 1; i < lines.length; i++) {
|
|
468
|
+
const line = lines[i];
|
|
469
|
+
const trimmed = line.trim();
|
|
470
|
+
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
471
|
+
const m = ITEM_RE.exec(line);
|
|
472
|
+
if (m === null || indentOf(line) < keyIndent) break;
|
|
473
|
+
const value = itemValue(m[2]);
|
|
474
|
+
if (isRuntimeExact(value)) {
|
|
475
|
+
runtimeIdx.push(i);
|
|
476
|
+
prior.push(value);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (runtimeIdx.length === 0) return { changed: false, text, priorRuntimeItems: [] };
|
|
480
|
+
const first = runtimeIdx[0];
|
|
481
|
+
const itemIndent = ITEM_RE.exec(lines[first])?.[1] ?? "";
|
|
482
|
+
const replacement = `${itemIndent}- '${RUNTIME_AGE_EXCLUDE_PACKAGE}@${targetVersion}'`;
|
|
483
|
+
const drop = new Set(runtimeIdx.slice(1));
|
|
484
|
+
const out = [];
|
|
485
|
+
for (let i = 0; i < lines.length; i++) {
|
|
486
|
+
if (drop.has(i)) continue;
|
|
487
|
+
out.push(i === first ? replacement : lines[i]);
|
|
488
|
+
}
|
|
489
|
+
const next = out.join(eol);
|
|
490
|
+
return { changed: next !== text, text: next, priorRuntimeItems: prior };
|
|
491
|
+
}
|
|
492
|
+
function previewRuntimeAgeExcludeHeal(projectRoot, targetVersion) {
|
|
493
|
+
const abs = join3(projectRoot, PNPM_WORKSPACE_FILE);
|
|
494
|
+
if (!existsSync4(abs)) return null;
|
|
495
|
+
const r = upsertRuntimeAgeExcludeText(readFileSync2(abs, "utf8"), targetVersion);
|
|
496
|
+
return r.changed ? r : null;
|
|
497
|
+
}
|
|
498
|
+
function healRuntimeAgeExclude(projectRoot, targetVersion) {
|
|
499
|
+
const r = previewRuntimeAgeExcludeHeal(projectRoot, targetVersion);
|
|
500
|
+
if (r === null) return false;
|
|
501
|
+
writeFileSync(join3(projectRoot, PNPM_WORKSPACE_FILE), r.text, "utf8");
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
function formatAgeExcludeHealLine(r, targetVersion) {
|
|
505
|
+
return `pnpm-workspace.yaml: replace minimumReleaseAgeExclude ${r.priorRuntimeItems.join(", ")} with one '${RUNTIME_AGE_EXCLUDE_PACKAGE}@${targetVersion}' entry (#5854)
|
|
506
|
+
`;
|
|
507
|
+
}
|
|
508
|
+
function addWithRuntimeAgeExcludeHeal(projectRoot, pm, targetVersion, add) {
|
|
509
|
+
if (pm !== "pnpm") return add();
|
|
510
|
+
healRuntimeAgeExclude(projectRoot, targetVersion);
|
|
511
|
+
const result = add();
|
|
512
|
+
if (result.ok) healRuntimeAgeExclude(projectRoot, targetVersion);
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
432
515
|
|
|
433
516
|
// packages/cli/src/contract-invoke.ts
|
|
434
517
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
435
|
-
import { existsSync as
|
|
518
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
436
519
|
function invokeRuntime(options) {
|
|
437
520
|
const { projectRoot, launcherVersion, runtime, argv } = options;
|
|
438
|
-
if (!
|
|
521
|
+
if (!existsSync5(runtime.entryPath)) {
|
|
439
522
|
return {
|
|
440
523
|
exitCode: EXIT_CODES.FAILURE,
|
|
441
524
|
stdout: "",
|
|
@@ -552,8 +635,8 @@ function readInteractiveLine(options) {
|
|
|
552
635
|
|
|
553
636
|
// packages/cli/src/legacy-shapes/detect.ts
|
|
554
637
|
import { execFileSync } from "node:child_process";
|
|
555
|
-
import { readFileSync as
|
|
556
|
-
import { join as
|
|
638
|
+
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
639
|
+
import { join as join4 } from "node:path";
|
|
557
640
|
|
|
558
641
|
// packages/cli/src/legacy-shapes/registry.ts
|
|
559
642
|
var DECISION_BY_SHAPE_ID = {
|
|
@@ -586,16 +669,16 @@ function isDir(path) {
|
|
|
586
669
|
}
|
|
587
670
|
function readText(path) {
|
|
588
671
|
try {
|
|
589
|
-
return
|
|
672
|
+
return readFileSync3(path, "utf8");
|
|
590
673
|
} catch {
|
|
591
674
|
return null;
|
|
592
675
|
}
|
|
593
676
|
}
|
|
594
677
|
var LEGACY_DEFT_DIR = "deft";
|
|
595
678
|
function isFrameworkDeftDir(projectRoot) {
|
|
596
|
-
const deftDir =
|
|
679
|
+
const deftDir = join4(projectRoot, LEGACY_DEFT_DIR);
|
|
597
680
|
if (!isDir(deftDir)) return false;
|
|
598
|
-
return isFile(
|
|
681
|
+
return isFile(join4(deftDir, "VERSION")) || isFile(join4(deftDir, "main.md")) || isFile(join4(deftDir, "Taskfile.yml")) || isDir(join4(deftDir, "skills"));
|
|
599
682
|
}
|
|
600
683
|
function gitmodulesReferencesFramework(text) {
|
|
601
684
|
const normalized = text.replace(/\r\n/g, "\n").toLowerCase();
|
|
@@ -643,12 +726,12 @@ function resolveInstallShape(projectRoot) {
|
|
|
643
726
|
if (hasCore) {
|
|
644
727
|
return resolution("vendored-core-go", [".deft/core (copied-core evidence, no exact pin)"]);
|
|
645
728
|
}
|
|
646
|
-
if (isFile(
|
|
729
|
+
if (isFile(join4(projectRoot, ".deft", "VERSION")) && !isDir(join4(projectRoot, ".deft", "core"))) {
|
|
647
730
|
return resolution("orphan-deft-version", [".deft/VERSION"]);
|
|
648
731
|
}
|
|
649
|
-
const deftDir =
|
|
732
|
+
const deftDir = join4(projectRoot, LEGACY_DEFT_DIR);
|
|
650
733
|
if (frameworkDeft) {
|
|
651
|
-
const submoduleGit = isFile(
|
|
734
|
+
const submoduleGit = isFile(join4(deftDir, ".git")) || isDir(join4(deftDir, ".git"));
|
|
652
735
|
if (submoduleGit) {
|
|
653
736
|
if (isUnsafeSubmoduleGitlink(projectRoot)) {
|
|
654
737
|
return resolution(
|
|
@@ -661,7 +744,7 @@ function resolveInstallShape(projectRoot) {
|
|
|
661
744
|
}
|
|
662
745
|
return resolution("go-tarball-deft-root", ["deft/"]);
|
|
663
746
|
}
|
|
664
|
-
const gitmodulesPath =
|
|
747
|
+
const gitmodulesPath = join4(projectRoot, ".gitmodules");
|
|
665
748
|
if (isFile(gitmodulesPath)) {
|
|
666
749
|
const text = readText(gitmodulesPath);
|
|
667
750
|
if (text !== null && gitmodulesReferencesFramework(text)) {
|
|
@@ -699,8 +782,8 @@ function isL2RefusalDecision(decision) {
|
|
|
699
782
|
// packages/cli/src/pm.ts
|
|
700
783
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
701
784
|
import { createHash } from "node:crypto";
|
|
702
|
-
import { existsSync as
|
|
703
|
-
import { join as
|
|
785
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
786
|
+
import { join as join5 } from "node:path";
|
|
704
787
|
var PARTIAL_CHANGES_MAY_REMAIN = "Partial changes may remain.";
|
|
705
788
|
var INSTALL_SCRIPT_POLICY_PLAN_LINE = "install-script policy: PM exact-add uses --ignore-scripts (pin/wiring do not require package lifecycle scripts); project registry, authentication, proxy, and lockfile settings are honoured";
|
|
706
789
|
var EXACT_SEMVER_RE = /^\d+\.\d+\.\d+([-+][0-9A-Za-z.-]+)?$/;
|
|
@@ -714,7 +797,7 @@ function isPrereleaseVersion(version) {
|
|
|
714
797
|
}
|
|
715
798
|
function readJsonObject2(path) {
|
|
716
799
|
try {
|
|
717
|
-
const raw =
|
|
800
|
+
const raw = readFileSync4(path, "utf8");
|
|
718
801
|
const parsed = JSON.parse(raw);
|
|
719
802
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
720
803
|
return parsed;
|
|
@@ -733,14 +816,14 @@ function parsePmNameToken(raw) {
|
|
|
733
816
|
return { kind: "unsupported", name };
|
|
734
817
|
}
|
|
735
818
|
function readPackageManagerField(projectRoot) {
|
|
736
|
-
const pkg = readJsonObject2(
|
|
819
|
+
const pkg = readJsonObject2(join5(projectRoot, "package.json"));
|
|
737
820
|
if (pkg === null) return { kind: "absent" };
|
|
738
821
|
const raw = pkg.packageManager;
|
|
739
822
|
if (typeof raw !== "string" || raw.trim() === "") return { kind: "absent" };
|
|
740
823
|
return parsePmNameToken(raw);
|
|
741
824
|
}
|
|
742
825
|
function readDevEnginesPackageManager(projectRoot) {
|
|
743
|
-
const pkg = readJsonObject2(
|
|
826
|
+
const pkg = readJsonObject2(join5(projectRoot, "package.json"));
|
|
744
827
|
if (pkg === null) return { kind: "absent" };
|
|
745
828
|
const devEngines = pkg.devEngines;
|
|
746
829
|
if (devEngines === null || typeof devEngines !== "object" || Array.isArray(devEngines)) {
|
|
@@ -790,8 +873,8 @@ function readDeclaredPackageManagerSlot(projectRoot) {
|
|
|
790
873
|
return { kind: "absent" };
|
|
791
874
|
}
|
|
792
875
|
function detectPackageManager(projectRoot, flag) {
|
|
793
|
-
const hasYarn =
|
|
794
|
-
const hasBun =
|
|
876
|
+
const hasYarn = existsSync6(join5(projectRoot, "yarn.lock"));
|
|
877
|
+
const hasBun = existsSync6(join5(projectRoot, "bun.lock")) || existsSync6(join5(projectRoot, "bun.lockb"));
|
|
795
878
|
if (hasYarn) {
|
|
796
879
|
return {
|
|
797
880
|
ok: false,
|
|
@@ -822,8 +905,8 @@ function detectPackageManager(projectRoot, flag) {
|
|
|
822
905
|
};
|
|
823
906
|
}
|
|
824
907
|
}
|
|
825
|
-
const hasPnpmLock =
|
|
826
|
-
const hasNpmLock =
|
|
908
|
+
const hasPnpmLock = existsSync6(join5(projectRoot, "pnpm-lock.yaml"));
|
|
909
|
+
const hasNpmLock = existsSync6(join5(projectRoot, "package-lock.json"));
|
|
827
910
|
const fieldPm = declared.kind === "supported" ? declared.pm : null;
|
|
828
911
|
const fieldEvidence = declared.kind === "supported" ? declared.evidence : null;
|
|
829
912
|
if (hasPnpmLock && hasNpmLock) {
|
|
@@ -915,16 +998,16 @@ function npmRootRequest(packages) {
|
|
|
915
998
|
}
|
|
916
999
|
function lockfileRecordsExactPin(projectRoot, exactVersion, pm) {
|
|
917
1000
|
if (pm === "pnpm") {
|
|
918
|
-
const pnpmLock =
|
|
919
|
-
if (!
|
|
1001
|
+
const pnpmLock = join5(projectRoot, "pnpm-lock.yaml");
|
|
1002
|
+
if (!existsSync6(pnpmLock)) return false;
|
|
920
1003
|
try {
|
|
921
|
-
return pnpmRootRecordsExactPin(
|
|
1004
|
+
return pnpmRootRecordsExactPin(readFileSync4(pnpmLock, "utf8"), exactVersion);
|
|
922
1005
|
} catch {
|
|
923
1006
|
return false;
|
|
924
1007
|
}
|
|
925
1008
|
}
|
|
926
|
-
const npmLock =
|
|
927
|
-
if (!
|
|
1009
|
+
const npmLock = join5(projectRoot, "package-lock.json");
|
|
1010
|
+
if (!existsSync6(npmLock)) return false;
|
|
928
1011
|
const lock = readJsonObject2(npmLock);
|
|
929
1012
|
if (lock === null) return false;
|
|
930
1013
|
const packages = lock.packages;
|
|
@@ -941,17 +1024,17 @@ function lockfileRecordsExactPin(projectRoot, exactVersion, pm) {
|
|
|
941
1024
|
return false;
|
|
942
1025
|
}
|
|
943
1026
|
function ensurePackageJson(projectRoot) {
|
|
944
|
-
const path =
|
|
945
|
-
if (
|
|
1027
|
+
const path = join5(projectRoot, "package.json");
|
|
1028
|
+
if (existsSync6(path)) {
|
|
946
1029
|
const existing = readJsonObject2(path);
|
|
947
1030
|
if (existing !== null && Object.keys(existing).length === 0) {
|
|
948
|
-
|
|
1031
|
+
writeFileSync2(path, `${JSON.stringify({ private: true }, null, 2)}
|
|
949
1032
|
`);
|
|
950
1033
|
return { created: true, path };
|
|
951
1034
|
}
|
|
952
1035
|
return { created: false, path };
|
|
953
1036
|
}
|
|
954
|
-
|
|
1037
|
+
writeFileSync2(path, `${JSON.stringify({ private: true }, null, 2)}
|
|
955
1038
|
`);
|
|
956
1039
|
return { created: true, path };
|
|
957
1040
|
}
|
|
@@ -962,7 +1045,7 @@ function versionFromPmToken(raw) {
|
|
|
962
1045
|
return ver.length > 0 ? ver : null;
|
|
963
1046
|
}
|
|
964
1047
|
function readDeclaredPackageManagerVersion(projectRoot) {
|
|
965
|
-
const pkg = readJsonObject2(
|
|
1048
|
+
const pkg = readJsonObject2(join5(projectRoot, "package.json"));
|
|
966
1049
|
if (pkg === null) return null;
|
|
967
1050
|
if (typeof pkg.packageManager === "string" && pkg.packageManager.trim() !== "") {
|
|
968
1051
|
const fromField = versionFromPmToken(pkg.packageManager.trim());
|
|
@@ -1021,9 +1104,9 @@ function ensurePackageManagerAvailable(pm, env = process.env, declaredVersion =
|
|
|
1021
1104
|
return { ok: true };
|
|
1022
1105
|
}
|
|
1023
1106
|
function fileDigest(absPath) {
|
|
1024
|
-
if (!
|
|
1107
|
+
if (!existsSync6(absPath)) return null;
|
|
1025
1108
|
try {
|
|
1026
|
-
return createHash("sha256").update(
|
|
1109
|
+
return createHash("sha256").update(readFileSync4(absPath)).digest("hex");
|
|
1027
1110
|
} catch {
|
|
1028
1111
|
return null;
|
|
1029
1112
|
}
|
|
@@ -1042,7 +1125,7 @@ function planCriticalRelPaths(_pm) {
|
|
|
1042
1125
|
function fingerprintPlanCriticalFiles(projectRoot, pm) {
|
|
1043
1126
|
const entries = planCriticalRelPaths(pm).map((relPath) => ({
|
|
1044
1127
|
relPath,
|
|
1045
|
-
digest: fileDigest(
|
|
1128
|
+
digest: fileDigest(join5(projectRoot, relPath))
|
|
1046
1129
|
}));
|
|
1047
1130
|
return { entries };
|
|
1048
1131
|
}
|
|
@@ -1092,7 +1175,7 @@ function interpretPmSpawnResult(pm, args, result) {
|
|
|
1092
1175
|
return { ok: true };
|
|
1093
1176
|
}
|
|
1094
1177
|
function isPnpmWorkspaceRoot(projectRoot) {
|
|
1095
|
-
return
|
|
1178
|
+
return existsSync6(join5(projectRoot, "pnpm-workspace.yaml"));
|
|
1096
1179
|
}
|
|
1097
1180
|
function buildPmExactAddArgs(pm, version, projectRoot) {
|
|
1098
1181
|
const spec = `${RUNTIME_PACKAGE_NAME}@${version}`;
|
|
@@ -1116,7 +1199,7 @@ var RETIRED_DIRECTIVE_PACKAGE_NAMES = [
|
|
|
1116
1199
|
"@deftai/directive-types"
|
|
1117
1200
|
];
|
|
1118
1201
|
function removeLegacyDirectivePackages(projectRoot) {
|
|
1119
|
-
const path =
|
|
1202
|
+
const path = join5(projectRoot, "package.json");
|
|
1120
1203
|
const pkg = readJsonObject2(path);
|
|
1121
1204
|
if (pkg === null) return false;
|
|
1122
1205
|
let removed = false;
|
|
@@ -1134,7 +1217,7 @@ function removeLegacyDirectivePackages(projectRoot) {
|
|
|
1134
1217
|
}
|
|
1135
1218
|
}
|
|
1136
1219
|
if (!removed) return false;
|
|
1137
|
-
|
|
1220
|
+
writeFileSync2(path, `${JSON.stringify(pkg, null, 2)}
|
|
1138
1221
|
`);
|
|
1139
1222
|
return true;
|
|
1140
1223
|
}
|
|
@@ -1156,11 +1239,11 @@ function lockfileReferencesRetiredDirective(contents) {
|
|
|
1156
1239
|
function purgeRetiredDirectiveLockfiles(projectRoot) {
|
|
1157
1240
|
const purged = [];
|
|
1158
1241
|
for (const rel of LOCKFILE_CANDIDATES) {
|
|
1159
|
-
const abs =
|
|
1160
|
-
if (!
|
|
1242
|
+
const abs = join5(projectRoot, rel);
|
|
1243
|
+
if (!existsSync6(abs)) continue;
|
|
1161
1244
|
let contents;
|
|
1162
1245
|
try {
|
|
1163
|
-
contents =
|
|
1246
|
+
contents = readFileSync4(abs, "utf8");
|
|
1164
1247
|
} catch {
|
|
1165
1248
|
continue;
|
|
1166
1249
|
}
|
|
@@ -2198,14 +2281,14 @@ function resolvePublishedContract(version, env = process.env, projectRoot) {
|
|
|
2198
2281
|
// packages/cli/src/uninstall-map.ts
|
|
2199
2282
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
2200
2283
|
import {
|
|
2201
|
-
existsSync as
|
|
2284
|
+
existsSync as existsSync7,
|
|
2202
2285
|
readdirSync,
|
|
2203
|
-
readFileSync as
|
|
2286
|
+
readFileSync as readFileSync5,
|
|
2204
2287
|
realpathSync as realpathSync2,
|
|
2205
2288
|
rmSync,
|
|
2206
|
-
writeFileSync as
|
|
2289
|
+
writeFileSync as writeFileSync3
|
|
2207
2290
|
} from "node:fs";
|
|
2208
|
-
import { dirname, isAbsolute as isAbsolute2, join as
|
|
2291
|
+
import { dirname, isAbsolute as isAbsolute2, join as join6, normalize, relative, resolve as resolve2, sep } from "node:path";
|
|
2209
2292
|
var MANAGED_OPEN = "<!-- deft:managed-section";
|
|
2210
2293
|
var MANAGED_CLOSE = "<!-- /deft:managed-section -->";
|
|
2211
2294
|
var RUNTIME_PREFIX = "node_modules/@deftai/directive-runtime/";
|
|
@@ -2237,14 +2320,14 @@ var HOST_HOOK_RELS = [
|
|
|
2237
2320
|
];
|
|
2238
2321
|
function readText2(path) {
|
|
2239
2322
|
try {
|
|
2240
|
-
return
|
|
2323
|
+
return readFileSync5(path, "utf8");
|
|
2241
2324
|
} catch {
|
|
2242
2325
|
return null;
|
|
2243
2326
|
}
|
|
2244
2327
|
}
|
|
2245
2328
|
function readJsonObject3(path) {
|
|
2246
2329
|
try {
|
|
2247
|
-
const raw =
|
|
2330
|
+
const raw = readFileSync5(path, "utf8");
|
|
2248
2331
|
const parsed = JSON.parse(raw);
|
|
2249
2332
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
2250
2333
|
return parsed;
|
|
@@ -2253,7 +2336,7 @@ function readJsonObject3(path) {
|
|
|
2253
2336
|
}
|
|
2254
2337
|
}
|
|
2255
2338
|
function pkgHasDep(projectRoot, name) {
|
|
2256
|
-
const pkg = readJsonObject3(
|
|
2339
|
+
const pkg = readJsonObject3(join6(projectRoot, "package.json"));
|
|
2257
2340
|
if (pkg === null) return false;
|
|
2258
2341
|
for (const key of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
2259
2342
|
const block = pkg[key];
|
|
@@ -2305,18 +2388,18 @@ function safeWriteText(projectRoot, rel, body) {
|
|
|
2305
2388
|
const abs = resolve2(projectRoot, rel);
|
|
2306
2389
|
if (!isPathInsideProjectRoot(projectRoot, abs)) return false;
|
|
2307
2390
|
try {
|
|
2308
|
-
|
|
2391
|
+
writeFileSync3(abs, body);
|
|
2309
2392
|
return true;
|
|
2310
2393
|
} catch {
|
|
2311
2394
|
return false;
|
|
2312
2395
|
}
|
|
2313
2396
|
}
|
|
2314
2397
|
function parseOwnershipArtifacts(projectRoot) {
|
|
2315
|
-
const path =
|
|
2316
|
-
if (!
|
|
2398
|
+
const path = join6(projectRoot, ".deft", "GENERATION.json");
|
|
2399
|
+
if (!existsSync7(path)) return { inspection: "absent", artifacts: [], rejected: [] };
|
|
2317
2400
|
let parsed;
|
|
2318
2401
|
try {
|
|
2319
|
-
parsed = JSON.parse(
|
|
2402
|
+
parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
2320
2403
|
} catch {
|
|
2321
2404
|
return { inspection: "unreadable", artifacts: [], rejected: [] };
|
|
2322
2405
|
}
|
|
@@ -2373,8 +2456,8 @@ function isOurGitHook(rel, body) {
|
|
|
2373
2456
|
return body.includes("_directive-run.sh") || body.includes("_deft-run.sh") || body.includes(RUNTIME_PREFIX) || /\brun_deft\s+(verify:|preflight)/.test(body);
|
|
2374
2457
|
}
|
|
2375
2458
|
function listWiringReady(projectRoot) {
|
|
2376
|
-
const dir =
|
|
2377
|
-
if (!
|
|
2459
|
+
const dir = join6(projectRoot, ".deft", "directive");
|
|
2460
|
+
if (!existsSync7(dir)) return [];
|
|
2378
2461
|
try {
|
|
2379
2462
|
return readdirSync(dir).filter((n) => n.startsWith("wiring-ready.") && n.endsWith(".json")).map((n) => `.deft/directive/${n}`);
|
|
2380
2463
|
} catch {
|
|
@@ -2388,35 +2471,35 @@ function discoverKnownArtifacts(projectRoot) {
|
|
|
2388
2471
|
out.push(art);
|
|
2389
2472
|
}
|
|
2390
2473
|
};
|
|
2391
|
-
if (
|
|
2474
|
+
if (existsSync7(join6(projectRoot, ".deft", "GENERATION.json"))) {
|
|
2392
2475
|
push({ path: ".deft/GENERATION.json", kind: "whole-file", source: "known-map" });
|
|
2393
2476
|
}
|
|
2394
2477
|
for (const rel of listWiringReady(projectRoot)) {
|
|
2395
2478
|
push({ path: rel, kind: "whole-file", source: "known-map" });
|
|
2396
2479
|
}
|
|
2397
|
-
if (
|
|
2480
|
+
if (existsSync7(join6(projectRoot, ".deft", "directive", "data-schema.json"))) {
|
|
2398
2481
|
push({
|
|
2399
2482
|
path: ".deft/directive/data-schema.json",
|
|
2400
2483
|
kind: "whole-file",
|
|
2401
2484
|
source: "known-map"
|
|
2402
2485
|
});
|
|
2403
2486
|
}
|
|
2404
|
-
if (
|
|
2487
|
+
if (existsSync7(join6(projectRoot, ".deft", "core"))) {
|
|
2405
2488
|
push({ path: ".deft/core", kind: "whole-file", source: "known-map" });
|
|
2406
2489
|
}
|
|
2407
2490
|
for (const rel of GITHOOK_RELS) {
|
|
2408
|
-
const body = readText2(
|
|
2491
|
+
const body = readText2(join6(projectRoot, rel));
|
|
2409
2492
|
if (body !== null && isOurGitHook(rel, body)) {
|
|
2410
2493
|
push({ path: rel, kind: "whole-file", source: "known-map" });
|
|
2411
2494
|
}
|
|
2412
2495
|
}
|
|
2413
2496
|
for (const rel of skillPointerRels()) {
|
|
2414
|
-
const body = readText2(
|
|
2497
|
+
const body = readText2(join6(projectRoot, rel));
|
|
2415
2498
|
if (body !== null && isOurSkillPointer(body)) {
|
|
2416
2499
|
push({ path: rel, kind: "whole-file", source: "known-map" });
|
|
2417
2500
|
}
|
|
2418
2501
|
}
|
|
2419
|
-
const agents = readText2(
|
|
2502
|
+
const agents = readText2(join6(projectRoot, "AGENTS.md"));
|
|
2420
2503
|
if (agents !== null && agents.includes(MANAGED_OPEN)) {
|
|
2421
2504
|
push({
|
|
2422
2505
|
path: "AGENTS.md",
|
|
@@ -2426,7 +2509,7 @@ function discoverKnownArtifacts(projectRoot) {
|
|
|
2426
2509
|
});
|
|
2427
2510
|
}
|
|
2428
2511
|
for (const rel of HOST_HOOK_RELS) {
|
|
2429
|
-
if (
|
|
2512
|
+
if (existsSync7(join6(projectRoot, rel))) {
|
|
2430
2513
|
push({
|
|
2431
2514
|
path: rel,
|
|
2432
2515
|
kind: "structured-entry",
|
|
@@ -2435,7 +2518,7 @@ function discoverKnownArtifacts(projectRoot) {
|
|
|
2435
2518
|
});
|
|
2436
2519
|
}
|
|
2437
2520
|
}
|
|
2438
|
-
const taskfile = readText2(
|
|
2521
|
+
const taskfile = readText2(join6(projectRoot, "Taskfile.yml"));
|
|
2439
2522
|
if (taskfile !== null && (taskfile.includes(`${RUNTIME_PREFIX}Taskfile.yml`) || taskfile.includes(".deft/core/Taskfile.yml") || /(^|\n)[ \t]*deft:\s*(\n|$)/.test(taskfile))) {
|
|
2440
2523
|
push({
|
|
2441
2524
|
path: "Taskfile.yml",
|
|
@@ -2444,10 +2527,10 @@ function discoverKnownArtifacts(projectRoot) {
|
|
|
2444
2527
|
source: "known-map"
|
|
2445
2528
|
});
|
|
2446
2529
|
}
|
|
2447
|
-
if (
|
|
2530
|
+
if (existsSync7(join6(projectRoot, "xbrief"))) {
|
|
2448
2531
|
push({ path: "xbrief", kind: "retained", source: "known-map" });
|
|
2449
2532
|
}
|
|
2450
|
-
if (
|
|
2533
|
+
if (existsSync7(join6(projectRoot, ".deft", "settings.json"))) {
|
|
2451
2534
|
push({ path: ".deft/settings.json", kind: "retained", source: "known-map" });
|
|
2452
2535
|
}
|
|
2453
2536
|
return out;
|
|
@@ -2471,9 +2554,9 @@ function discoverUninstallFootprint(projectRoot) {
|
|
|
2471
2554
|
const artifacts = mergeArtifacts(fromRecord, fromKnown);
|
|
2472
2555
|
const hasRuntimePin = pkgHasDep(projectRoot, RUNTIME_PACKAGE_NAME);
|
|
2473
2556
|
const hasLegacyLauncherPin = pkgHasDep(projectRoot, LAUNCHER_PACKAGE_NAME);
|
|
2474
|
-
const hasLegacyCore =
|
|
2557
|
+
const hasLegacyCore = existsSync7(join6(projectRoot, ".deft", "core"));
|
|
2475
2558
|
const removable = artifacts.some((a) => a.kind !== "retained");
|
|
2476
|
-
const hasFootprint = removable || hasRuntimePin || hasLegacyLauncherPin || hasLegacyCore ||
|
|
2559
|
+
const hasFootprint = removable || hasRuntimePin || hasLegacyLauncherPin || hasLegacyCore || existsSync7(join6(projectRoot, ".deft", "GENERATION.json"));
|
|
2477
2560
|
return {
|
|
2478
2561
|
artifacts,
|
|
2479
2562
|
ownershipInspection: inspection,
|
|
@@ -2549,7 +2632,7 @@ function safeUnlink(projectRoot, rel) {
|
|
|
2549
2632
|
if (!isSafeOwnershipRelPath(rel)) return false;
|
|
2550
2633
|
const abs = resolve2(projectRoot, rel);
|
|
2551
2634
|
if (!isPathInsideProjectRoot(projectRoot, abs)) return false;
|
|
2552
|
-
if (!
|
|
2635
|
+
if (!existsSync7(abs)) return false;
|
|
2553
2636
|
try {
|
|
2554
2637
|
if (!isPathInsideProjectRoot(projectRoot, abs)) return false;
|
|
2555
2638
|
rmSync(abs, { recursive: true, force: true });
|
|
@@ -2562,8 +2645,8 @@ function maybeRemoveEmptyParents(projectRoot, relFile) {
|
|
|
2562
2645
|
const removed = [];
|
|
2563
2646
|
let dir = dirname(relFile);
|
|
2564
2647
|
while (dir && dir !== "." && dir !== "/") {
|
|
2565
|
-
const abs =
|
|
2566
|
-
if (!
|
|
2648
|
+
const abs = join6(projectRoot, dir);
|
|
2649
|
+
if (!existsSync7(abs)) break;
|
|
2567
2650
|
try {
|
|
2568
2651
|
const entries = readdirSync(abs);
|
|
2569
2652
|
if (entries.length > 0) break;
|
|
@@ -2598,7 +2681,7 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2598
2681
|
});
|
|
2599
2682
|
for (const art of ordered) {
|
|
2600
2683
|
if (art.kind === "retained") {
|
|
2601
|
-
if (
|
|
2684
|
+
if (existsSync7(join6(projectRoot, art.path))) preserved.push(art.path);
|
|
2602
2685
|
continue;
|
|
2603
2686
|
}
|
|
2604
2687
|
if (art.kind === "marked-section") {
|
|
@@ -2631,8 +2714,8 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2631
2714
|
}
|
|
2632
2715
|
if (art.kind === "structured-entry") {
|
|
2633
2716
|
const abs = resolve2(projectRoot, art.path);
|
|
2634
|
-
if (!isPathInsideProjectRoot(projectRoot, abs) || !
|
|
2635
|
-
if (
|
|
2717
|
+
if (!isPathInsideProjectRoot(projectRoot, abs) || !existsSync7(abs)) {
|
|
2718
|
+
if (existsSync7(abs)) {
|
|
2636
2719
|
uncertainty.push(`skipped structured-entry outside project: ${art.path}`);
|
|
2637
2720
|
}
|
|
2638
2721
|
continue;
|
|
@@ -2671,7 +2754,7 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2671
2754
|
continue;
|
|
2672
2755
|
}
|
|
2673
2756
|
if (art.path === "Taskfile.yml") {
|
|
2674
|
-
const body = readText2(
|
|
2757
|
+
const body = readText2(join6(projectRoot, art.path));
|
|
2675
2758
|
if (body !== null) {
|
|
2676
2759
|
const { next, removed: did } = stripTaskfileDeftInclude(body);
|
|
2677
2760
|
if (did) {
|
|
@@ -2719,7 +2802,7 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2719
2802
|
}
|
|
2720
2803
|
for (const rel of [...GITHOOK_RELS, ...skillPointerRels(), ...listWiringReady(projectRoot)]) {
|
|
2721
2804
|
if (removed.includes(rel)) continue;
|
|
2722
|
-
const body = rel.includes("SKILL.md") ? readText2(
|
|
2805
|
+
const body = rel.includes("SKILL.md") ? readText2(join6(projectRoot, rel)) : rel.startsWith(".githooks/") ? readText2(join6(projectRoot, rel)) : existsSync7(join6(projectRoot, rel)) ? "yes" : null;
|
|
2723
2806
|
if (body === null) continue;
|
|
2724
2807
|
if (rel.includes("SKILL.md") && !isOurSkillPointer(body)) continue;
|
|
2725
2808
|
if (rel.startsWith(".githooks/") && !isOurGitHook(rel, body)) continue;
|
|
@@ -2728,17 +2811,17 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2728
2811
|
removed.push(...maybeRemoveEmptyParents(projectRoot, rel));
|
|
2729
2812
|
}
|
|
2730
2813
|
}
|
|
2731
|
-
if (
|
|
2814
|
+
if (existsSync7(join6(projectRoot, ".deft", "core"))) {
|
|
2732
2815
|
if (safeUnlink(projectRoot, ".deft/core")) removed.push(".deft/core");
|
|
2733
2816
|
else leftovers.push(".deft/core");
|
|
2734
2817
|
}
|
|
2735
|
-
if (
|
|
2818
|
+
if (existsSync7(join6(projectRoot, ".deft", "directive", "data-schema.json"))) {
|
|
2736
2819
|
if (safeUnlink(projectRoot, ".deft/directive/data-schema.json")) {
|
|
2737
2820
|
removed.push(".deft/directive/data-schema.json");
|
|
2738
2821
|
}
|
|
2739
2822
|
}
|
|
2740
|
-
const directiveDir =
|
|
2741
|
-
if (
|
|
2823
|
+
const directiveDir = join6(projectRoot, ".deft", "directive");
|
|
2824
|
+
if (existsSync7(directiveDir)) {
|
|
2742
2825
|
try {
|
|
2743
2826
|
const left = readdirSync(directiveDir);
|
|
2744
2827
|
if (left.length === 0) {
|
|
@@ -2750,13 +2833,13 @@ function applyLauncherCleanup(projectRoot, discovery) {
|
|
|
2750
2833
|
} catch {
|
|
2751
2834
|
}
|
|
2752
2835
|
}
|
|
2753
|
-
if (
|
|
2836
|
+
if (existsSync7(join6(projectRoot, ".deft", "GENERATION.json"))) {
|
|
2754
2837
|
if (safeUnlink(projectRoot, ".deft/GENERATION.json")) removed.push(".deft/GENERATION.json");
|
|
2755
2838
|
}
|
|
2756
|
-
if (
|
|
2839
|
+
if (existsSync7(join6(projectRoot, "xbrief")) && !preserved.includes("xbrief")) {
|
|
2757
2840
|
preserved.push("xbrief");
|
|
2758
2841
|
}
|
|
2759
|
-
if (
|
|
2842
|
+
if (existsSync7(join6(projectRoot, ".deft", "settings.json")) && !preserved.includes(".deft/settings.json")) {
|
|
2760
2843
|
preserved.push(".deft/settings.json");
|
|
2761
2844
|
}
|
|
2762
2845
|
return {
|
|
@@ -2783,11 +2866,11 @@ function listLinkedWorktreePaths(projectRoot) {
|
|
|
2783
2866
|
}
|
|
2784
2867
|
}
|
|
2785
2868
|
function siblingNeedsHooksPath(projectRoot) {
|
|
2786
|
-
const rootResolved =
|
|
2869
|
+
const rootResolved = join6(projectRoot);
|
|
2787
2870
|
for (const wt of listLinkedWorktreePaths(projectRoot)) {
|
|
2788
|
-
if (
|
|
2789
|
-
if (
|
|
2790
|
-
if (
|
|
2871
|
+
if (join6(wt) === rootResolved) continue;
|
|
2872
|
+
if (existsSync7(join6(wt, ".githooks", "_directive-run.sh"))) return true;
|
|
2873
|
+
if (existsSync7(join6(wt, ".deft", "GENERATION.json"))) return true;
|
|
2791
2874
|
}
|
|
2792
2875
|
return false;
|
|
2793
2876
|
}
|
|
@@ -2818,17 +2901,17 @@ function cleanupHooksPath(projectRoot) {
|
|
|
2818
2901
|
}
|
|
2819
2902
|
function verifyUninstallComplete(projectRoot) {
|
|
2820
2903
|
const leftovers = [];
|
|
2821
|
-
if (
|
|
2904
|
+
if (existsSync7(join6(projectRoot, ".deft", "GENERATION.json"))) {
|
|
2822
2905
|
leftovers.push(".deft/GENERATION.json");
|
|
2823
2906
|
}
|
|
2824
|
-
if (
|
|
2907
|
+
if (existsSync7(join6(projectRoot, ".deft", "core"))) {
|
|
2825
2908
|
leftovers.push(".deft/core");
|
|
2826
2909
|
}
|
|
2827
2910
|
for (const rel of GITHOOK_RELS) {
|
|
2828
|
-
const body = readText2(
|
|
2911
|
+
const body = readText2(join6(projectRoot, rel));
|
|
2829
2912
|
if (body !== null && isOurGitHook(rel, body)) leftovers.push(rel);
|
|
2830
2913
|
}
|
|
2831
|
-
const agents = readText2(
|
|
2914
|
+
const agents = readText2(join6(projectRoot, "AGENTS.md"));
|
|
2832
2915
|
if (agents !== null && agents.includes(MANAGED_OPEN)) {
|
|
2833
2916
|
leftovers.push("AGENTS.md#marked-section");
|
|
2834
2917
|
}
|
|
@@ -2958,7 +3041,7 @@ function resolveLineReader(deps) {
|
|
|
2958
3041
|
}
|
|
2959
3042
|
function shouldDefaultToRepair(projectRoot, state) {
|
|
2960
3043
|
if (state.installed === null) return true;
|
|
2961
|
-
return !
|
|
3044
|
+
return !existsSync8(join7(projectRoot, ".deft", "GENERATION.json"));
|
|
2962
3045
|
}
|
|
2963
3046
|
function printConfiguredMenu(io, opts) {
|
|
2964
3047
|
const repairMarker = opts.defaultChoice === "repair" ? ">" : " ";
|
|
@@ -3149,7 +3232,7 @@ function runFirstInstall(projectRoot, state, flags, launcherVersion, io, deps, e
|
|
|
3149
3232
|
}
|
|
3150
3233
|
targetVersion = resolved.version;
|
|
3151
3234
|
}
|
|
3152
|
-
const willCreatePkg = !
|
|
3235
|
+
const willCreatePkg = !existsSync8(join7(projectRoot, "package.json"));
|
|
3153
3236
|
const pmCmd = formatPmExactAddCommand(pmDetect.pm, targetVersion, projectRoot);
|
|
3154
3237
|
presentFirstInstallPlan(io, {
|
|
3155
3238
|
projectRoot,
|
|
@@ -3158,10 +3241,12 @@ function runFirstInstall(projectRoot, state, flags, launcherVersion, io, deps, e
|
|
|
3158
3241
|
version: targetVersion,
|
|
3159
3242
|
pmCommand: pmCmd,
|
|
3160
3243
|
willCreatePkg,
|
|
3161
|
-
gitHooksInactive: !
|
|
3244
|
+
gitHooksInactive: !existsSync8(join7(projectRoot, ".git")),
|
|
3162
3245
|
nodeWarning: checkNodeVersion(deps.nodeVersion).warning ?? null,
|
|
3163
3246
|
verbosity: flags.verbosity
|
|
3164
3247
|
});
|
|
3248
|
+
const ageExcludeHeal = pmDetect.pm === "pnpm" ? previewRuntimeAgeExcludeHeal(projectRoot, targetVersion) : null;
|
|
3249
|
+
if (ageExcludeHeal !== null) io.writeOut(formatAgeExcludeHealLine(ageExcludeHeal, targetVersion));
|
|
3165
3250
|
const planFp = fingerprintPlanCriticalFiles(projectRoot, pmDetect.pm);
|
|
3166
3251
|
if (flags.dryRun) {
|
|
3167
3252
|
io.writeOut("[dry-run] no changes made.\n");
|
|
@@ -3175,7 +3260,12 @@ function runFirstInstall(projectRoot, state, flags, launcherVersion, io, deps, e
|
|
|
3175
3260
|
ensurePackageJson(projectRoot);
|
|
3176
3261
|
io.writeOut('Created package.json { "private": true }\n');
|
|
3177
3262
|
}
|
|
3178
|
-
const add =
|
|
3263
|
+
const add = addWithRuntimeAgeExcludeHeal(
|
|
3264
|
+
projectRoot,
|
|
3265
|
+
pmDetect.pm,
|
|
3266
|
+
targetVersion,
|
|
3267
|
+
() => deps.runPmAdd?.({ projectRoot, pm: pmDetect.pm, version: targetVersion }) ?? runPmExactAdd({ projectRoot, pm: pmDetect.pm, version: targetVersion, env })
|
|
3268
|
+
);
|
|
3179
3269
|
if (!add.ok) {
|
|
3180
3270
|
return reportPmFailure(io, add);
|
|
3181
3271
|
}
|
|
@@ -3248,10 +3338,12 @@ function runRepair(projectRoot, state, flags, launcherVersion, io, deps, env) {
|
|
|
3248
3338
|
needsPmRestore,
|
|
3249
3339
|
pmCommand: needsPmRestore ? pmCmd : null,
|
|
3250
3340
|
restoreReason: needsPmRestore ? restoreReason : null,
|
|
3251
|
-
gitHooksInactive: !
|
|
3341
|
+
gitHooksInactive: !existsSync8(join7(projectRoot, ".git")),
|
|
3252
3342
|
nodeWarning: checkNodeVersion(deps.nodeVersion).warning ?? null,
|
|
3253
3343
|
verbosity: flags.verbosity
|
|
3254
3344
|
});
|
|
3345
|
+
const ageExcludeHeal = pmDetect.pm === "pnpm" ? previewRuntimeAgeExcludeHeal(projectRoot, pinVersion) : null;
|
|
3346
|
+
if (ageExcludeHeal !== null) io.writeOut(formatAgeExcludeHealLine(ageExcludeHeal, pinVersion));
|
|
3255
3347
|
const planFp = fingerprintPlanCriticalFiles(projectRoot, pmDetect.pm);
|
|
3256
3348
|
if (flags.dryRun) {
|
|
3257
3349
|
io.writeOut("[dry-run] no changes made.\n");
|
|
@@ -3266,8 +3358,14 @@ function runRepair(projectRoot, state, flags, launcherVersion, io, deps, env) {
|
|
|
3266
3358
|
if (approval !== null) return approval;
|
|
3267
3359
|
const stale = assertPlanStillValid(projectRoot, pmDetect.pm, planFp, io);
|
|
3268
3360
|
if (stale !== null) return stale;
|
|
3361
|
+
if (pmDetect.pm === "pnpm") healRuntimeAgeExclude(projectRoot, pinVersion);
|
|
3269
3362
|
if (needsPmRestore) {
|
|
3270
|
-
const add =
|
|
3363
|
+
const add = addWithRuntimeAgeExcludeHeal(
|
|
3364
|
+
projectRoot,
|
|
3365
|
+
pmDetect.pm,
|
|
3366
|
+
pinVersion,
|
|
3367
|
+
() => deps.runPmAdd?.({ projectRoot, pm: pmDetect.pm, version: pinVersion }) ?? runPmExactAdd({ projectRoot, pm: pmDetect.pm, version: pinVersion, env })
|
|
3368
|
+
);
|
|
3271
3369
|
if (!add.ok) {
|
|
3272
3370
|
return reportPmFailure(io, add);
|
|
3273
3371
|
}
|
|
@@ -3396,14 +3494,14 @@ function handOffMigrate(opts) {
|
|
|
3396
3494
|
}
|
|
3397
3495
|
function isWiringCurrentForVersion(projectRoot, version) {
|
|
3398
3496
|
try {
|
|
3399
|
-
const genPath =
|
|
3400
|
-
if (!
|
|
3401
|
-
const genRaw = JSON.parse(
|
|
3497
|
+
const genPath = join7(projectRoot, ".deft", "GENERATION.json");
|
|
3498
|
+
if (!existsSync8(genPath)) return false;
|
|
3499
|
+
const genRaw = JSON.parse(readFileSync6(genPath, "utf8"));
|
|
3402
3500
|
if (genRaw === null || typeof genRaw !== "object" || Array.isArray(genRaw)) return false;
|
|
3403
3501
|
if (genRaw.runtimeVersion !== version) return false;
|
|
3404
|
-
const ready =
|
|
3405
|
-
if (!
|
|
3406
|
-
const bodyRaw = JSON.parse(
|
|
3502
|
+
const ready = join7(projectRoot, ".deft", "directive", `wiring-ready.${version}.json`);
|
|
3503
|
+
if (!existsSync8(ready)) return false;
|
|
3504
|
+
const bodyRaw = JSON.parse(readFileSync6(ready, "utf8"));
|
|
3407
3505
|
if (bodyRaw === null || typeof bodyRaw !== "object" || Array.isArray(bodyRaw)) return false;
|
|
3408
3506
|
const bodyVersion = bodyRaw.runtimeVersion;
|
|
3409
3507
|
if (bodyVersion !== void 0 && bodyVersion !== version) return false;
|
|
@@ -3596,10 +3694,12 @@ function runUpgrade(projectRoot, state, argv, launcherVersion, io = defaultIo(),
|
|
|
3596
3694
|
needMigrate,
|
|
3597
3695
|
oldStyle: state.oldStyle,
|
|
3598
3696
|
convertShapeId: convertViaRemovals ? upgradeShape?.shapeId : null,
|
|
3599
|
-
gitHooksInactive: !
|
|
3697
|
+
gitHooksInactive: !existsSync8(join7(projectRoot, ".git")),
|
|
3600
3698
|
nodeWarning: checkNodeVersion(deps.nodeVersion).warning ?? null,
|
|
3601
3699
|
verbosity: flags.verbosity
|
|
3602
3700
|
});
|
|
3701
|
+
const ageExcludeHeal = pmDetect.pm === "pnpm" && versionChange ? previewRuntimeAgeExcludeHeal(projectRoot, targetVersion) : null;
|
|
3702
|
+
if (ageExcludeHeal !== null) io.writeOut(formatAgeExcludeHealLine(ageExcludeHeal, targetVersion));
|
|
3603
3703
|
const planFp = fingerprintPlanCriticalFiles(projectRoot, pmDetect.pm);
|
|
3604
3704
|
if (flags.dryRun) {
|
|
3605
3705
|
io.writeOut("[dry-run] no changes made.\n");
|
|
@@ -3616,7 +3716,7 @@ function runUpgrade(projectRoot, state, argv, launcherVersion, io = defaultIo(),
|
|
|
3616
3716
|
if (stale !== null) return stale;
|
|
3617
3717
|
if (versionChange) {
|
|
3618
3718
|
if (state.oldStyle || convertViaRemovals) {
|
|
3619
|
-
if (convertViaRemovals && !
|
|
3719
|
+
if (convertViaRemovals && !existsSync8(join7(projectRoot, "package.json"))) {
|
|
3620
3720
|
ensurePackageJson(projectRoot);
|
|
3621
3721
|
}
|
|
3622
3722
|
for (const packageName of RETIRED_DIRECTIVE_PACKAGE_NAMES) {
|
|
@@ -3634,10 +3734,15 @@ function runUpgrade(projectRoot, state, argv, launcherVersion, io = defaultIo(),
|
|
|
3634
3734
|
);
|
|
3635
3735
|
}
|
|
3636
3736
|
}
|
|
3637
|
-
if (convertViaRemovals && !
|
|
3737
|
+
if (convertViaRemovals && !existsSync8(join7(projectRoot, "package.json"))) {
|
|
3638
3738
|
ensurePackageJson(projectRoot);
|
|
3639
3739
|
}
|
|
3640
|
-
const add =
|
|
3740
|
+
const add = addWithRuntimeAgeExcludeHeal(
|
|
3741
|
+
projectRoot,
|
|
3742
|
+
pmDetect.pm,
|
|
3743
|
+
targetVersion,
|
|
3744
|
+
() => deps.runPmAdd?.({ projectRoot, pm: pmDetect.pm, version: targetVersion }) ?? runPmExactAdd({ projectRoot, pm: pmDetect.pm, version: targetVersion, env })
|
|
3745
|
+
);
|
|
3641
3746
|
if (!add.ok) {
|
|
3642
3747
|
return reportPmFailure(io, add);
|
|
3643
3748
|
}
|
|
@@ -3678,8 +3783,8 @@ function runUpgrade(projectRoot, state, argv, launcherVersion, io = defaultIo(),
|
|
|
3678
3783
|
return setupResult.exitCode;
|
|
3679
3784
|
}
|
|
3680
3785
|
if (convertViaRemovals) {
|
|
3681
|
-
const pkgPath =
|
|
3682
|
-
if (!
|
|
3786
|
+
const pkgPath = join7(projectRoot, "package.json");
|
|
3787
|
+
if (!existsSync8(pkgPath)) {
|
|
3683
3788
|
io.writeErr(
|
|
3684
3789
|
`Convert upgrade lost package.json after setup (shape ${upgradeShape?.shapeId}). Expected exact ${RUNTIME_PACKAGE_NAME}@${targetVersion}. Fix the cause, then run: directive upgrade --yes.
|
|
3685
3790
|
`
|
|
@@ -3796,10 +3901,10 @@ function runUninstall(projectRoot, state, argv, launcherVersion, io = defaultIo(
|
|
|
3796
3901
|
(a) => a.kind === "whole-file" ? a.path : a.kind === "marked-section" ? `${a.path} (marked section)` : `${a.path} (${a.entryKey ?? "structured entry"})`
|
|
3797
3902
|
);
|
|
3798
3903
|
const keepPaths = discovery.artifacts.filter((a) => a.kind === "retained").map((a) => a.path);
|
|
3799
|
-
if (!keepPaths.includes("xbrief") &&
|
|
3904
|
+
if (!keepPaths.includes("xbrief") && existsSync8(join7(projectRoot, "xbrief"))) {
|
|
3800
3905
|
keepPaths.push("xbrief");
|
|
3801
3906
|
}
|
|
3802
|
-
if (!keepPaths.includes(".deft/settings.json") &&
|
|
3907
|
+
if (!keepPaths.includes(".deft/settings.json") && existsSync8(join7(projectRoot, ".deft", "settings.json"))) {
|
|
3803
3908
|
keepPaths.push(".deft/settings.json");
|
|
3804
3909
|
}
|
|
3805
3910
|
keepPaths.push("user content in AGENTS.md / host configs", "global launcher");
|
|
@@ -4029,14 +4134,14 @@ Recovery: ${RECOVERY_GUIDANCE}
|
|
|
4029
4134
|
var runDoctorStub = runDoctor;
|
|
4030
4135
|
|
|
4031
4136
|
// packages/cli/src/version.ts
|
|
4032
|
-
import { readFileSync as
|
|
4033
|
-
import { dirname as dirname2, join as
|
|
4137
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
4138
|
+
import { dirname as dirname2, join as join8 } from "node:path";
|
|
4034
4139
|
import { fileURLToPath } from "node:url";
|
|
4035
4140
|
var FALLBACK = "0.0.0";
|
|
4036
4141
|
function readLauncherVersion() {
|
|
4037
4142
|
try {
|
|
4038
|
-
const pkgPath =
|
|
4039
|
-
const parsed = JSON.parse(
|
|
4143
|
+
const pkgPath = join8(dirname2(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
4144
|
+
const parsed = JSON.parse(readFileSync7(pkgPath, "utf8"));
|
|
4040
4145
|
if (parsed !== null && typeof parsed === "object") {
|
|
4041
4146
|
const version = parsed.version;
|
|
4042
4147
|
if (typeof version === "string" && version.length > 0) return version;
|
package/package.json
CHANGED