@deksden-com/dd-flow-cli 0.6.0 → 0.7.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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -1
  3. package/dist/build-info.json +5 -5
  4. package/dist/cli/help.js +20 -8
  5. package/dist/cli/run-cli.js +104 -24
  6. package/dist/domain/flow-contract.js +11 -0
  7. package/dist/runtime/context.js +8 -2
  8. package/dist/schemas/code-stage-report.schema.json +7 -2
  9. package/dist/schemas/engine-manifest.schema.json +22 -0
  10. package/dist/schemas/flow-run.schema.json +1 -0
  11. package/dist/schemas/mb-upgrade-migration-report.schema.json +3 -1
  12. package/dist/schemas/merge-stage-report-legacy-0.4.2.schema.json +24 -0
  13. package/dist/schemas/run-engine-binding.schema.json +37 -0
  14. package/dist/schemas/stage-prompt.schema.json +4 -4
  15. package/dist/services/canon.js +15 -1
  16. package/dist/services/cli-operation-classifier.js +52 -8
  17. package/dist/services/compatibility-preflight.js +1 -1
  18. package/dist/services/dashboard.js +2 -2
  19. package/dist/services/engines.js +408 -30
  20. package/dist/services/hooks.js +1 -5
  21. package/dist/services/lanes.js +0 -4
  22. package/dist/services/merge-queue.js +48 -0
  23. package/dist/services/merge-worker.js +3 -4
  24. package/dist/services/migrations.js +307 -44
  25. package/dist/services/plan-runtime.js +4 -4
  26. package/dist/services/plans.js +5 -3
  27. package/dist/services/protocols.js +23 -2
  28. package/dist/services/run-engine-bindings.js +157 -0
  29. package/dist/services/runs.js +21 -7
  30. package/dist/services/schema-validation.js +96 -0
  31. package/dist/services/stage-lifecycle.js +98 -10
  32. package/dist/services/status.js +8 -3
  33. package/dist/storage/database.js +32 -11
  34. package/package.json +1 -1
@@ -34,21 +34,63 @@ export function isReadOnlyCliOperation(args, env = process.env) {
34
34
  export function isMbUpgradeCliOperation(args, env = process.env) {
35
35
  return classifyCliOperation(args, env).mode === "mb_upgrade";
36
36
  }
37
- function isMbUpgradeMode(args, env) {
38
- if (env.DD_FLOW_COMPATIBILITY_MODE === "mb-upgrade" || env.DD_FLOW_MB_UPGRADE_MODE === "1") {
37
+ export function requiresExplicitUpgradeAuthorization(args) {
38
+ const positional = positionalArgs(args);
39
+ const [family, command] = positional;
40
+ if (family === "migration" && command === "apply")
39
41
  return true;
40
- }
42
+ if (family === "run" && command === "start" && optionValue(args, "flow-kind") === "mb-upgrade")
43
+ return true;
44
+ return false;
45
+ }
46
+ function isMbUpgradeMode(args, env) {
47
+ const marked = env.DD_FLOW_COMPATIBILITY_MODE === "mb-upgrade" || env.DD_FLOW_MB_UPGRADE_MODE === "1";
41
48
  for (let index = 0; index < args.length; index += 1) {
42
49
  const arg = args[index];
43
50
  if (arg === "--compatibility-mode" && args[index + 1] === "mb-upgrade")
44
- return true;
51
+ return isUpgradeAllowlisted(args);
45
52
  if (arg === "--mb-upgrade-mode")
46
- return true;
47
- if (arg?.startsWith("--compatibility-mode="))
48
- return arg.slice("--compatibility-mode=".length) === "mb-upgrade";
53
+ return isUpgradeAllowlisted(args);
54
+ if (arg?.startsWith("--compatibility-mode=") && arg.slice("--compatibility-mode=".length) === "mb-upgrade") {
55
+ return isUpgradeAllowlisted(args);
56
+ }
49
57
  }
58
+ return marked && isUpgradeAllowlisted(args);
59
+ }
60
+ function isUpgradeAllowlisted(args) {
61
+ const positional = positionalArgs(args);
62
+ const [family, command] = positional;
63
+ if (family === "status")
64
+ return true;
65
+ if (family === "engine" && command === "resolve")
66
+ return true;
67
+ if (family === "migration" && ["impact", "plan", "report", "verify", "apply"].includes(command ?? ""))
68
+ return true;
69
+ if (family === "memory" && command === "permissions" && positional[2] === "preflight")
70
+ return true;
71
+ if (family === "run" && command === "start")
72
+ return optionValue(args, "flow-kind") === "mb-upgrade";
73
+ if (family === "stage" && ["start", "finish"].includes(command ?? ""))
74
+ return hasRunBinding(args);
75
+ if (family === "session" && ["status", "register", "stop", "usage"].includes(command ?? ""))
76
+ return hasRunBinding(args);
77
+ if (family === "dashboard" && ["data", "render", "refresh", "open"].includes(command ?? ""))
78
+ return true;
50
79
  return false;
51
80
  }
81
+ function hasRunBinding(args) {
82
+ return Boolean(optionValue(args, "run") || positionalArgs(args).some((value) => value.startsWith("RUN-")));
83
+ }
84
+ function optionValue(args, name) {
85
+ for (let index = args.length - 1; index >= 0; index -= 1) {
86
+ const arg = args[index];
87
+ if (arg === `--${name}`)
88
+ return args[index + 1] ?? null;
89
+ if (arg?.startsWith(`--${name}=`))
90
+ return arg.slice(name.length + 3);
91
+ }
92
+ return null;
93
+ }
52
94
  function isRouterNative(args) {
53
95
  const first = args[0];
54
96
  if (!first || first === "--version")
@@ -57,7 +99,9 @@ function isRouterNative(args) {
57
99
  return true;
58
100
  if (args.includes("--help") || args.includes("-h"))
59
101
  return true;
60
- return ["engine", "version", "schema"].includes(first);
102
+ if (["engine", "version", "schema"].includes(first))
103
+ return true;
104
+ return first === "codex" && args[1] === "hook" && args[2] === "handle";
61
105
  }
62
106
  function isReadOnlyDiagnostic(family, command, action) {
63
107
  if (!family)
@@ -11,7 +11,7 @@ export function preflightCliCompatibility(context, args, env = process.env, reso
11
11
  if (!projectRoot) {
12
12
  return { ok: true, classification, compatibility: null };
13
13
  }
14
- const selection = selectEngine(context, { projectRoot });
14
+ const selection = selectEngine(context, { projectRoot, env }, { allowCurrentInProcess: true }, classification);
15
15
  const compatibility = compatibilityReport(selection, classification);
16
16
  if (classification.mode === "read_only_diagnostics" || classification.mode === "mb_upgrade") {
17
17
  return { ok: true, classification, compatibility };
@@ -893,7 +893,7 @@ function planSummaryForProtocol(context, projectId, protocolId) {
893
893
  return { plan_id: "none", total: 0, done: 0, blocked: 0 };
894
894
  }
895
895
  try {
896
- const summary = planSummary(context, { projectId, protocolId, planPath: protocol.plan_path });
896
+ const summary = planSummary(context, { projectId, protocolId, planPath: protocol.plan_path }, { bind: false });
897
897
  return { plan_id: summary.plan_id, total: summary.total, done: summary.done, blocked: summary.blocked };
898
898
  }
899
899
  catch {
@@ -909,7 +909,7 @@ function activePlanItems(context, projectId, protocols) {
909
909
  }
910
910
  let plan;
911
911
  try {
912
- plan = planWithProgress(context, { projectId, protocolId: protocol.id, planPath: record.plan_path }).plan;
912
+ plan = planWithProgress(context, { projectId, protocolId: protocol.id, planPath: record.plan_path }, { bind: false }).plan;
913
913
  }
914
914
  catch {
915
915
  continue;