@deftai/directive 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.
@@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { evaluate, gitPorcelain, parseAllocationSection } from "@deftai/directive-core/story-ready";
6
+ import { ROUTING_GATED_DISPATCH_PROVIDERS, resolveDispatchProvider, verifyRouting, } from "@deftai/directive-core/swarm";
6
7
  /** Parse verify-story-ready CLI args, mirroring the Python argparse surface. */
7
8
  export function parseArgs(argv) {
8
9
  const parsed = {
@@ -11,6 +12,8 @@ export function parseArgs(argv) {
11
12
  allocationContext: null,
12
13
  allowDirty: false,
13
14
  emitJson: false,
15
+ skipRouting: false,
16
+ roles: [],
14
17
  };
15
18
  for (let i = 0; i < argv.length; i += 1) {
16
19
  const arg = argv[i];
@@ -53,6 +56,28 @@ export function parseArgs(argv) {
53
56
  else if (arg?.startsWith("--allocation-context=")) {
54
57
  parsed.allocationContext = arg.slice("--allocation-context=".length);
55
58
  }
59
+ else if (arg === "--skip-routing") {
60
+ parsed.skipRouting = true;
61
+ }
62
+ else if (arg === "--roles") {
63
+ const value = argv[i + 1];
64
+ if (value === undefined) {
65
+ return { ...parsed, error: "argument --roles: expected one argument" };
66
+ }
67
+ for (const role of value.split(",")) {
68
+ if (role.trim().length > 0) {
69
+ parsed.roles.push(role.trim());
70
+ }
71
+ }
72
+ i += 1;
73
+ }
74
+ else if (arg?.startsWith("--roles=")) {
75
+ for (const role of arg.slice("--roles=".length).split(",")) {
76
+ if (role.trim().length > 0) {
77
+ parsed.roles.push(role.trim());
78
+ }
79
+ }
80
+ }
56
81
  else if (arg === "--help" || arg === "-h") {
57
82
  return { ...parsed, help: true };
58
83
  }
@@ -67,8 +92,11 @@ export function parseArgs(argv) {
67
92
  }
68
93
  const HELP_TEXT = `usage: verify-story-ready [--vbrief-path PATH] [--project-root PATH]
69
94
  [--allocation-context PATH] [--allow-dirty] [--json]
95
+ [--skip-routing] [--roles ROLE[,ROLE...]]
70
96
 
71
- Deterministic story-start Gate 0 (#1378). Three-state exit: 0 ready / 1 not ready / 2 config error.
97
+ Deterministic story-start Gate 0 (#1378). When the active dispatch provider is
98
+ cursor or grok, chains verify:routing (#1877 single-dispatch enforcement).
99
+ Three-state exit: 0 ready / 1 not ready / 2 config error.
72
100
  `;
73
101
  function emitJson(vbriefPath, exitCode, message, dispatchKind) {
74
102
  const payload = {
@@ -121,6 +149,25 @@ export function run(argv) {
121
149
  allowDirty: args.allowDirty,
122
150
  parsed,
123
151
  });
152
+ if (result.exitCode === 0 && !args.skipRouting) {
153
+ const provider = resolveDispatchProvider(process.env);
154
+ if (ROUTING_GATED_DISPATCH_PROVIDERS.has(provider)) {
155
+ const routingResult = verifyRouting({
156
+ projectRoot,
157
+ environ: process.env,
158
+ roles: args.roles.length > 0 ? args.roles : undefined,
159
+ });
160
+ if (routingResult.exitCode !== 0) {
161
+ if (args.emitJson) {
162
+ process.stdout.write(`${emitJson(vbriefPath, routingResult.exitCode, routingResult.report, result.dispatchKind)}\n`);
163
+ }
164
+ else {
165
+ process.stderr.write(`${routingResult.report}\n`);
166
+ }
167
+ return routingResult.exitCode;
168
+ }
169
+ }
170
+ }
124
171
  if (args.emitJson) {
125
172
  process.stdout.write(`${emitJson(vbriefPath, result.exitCode, result.message, result.dispatchKind)}\n`);
126
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive",
3
- "version": "0.66.2",
3
+ "version": "0.68.0",
4
4
  "description": "Directive CLI — npm install path for the Deft Directive framework.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,8 +31,8 @@
31
31
  "provenance": true
32
32
  },
33
33
  "dependencies": {
34
- "@deftai/directive-core": "^0.66.2",
35
- "@deftai/directive-content": "^0.66.2"
34
+ "@deftai/directive-core": "^0.68.0",
35
+ "@deftai/directive-content": "^0.68.0"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsc -b"