@deftai/directive 0.73.0 → 0.74.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.
@@ -15,6 +15,8 @@ export declare const CLI_MODULE_VERBS: readonly ["agents-refresh", "cache", "che
15
15
  export declare const CORE_MODULE_VERBS: readonly ["scm", "github-auth-modes", "github-body", "issue-emit", "issue-ingest", "reconcile-issues", "swarm-launch", "swarm-complete-cohort", "swarm-finalize-cohort", "swarm-readiness", "swarm-routing-verify", "swarm-routing-set", "swarm-verify-review-clean", "swarm-worktrees", "framework-commands", "pack-render", "packs-slice", "prd-render", "export-spec", "project-render", "roadmap-render", "spec-render", "spec-validate", "code-structure-validate", "pack-migrate-skills", "pack-migrate-rules", "pack-migrate-strategies", "pack-migrate-patterns", "pack-migrate-swarm-spec", "policy-set", "setup-ghx", "scope-undo", "scope-demote", "scope-decompose", "changelog-resolve-unreleased", "architecture-preflight-sor", "feedback-file", "value-readback"];
16
16
  /** Colon aliases for triage-actions (mirrors cli-router SUBCOMMAND_ROUTES). */
17
17
  export declare const TRIAGE_ACTION_ALIAS_SUBCOMMANDS: Readonly<Record<string, string>>;
18
+ /** Colon aliases for policy subcommands (mirrors cli-router SUBCOMMAND_ROUTES). */
19
+ export declare const POLICY_ACTION_ALIAS_SUBCOMMANDS: Readonly<Record<string, string>>;
18
20
  /** Task-style aliases (framework_commands / Taskfile names). */
19
21
  export declare const VERB_ALIASES: Readonly<Record<string, string>>;
20
22
  /** Pinned ghx version (display only) — keep in lockstep with .github/workflows/ci.yml env.GHX_VERSION. */
@@ -148,9 +150,21 @@ export declare function resolveCanonicalVerb(verb: string): string | null;
148
150
  /** Sorted list of all registered verb names (canonical + aliases). */
149
151
  export declare function registeredVerbs(): readonly string[];
150
152
  /**
151
- * Print dispatcher help. Leads with the three-command model (init / update /
152
- * doctor) + first-run guidance so a no-arg `directive` orients a newcomer before
153
- * the exhaustive verb list, which stays available below for power users (#2273).
153
+ * Deduplicated command names for `directive commands`, preferring colon-style
154
+ * task verbs over dash-style canonical stems when both exist (#2172).
155
+ */
156
+ export declare function preferredCommandNames(): readonly string[];
157
+ /** Major.minor label for the curated help title (#2172). */
158
+ export declare function helpVersionLabel(): string;
159
+ /**
160
+ * Print the exhaustive registered-command list for `directive commands` (#2172).
161
+ * Lists deduplicated preferred names (colon-style when available).
162
+ */
163
+ export declare function printCommandsList(io?: DispatchIo): void;
164
+ /**
165
+ * Print curated top-level help: title/version, usage, common options, grouped
166
+ * common commands, and a pointer to `directive commands` for the full list
167
+ * (#2172). Preserves the init/update/doctor first-run guidance from #2273.
154
168
  */
155
169
  export declare function printHelp(io?: DispatchIo): void;
156
170
  /** Dispatch argv to a registered verb; returns the handler exit code. */
package/dist/dispatch.js CHANGED
@@ -9,7 +9,7 @@ import { homedir, tmpdir } from "node:os";
9
9
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
10
10
  import { engineInfo, userConfig } from "@deftai/directive-core";
11
11
  import { parseInitArgv, runInitDepositCli } from "@deftai/directive-core/init-deposit";
12
- import { appendAuditLog, disclosureLine, migrateLegacyPolicyKey, PLAN_POLICY_KEY, projectDefinitionPath, resolvePolicy, resolveWipCap, setPolicy, } from "@deftai/directive-core/policy";
12
+ import { appendAuditLog, disclosureLine, migrateLegacyPolicyKey, PLAN_POLICY_KEY, policyColonInvocation, policySetInvocation, projectDefinitionPath, resolvePolicy, resolveWipCap, setPolicy, } from "@deftai/directive-core/policy";
13
13
  import { defaultWhich } from "@deftai/directive-core/scm";
14
14
  import { KNOWN_SUBAGENT_BACKEND_IDS, probeSubagentBackends, resolveSwarmSubagentBackend, } from "@deftai/directive-core/swarm";
15
15
  const HANDLER_KEYS = [
@@ -168,6 +168,14 @@ export const TRIAGE_ACTION_ALIAS_SUBCOMMANDS = {
168
168
  "triage:history": "history",
169
169
  };
170
170
  const TRIAGE_ACTION_COLON_ALIASES = Object.fromEntries(Object.keys(TRIAGE_ACTION_ALIAS_SUBCOMMANDS).map((alias) => [alias, "triage-actions"]));
171
+ /** Colon aliases for policy subcommands (mirrors cli-router SUBCOMMAND_ROUTES). */
172
+ export const POLICY_ACTION_ALIAS_SUBCOMMANDS = {
173
+ "policy:show": "show",
174
+ "policy:enforce-branches": "enforce-branches",
175
+ "policy:allow-direct-commits": "allow-direct-commits",
176
+ "policy:enable-value-feedback": "enable-value-feedback",
177
+ };
178
+ const POLICY_ACTION_COLON_ALIASES = Object.fromEntries(Object.keys(POLICY_ACTION_ALIAS_SUBCOMMANDS).map((alias) => [alias, "policy"]));
171
179
  /** Task-style aliases (framework_commands / Taskfile names). */
172
180
  export const VERB_ALIASES = {
173
181
  "verify:encoding": "verify-encoding",
@@ -211,6 +219,7 @@ export const VERB_ALIASES = {
211
219
  "triage:queue": "triage-queue",
212
220
  "triage:scope": "triage-scope",
213
221
  ...TRIAGE_ACTION_COLON_ALIASES,
222
+ ...POLICY_ACTION_COLON_ALIASES,
214
223
  "agents:refresh": "agents-refresh",
215
224
  "migrate:preflight": "migrate-preflight",
216
225
  "migrate:xbrief": "migrate-xbrief",
@@ -1747,7 +1756,9 @@ const POLICY_CAPABILITY_COST_DISCLOSURE = "\u26a0 Capability-cost disclosure --
1747
1756
  " \u2022 verify:branch will pass on the default branch.\n" +
1748
1757
  " \u2022 The CI sanity check (head_ref != base_ref) is still independent and " +
1749
1758
  "will continue to flag master->master PRs.\n" +
1750
- " \u2022 This change is reversible: run `task policy:enforce-branches` to " +
1759
+ " \u2022 This change is reversible: run `" +
1760
+ policyColonInvocation("enforce-branches") +
1761
+ "` to " +
1751
1762
  "re-enable the gate.\n" +
1752
1763
  " \u2022 The change is recorded to meta/policy-changes.log for auditability.";
1753
1764
  const POLICY_WIP_CAP_DISCLOSURE = "\u26a0 Capability-cost disclosure -- changing plan.policy.wipCap " +
@@ -1802,15 +1813,15 @@ function sanitizeNote(note) {
1802
1813
  function defaultPolicySetActor(cmd) {
1803
1814
  switch (cmd) {
1804
1815
  case "enforce-branches":
1805
- return "task policy:enforce-branches";
1816
+ return policyColonInvocation("enforce-branches");
1806
1817
  case "allow-direct-commits":
1807
- return "task policy:allow-direct-commits";
1818
+ return policyColonInvocation("allow-direct-commits");
1808
1819
  case "wip-cap":
1809
- return "task policy:wip-cap";
1820
+ return policySetInvocation("wip-cap");
1810
1821
  case "subagent-backend":
1811
- return "task policy:subagent-backend";
1822
+ return policySetInvocation("subagent-backend");
1812
1823
  case "subagent-backends":
1813
- return "task policy:subagent-backends";
1824
+ return policySetInvocation("subagent-backends");
1814
1825
  }
1815
1826
  }
1816
1827
  /** Mirror Python `Path(...).expanduser()` for a leading `~` / `~/` segment. */
@@ -2027,7 +2038,7 @@ function applyBranchPolicy(args, io) {
2027
2038
  if (!args.confirm) {
2028
2039
  io.writeOut(`${POLICY_CAPABILITY_COST_DISCLOSURE}\n`);
2029
2040
  io.writeOut("\n");
2030
- io.writeOut("Re-run with --confirm to apply: task policy:allow-direct-commits -- --confirm\n");
2041
+ io.writeOut(`Re-run with --confirm to apply: ${policyColonInvocation("allow-direct-commits", " -- --confirm")}\n`);
2031
2042
  return 1;
2032
2043
  }
2033
2044
  target = true;
@@ -2071,7 +2082,7 @@ function applyWipCap(args, io) {
2071
2082
  if (!args.confirm) {
2072
2083
  io.writeOut(`${POLICY_WIP_CAP_DISCLOSURE}\n`);
2073
2084
  io.writeOut("\n");
2074
- io.writeOut(`Re-run with --confirm to apply: task policy:wip-cap -- --set ${cap} --confirm\n`);
2085
+ io.writeOut(`Re-run with --confirm to apply: ${policySetInvocation("wip-cap", ` -- --set ${cap} --confirm`)}\n`);
2075
2086
  return 1;
2076
2087
  }
2077
2088
  let res;
@@ -2346,32 +2357,126 @@ export function registeredVerbs() {
2346
2357
  ]);
2347
2358
  return [...names].sort();
2348
2359
  }
2360
+ /** Top-level UX commands routed before the flat dispatcher (#1670). */
2361
+ const TOP_LEVEL_COMMAND_NAMES = [
2362
+ "init",
2363
+ "update",
2364
+ "migrate",
2365
+ "bootstrap",
2366
+ "doctor",
2367
+ "check",
2368
+ ];
2369
+ /** Scope lifecycle verbs exposed as scope:<verb> in help (#2172). */
2370
+ const SCOPE_COMMAND_NAMES = [
2371
+ "scope:promote",
2372
+ "scope:activate",
2373
+ "scope:complete",
2374
+ "scope:demote",
2375
+ "scope:undo",
2376
+ ];
2349
2377
  /**
2350
- * Print dispatcher help. Leads with the three-command model (init / update /
2351
- * doctor) + first-run guidance so a no-arg `directive` orients a newcomer before
2352
- * the exhaustive verb list, which stays available below for power users (#2273).
2378
+ * Deduplicated command names for `directive commands`, preferring colon-style
2379
+ * task verbs over dash-style canonical stems when both exist (#2172).
2380
+ */
2381
+ export function preferredCommandNames() {
2382
+ const aliasKeys = Object.keys(VERB_ALIASES);
2383
+ const aliasedCanonicals = new Set(Object.values(VERB_ALIASES));
2384
+ const unaliasedCanonicals = [...CLI_MODULE_VERBS, ...CORE_MODULE_VERBS].filter((verb) => !aliasedCanonicals.has(verb));
2385
+ return [
2386
+ ...new Set([
2387
+ ...TOP_LEVEL_COMMAND_NAMES,
2388
+ ...SCOPE_COMMAND_NAMES,
2389
+ ...aliasKeys,
2390
+ ...unaliasedCanonicals,
2391
+ ]),
2392
+ ].sort();
2393
+ }
2394
+ /** Major.minor label for the curated help title (#2172). */
2395
+ export function helpVersionLabel() {
2396
+ const version = engineInfo().version;
2397
+ const match = /^(\d+\.\d+)/.exec(version);
2398
+ return match ? `v${match[1]}` : `v${version}`;
2399
+ }
2400
+ const CURATED_HELP_GROUPS = [
2401
+ {
2402
+ title: "Getting started",
2403
+ commands: [
2404
+ { name: "init", summary: "Set up Directive in the current project (first-time setup)" },
2405
+ { name: "update", summary: "Refresh an existing install and self-heal the engine" },
2406
+ { name: "doctor", summary: "Diagnose the install and print the one next step" },
2407
+ ],
2408
+ },
2409
+ {
2410
+ title: "Session & ritual",
2411
+ commands: [{ name: "session:start", summary: "Record session-start ritual state" }],
2412
+ },
2413
+ {
2414
+ title: "Quality & gates",
2415
+ commands: [{ name: "check", summary: "Run install and lifecycle quality gates" }],
2416
+ },
2417
+ {
2418
+ title: "Work queue & triage",
2419
+ commands: [
2420
+ { name: "triage:welcome", summary: "Session orientation and triage one-liner" },
2421
+ { name: "triage:queue", summary: "Ranked work queue for what to do next" },
2422
+ ],
2423
+ },
2424
+ {
2425
+ title: "Scope lifecycle",
2426
+ commands: [{ name: "scope:promote", summary: "Promote a scope xBRIEF to pending" }],
2427
+ },
2428
+ {
2429
+ title: "Project artifacts",
2430
+ commands: [
2431
+ { name: "project:render", summary: "Render PROJECT-DEFINITION projection" },
2432
+ { name: "spec:render", summary: "Render specification projection" },
2433
+ ],
2434
+ },
2435
+ ];
2436
+ function formatHelpCommand(command) {
2437
+ const padding = " ".repeat(Math.max(1, 22 - command.name.length));
2438
+ return ` ${command.name}${padding}${command.summary}\n`;
2439
+ }
2440
+ /**
2441
+ * Print the exhaustive registered-command list for `directive commands` (#2172).
2442
+ * Lists deduplicated preferred names (colon-style when available).
2443
+ */
2444
+ export function printCommandsList(io = defaultIo()) {
2445
+ io.writeOut("Registered commands:\n");
2446
+ for (const name of preferredCommandNames()) {
2447
+ io.writeOut(` ${name}\n`);
2448
+ }
2449
+ }
2450
+ /**
2451
+ * Print curated top-level help: title/version, usage, common options, grouped
2452
+ * common commands, and a pointer to `directive commands` for the full list
2453
+ * (#2172). Preserves the init/update/doctor first-run guidance from #2273.
2353
2454
  */
2354
2455
  export function printHelp(io = defaultIo()) {
2355
- io.writeOut("directive -- the Deft Directive CLI\n" +
2356
- "\n" +
2357
- "Start here (most projects only need these three):\n" +
2358
- " directive init Set up Directive in the current project (first-time setup)\n" +
2359
- " directive update Refresh an existing install and self-heal the engine\n" +
2360
- " directive doctor Diagnose the install and print the one next step\n" +
2361
- "\n" +
2456
+ io.writeOut(`Directive ${helpVersionLabel()}\n`);
2457
+ io.writeOut("AI development framework CLI for project lifecycle, scope, and quality gates.\n\n");
2458
+ io.writeOut("Usage:\n");
2459
+ io.writeOut(" directive <command> [options]\n");
2460
+ io.writeOut(" directive help\n");
2461
+ io.writeOut(" directive commands List every registered command\n\n");
2462
+ io.writeOut("Options:\n");
2463
+ io.writeOut(" -h, --help Show this help\n");
2464
+ io.writeOut(" -V, --version Print version information\n\n");
2465
+ for (const group of CURATED_HELP_GROUPS) {
2466
+ io.writeOut(`${group.title}:\n`);
2467
+ for (const command of group.commands) {
2468
+ io.writeOut(formatHelpCommand(command));
2469
+ }
2470
+ io.writeOut("\n");
2471
+ }
2472
+ io.writeOut("Commands use colon style (e.g. triage:queue); dash-style aliases remain supported.\n" +
2473
+ "Run `directive commands` for the full registered-command list.\n\n" +
2362
2474
  "First run? From the project root:\n" +
2363
2475
  " 1. npm i -g @deftai/directive (Node >= 20)\n" +
2364
2476
  " (pnpm: pnpm add -g @deftai/directive -- ensure PNPM_HOME is on PATH, run `pnpm setup` if needed)\n" +
2365
2477
  " 2. directive init\n" +
2366
2478
  " 3. directive doctor\n" +
2367
- "New clone where `directive` will not run? Read the Cold-start bootstrap block at the top of README.md.\n" +
2368
- "\n" +
2369
- "Usage: directive <verb> [args...]\n" +
2370
- "\n" +
2371
- "Registered verbs:\n");
2372
- for (const name of registeredVerbs()) {
2373
- io.writeOut(` ${name}\n`);
2374
- }
2479
+ "New clone where `directive` will not run? Read the Cold-start bootstrap block at the top of README.md.\n");
2375
2480
  }
2376
2481
  async function invokeHandler(handler, argv) {
2377
2482
  const code = await handler(argv);
@@ -2393,6 +2498,10 @@ export async function dispatch(argv, io = defaultIo()) {
2393
2498
  return 0;
2394
2499
  }
2395
2500
  const [verb, ...rest] = argv;
2501
+ if (verb === "commands") {
2502
+ printCommandsList(io);
2503
+ return 0;
2504
+ }
2396
2505
  const canonical = resolveCanonicalVerb(verb ?? "");
2397
2506
  if (canonical === null) {
2398
2507
  io.writeErr(`directive: unknown verb '${verb}'\n`);
@@ -2401,11 +2510,14 @@ export async function dispatch(argv, io = defaultIo()) {
2401
2510
  try {
2402
2511
  const handler = await loadHandler(canonical, io);
2403
2512
  const triageSubcommand = verb !== undefined ? TRIAGE_ACTION_ALIAS_SUBCOMMANDS[verb] : undefined;
2513
+ const policySubcommand = verb !== undefined ? POLICY_ACTION_ALIAS_SUBCOMMANDS[verb] : undefined;
2404
2514
  const handlerArgv = canonical === "framework-commands" && verb !== undefined && verb !== canonical
2405
2515
  ? [verb, ...rest]
2406
2516
  : triageSubcommand !== undefined && canonical === "triage-actions"
2407
2517
  ? [triageSubcommand, ...rest]
2408
- : rest;
2518
+ : policySubcommand !== undefined && canonical === "policy"
2519
+ ? [policySubcommand, ...rest]
2520
+ : rest;
2409
2521
  return await invokeHandler(handler, handlerArgv);
2410
2522
  }
2411
2523
  catch (err) {
package/dist/policy.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import { existsSync } from "node:fs";
7
7
  import { resolve as pathResolve, relative } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
- import { describeShadowedPlanExtension, detectShadowedPlanExtensions, disclosureLine, enableValueFeedback, FIELD_VALUE_FEEDBACK, FIELD_VALUE_FEEDBACK_CLI_ALIAS, formatValueFeedbackStatusLine, inspectAllPolicies, inspectOnePolicy, loadProjectDefinition, projectDefinitionPath, pythonListRepr, pythonStringRepr, registeredPolicyNames, renderJson, renderText, resolvePolicy, resolveValueFeedback, setPolicy, } from "@deftai/directive-core/policy";
9
+ import { describeShadowedPlanExtension, detectShadowedPlanExtensions, disclosureLine, enableValueFeedback, FIELD_VALUE_FEEDBACK, FIELD_VALUE_FEEDBACK_CLI_ALIAS, formatValueFeedbackStatusLine, inspectAllPolicies, inspectOnePolicy, loadProjectDefinition, policyColonInvocation, projectDefinitionPath, pythonListRepr, pythonStringRepr, registeredPolicyNames, renderJson, renderText, resolvePolicy, resolveValueFeedback, setPolicy, } from "@deftai/directive-core/policy";
10
10
  const CAPABILITY_COST_DISCLOSURE = "\u26a0 Capability-cost disclosure -- enabling direct commits to the default " +
11
11
  "branch turns OFF the deft branch-protection policy.\n" +
12
12
  " \u2022 Pre-commit + pre-push hooks will no longer block default-branch " +
@@ -14,7 +14,9 @@ const CAPABILITY_COST_DISCLOSURE = "\u26a0 Capability-cost disclosure -- enablin
14
14
  " \u2022 verify:branch will pass on the default branch.\n" +
15
15
  " \u2022 The CI sanity check (head_ref != base_ref) is still independent and " +
16
16
  "will continue to flag master->master PRs.\n" +
17
- " \u2022 This change is reversible: run `task policy:enforce-branches` to " +
17
+ " \u2022 This change is reversible: run `" +
18
+ policyColonInvocation("enforce-branches") +
19
+ "` to " +
18
20
  "re-enable the gate.\n" +
19
21
  " \u2022 The change is recorded to meta/policy-changes.log for auditability.";
20
22
  function makeSetError(message) {
@@ -121,7 +123,7 @@ export function parseArgs(argv) {
121
123
  return {
122
124
  cmd: "show",
123
125
  confirm: false,
124
- actor: "task policy:show",
126
+ actor: policyColonInvocation("show"),
125
127
  note: "",
126
128
  projectRoot: show.projectRoot,
127
129
  format: show.format,
@@ -149,10 +151,10 @@ export function parseArgs(argv) {
149
151
  cmd === "enable-value-feedback") {
150
152
  let confirm = false;
151
153
  let actor = cmd === "enforce-branches"
152
- ? "task policy:enforce-branches"
154
+ ? policyColonInvocation("enforce-branches")
153
155
  : cmd === "allow-direct-commits"
154
- ? "task policy:allow-direct-commits"
155
- : "task policy:enable-value-feedback";
156
+ ? policyColonInvocation("allow-direct-commits")
157
+ : policyColonInvocation("enable-value-feedback");
156
158
  let note = "";
157
159
  let projectRoot = ".";
158
160
  for (let i = 1; i < argv.length; i += 1) {
@@ -291,7 +293,7 @@ function runSet(args) {
291
293
  const projectRoot = pathResolve(args.projectRoot);
292
294
  if (args.cmd === "allow-direct-commits" && !args.confirm) {
293
295
  process.stdout.write(`${CAPABILITY_COST_DISCLOSURE}\n\n`);
294
- process.stdout.write("Re-run with --confirm to apply: task policy:allow-direct-commits -- --confirm\n");
296
+ process.stdout.write(`Re-run with --confirm to apply: ${policyColonInvocation("allow-direct-commits", " -- --confirm")}\n`);
295
297
  return 1;
296
298
  }
297
299
  const target = args.cmd === "allow-direct-commits";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive",
3
- "version": "0.73.0",
3
+ "version": "0.74.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.73.0",
35
- "@deftai/directive-content": "^0.73.0"
34
+ "@deftai/directive-core": "^0.74.0",
35
+ "@deftai/directive-content": "^0.74.0"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsc -b"