@deftai/directive 0.79.1 → 0.79.3
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/cli-router/route-argv.js +40 -6
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +18 -1
- package/dist/lifecycle-event.d.ts +11 -0
- package/dist/lifecycle-event.js +45 -0
- package/dist/review-monitor-register.d.ts +17 -0
- package/dist/review-monitor-register.js +166 -0
- package/dist/verify-review-monitor.d.ts +18 -0
- package/dist/verify-review-monitor.js +156 -0
- package/package.json +3 -3
|
@@ -129,6 +129,14 @@ function routeNamespaceVerb(ns, verb, rest) {
|
|
|
129
129
|
const subcommand = routeSubcommandKey(ns, verb, rest);
|
|
130
130
|
if (subcommand !== null)
|
|
131
131
|
return subcommand;
|
|
132
|
+
// PR stems (watch → pr-watch) must win over colon aliases like pr:watch (#2652),
|
|
133
|
+
// otherwise `directive pr watch` would dispatch the colon token and break PR_VERB_MAP.
|
|
134
|
+
if (ns === "pr") {
|
|
135
|
+
const prStem = PR_VERB_MAP[verb];
|
|
136
|
+
if (prStem !== undefined) {
|
|
137
|
+
return { kind: "dispatch", argv: [prStem, ...rest] };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
132
140
|
if (resolveCanonicalVerb(colonKey) !== null) {
|
|
133
141
|
return { kind: "dispatch", argv: [colonKey, ...rest] };
|
|
134
142
|
}
|
|
@@ -149,12 +157,6 @@ function routeNamespaceVerb(ns, verb, rest) {
|
|
|
149
157
|
if (verb === "undo")
|
|
150
158
|
return { kind: "dispatch", argv: ["scope-undo", ...rest] };
|
|
151
159
|
}
|
|
152
|
-
if (ns === "pr") {
|
|
153
|
-
const prStem = PR_VERB_MAP[verb];
|
|
154
|
-
if (prStem !== undefined) {
|
|
155
|
-
return { kind: "dispatch", argv: [prStem, ...rest] };
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
160
|
if (ns === "verify") {
|
|
159
161
|
const verifyStem = VERIFY_VERB_MAP[verb];
|
|
160
162
|
if (verifyStem !== undefined) {
|
|
@@ -179,6 +181,32 @@ function routeNamespaceVerb(ns, verb, rest) {
|
|
|
179
181
|
}
|
|
180
182
|
return null;
|
|
181
183
|
}
|
|
184
|
+
/** Split `namespace:verb` task keys (e.g. scope:promote) for namespace routing (#2654). */
|
|
185
|
+
function tryColonNamespaceRoute(first, rest) {
|
|
186
|
+
// Registered colon aliases (policy:show, pr:watch, …) stay on the flat path.
|
|
187
|
+
if (resolveCanonicalVerb(first) !== null)
|
|
188
|
+
return null;
|
|
189
|
+
const colon = first.indexOf(":");
|
|
190
|
+
if (colon <= 0)
|
|
191
|
+
return null;
|
|
192
|
+
const ns = first.slice(0, colon);
|
|
193
|
+
const verb = first.slice(colon + 1);
|
|
194
|
+
if (verb.length === 0)
|
|
195
|
+
return null;
|
|
196
|
+
return routeNamespaceVerb(ns, verb, [...rest]);
|
|
197
|
+
}
|
|
198
|
+
/** Split `scope-<verb>` dash aliases (e.g. scope-promote) for namespace routing (#2654). */
|
|
199
|
+
function tryScopeDashRoute(first, rest) {
|
|
200
|
+
if (resolveCanonicalVerb(first) !== null)
|
|
201
|
+
return null;
|
|
202
|
+
const prefix = "scope-";
|
|
203
|
+
if (!first.startsWith(prefix))
|
|
204
|
+
return null;
|
|
205
|
+
const verb = first.slice(prefix.length);
|
|
206
|
+
if (verb.length === 0)
|
|
207
|
+
return null;
|
|
208
|
+
return routeNamespaceVerb("scope", verb, [...rest]);
|
|
209
|
+
}
|
|
182
210
|
function routeThreeToken(ns, verb, subverb, rest) {
|
|
183
211
|
if (ns === "scm" && verb === "issue") {
|
|
184
212
|
return { kind: "dispatch", argv: ["scm", "issue", subverb, ...rest] };
|
|
@@ -214,6 +242,12 @@ export function routeArgv(argv) {
|
|
|
214
242
|
const topLevel = routeTopLevel(first, argv.slice(1));
|
|
215
243
|
if (topLevel !== null)
|
|
216
244
|
return topLevel;
|
|
245
|
+
const colonRoute = tryColonNamespaceRoute(first, argv.slice(1));
|
|
246
|
+
if (colonRoute !== null)
|
|
247
|
+
return colonRoute;
|
|
248
|
+
const scopeDashRoute = tryScopeDashRoute(first, argv.slice(1));
|
|
249
|
+
if (scopeDashRoute !== null)
|
|
250
|
+
return scopeDashRoute;
|
|
217
251
|
if (argv.length === 1 && resolveCanonicalVerb(first) !== null) {
|
|
218
252
|
return { kind: "dispatch", argv: [first] };
|
|
219
253
|
}
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface DispatchIo {
|
|
|
10
10
|
writeErr: (text: string) => void;
|
|
11
11
|
}
|
|
12
12
|
/** CLI modules in packages/cli/src (excluding parity harnesses and bin/index). */
|
|
13
|
-
export declare const CLI_MODULE_VERBS: readonly ["agents-refresh", "cache", "check", "capacity-backfill", "capacity-show", "codebase-default-extractor", "codebase-map", "codebase-map-fresh", "codebase-projection-registry", "codebase-provider", "doctor", "install-upgrade", "install-uninstall", "migrate-preflight", "migrate-xbrief", "migrate-category-b", "framework-check-updates", "hook-dispatch", "umbrella-current-shape", "changelog-check", "change-init", "commit-lint", "policy", "pr-closing-keywords", "pr-merge-readiness", "pr-monitor", "pr-protected-issues", "pr-wait-mergeable", "pr-watch", "preflight-cache", "preflight-gh", "probe-session", "release", "release-e2e", "release-publish", "release-rollback", "scope-lifecycle", "session-start", "plan-sequence", "slice", "subagent-monitor", "toolchain-check", "triage-actions", "triage-bootstrap", "triage-bulk", "triage-classify", "triage-help", "triage-queue", "triage-reconcile", "triage-refresh", "triage-scope", "triage-scope-drift", "triage-smoketest", "triage-subscribe", "triage-summary", "triage-welcome", "ts-check-lane", "vbrief-activate", "vbrief-build", "vbrief-preflight", "vbrief-reconcile", "vbrief-validate", "vbrief-validation", "verify-branch", "verify-encoding", "verify-forward-coverage", "verify-hooks-installed", "verify-investigation", "verify-judgment-gates", "verify-no-task-runtime", "validate-links", "validate-strategy-output", "verify-biome-config", "verify-bridge-drift", "verify-capacity", "verify-content-manifest", "verify-contract-drift", "verify-cursor-tier1", "verify-go-freeze", "verify-scm-boundary", "verify-session-ritual", "verify-plan-sequence", "verify-stubs", "verify-xbrief-drift", "rule-ownership-lint", "verify-story-ready", "verify-tools", "verify-wip-cap", "verify-agents-md-budget", "verify-agents-md-advisory", "verify-eval-health-relocation", "verify-eval-triggers-relocation", "eval-health", "eval-run", "eval-report", "eval-triggers"];
|
|
13
|
+
export declare const CLI_MODULE_VERBS: readonly ["agents-refresh", "cache", "check", "capacity-backfill", "capacity-show", "codebase-default-extractor", "codebase-map", "codebase-map-fresh", "codebase-projection-registry", "codebase-provider", "doctor", "install-upgrade", "install-uninstall", "migrate-preflight", "migrate-xbrief", "migrate-category-b", "framework-check-updates", "hook-dispatch", "umbrella-current-shape", "changelog-check", "change-init", "commit-lint", "policy", "pr-closing-keywords", "pr-merge-readiness", "pr-monitor", "pr-protected-issues", "pr-wait-mergeable", "pr-watch", "preflight-cache", "preflight-gh", "probe-session", "release", "release-e2e", "release-publish", "release-rollback", "scope-lifecycle", "lifecycle-event", "session-start", "plan-sequence", "slice", "subagent-monitor", "toolchain-check", "triage-actions", "triage-bootstrap", "triage-bulk", "triage-classify", "triage-help", "triage-queue", "triage-reconcile", "triage-refresh", "triage-scope", "triage-scope-drift", "triage-smoketest", "triage-subscribe", "triage-summary", "triage-welcome", "ts-check-lane", "vbrief-activate", "vbrief-build", "vbrief-preflight", "vbrief-reconcile", "vbrief-validate", "vbrief-validation", "verify-branch", "verify-encoding", "verify-forward-coverage", "verify-hooks-installed", "verify-investigation", "verify-judgment-gates", "verify-no-task-runtime", "validate-links", "validate-strategy-output", "verify-biome-config", "verify-bridge-drift", "verify-capacity", "verify-content-manifest", "verify-contract-drift", "verify-cursor-tier1", "verify-go-freeze", "verify-scm-boundary", "verify-session-ritual", "verify-plan-sequence", "verify-stubs", "verify-xbrief-drift", "rule-ownership-lint", "verify-story-ready", "verify-review-monitor", "review-monitor-register", "verify-tools", "verify-wip-cap", "verify-agents-md-budget", "verify-agents-md-advisory", "verify-eval-health-relocation", "verify-eval-triggers-relocation", "eval-health", "eval-run", "eval-report", "eval-triggers"];
|
|
14
14
|
/** Core-only CLI entrypoints without a packages/cli wrapper. */
|
|
15
15
|
export declare const CORE_MODULE_VERBS: readonly ["scm", "github-auth-modes", "github-body", "issue-emit", "issue-ingest", "issue-sync-from-xbrief", "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). */
|
package/dist/dispatch.js
CHANGED
|
@@ -61,6 +61,7 @@ export const CLI_MODULE_VERBS = [
|
|
|
61
61
|
"release-publish",
|
|
62
62
|
"release-rollback",
|
|
63
63
|
"scope-lifecycle",
|
|
64
|
+
"lifecycle-event",
|
|
64
65
|
"session-start",
|
|
65
66
|
"plan-sequence",
|
|
66
67
|
"slice",
|
|
@@ -110,6 +111,8 @@ export const CLI_MODULE_VERBS = [
|
|
|
110
111
|
"verify-xbrief-drift",
|
|
111
112
|
"rule-ownership-lint",
|
|
112
113
|
"verify-story-ready",
|
|
114
|
+
"verify-review-monitor",
|
|
115
|
+
"review-monitor-register",
|
|
113
116
|
"verify-tools",
|
|
114
117
|
"verify-wip-cap",
|
|
115
118
|
"verify-agents-md-budget",
|
|
@@ -210,6 +213,8 @@ export const VERB_ALIASES = {
|
|
|
210
213
|
"xbrief:preflight": "vbrief-preflight",
|
|
211
214
|
"vbrief:activate": "vbrief-activate",
|
|
212
215
|
"verify:story-ready": "verify-story-ready",
|
|
216
|
+
"verify:review-monitor": "verify-review-monitor",
|
|
217
|
+
"review-monitor:register": "review-monitor-register",
|
|
213
218
|
"verify:tools": "verify-tools",
|
|
214
219
|
"verify:investigation": "verify-investigation",
|
|
215
220
|
"verify:judgment-gates": "verify-judgment-gates",
|
|
@@ -250,6 +255,7 @@ export const VERB_ALIASES = {
|
|
|
250
255
|
"issue:sync-from-xbrief": "issue-sync-from-xbrief",
|
|
251
256
|
upgrade: "install-upgrade",
|
|
252
257
|
"session:start": "session-start",
|
|
258
|
+
"lifecycle:event": "lifecycle-event",
|
|
253
259
|
"toolchain:check": "toolchain-check",
|
|
254
260
|
"ts:check-lane": "ts-check-lane",
|
|
255
261
|
"spec:validate": "spec-validate",
|
|
@@ -257,6 +263,7 @@ export const VERB_ALIASES = {
|
|
|
257
263
|
"prd:render": "prd-render",
|
|
258
264
|
"project:render": "project-render",
|
|
259
265
|
"project:export-spec": "export-spec",
|
|
266
|
+
"pr:watch": "pr-watch",
|
|
260
267
|
doctor: "doctor",
|
|
261
268
|
"eval:health": "eval-health",
|
|
262
269
|
"feedback:file": "feedback-file",
|
|
@@ -2435,7 +2442,13 @@ const CURATED_HELP_GROUPS = [
|
|
|
2435
2442
|
},
|
|
2436
2443
|
{
|
|
2437
2444
|
title: "Session & ritual",
|
|
2438
|
-
commands: [
|
|
2445
|
+
commands: [
|
|
2446
|
+
{ name: "session:start", summary: "Record session-start ritual state" },
|
|
2447
|
+
{
|
|
2448
|
+
name: "lifecycle:event",
|
|
2449
|
+
summary: "Record review-cycle plan:approved approval events",
|
|
2450
|
+
},
|
|
2451
|
+
],
|
|
2439
2452
|
},
|
|
2440
2453
|
{
|
|
2441
2454
|
title: "Quality & gates",
|
|
@@ -2532,6 +2545,10 @@ export async function dispatch(argv, io = defaultIo()) {
|
|
|
2532
2545
|
const canonical = resolveCanonicalVerb(verb ?? "");
|
|
2533
2546
|
if (canonical === null) {
|
|
2534
2547
|
io.writeErr(`directive: unknown verb '${verb}'\n`);
|
|
2548
|
+
if (verb?.includes(":")) {
|
|
2549
|
+
io.writeErr(`hint: prefer \`task ${verb}\` (Taskfile) or the hyphen stem ` +
|
|
2550
|
+
`(e.g. pr:watch → pr-watch / \`task pr:watch\`)\n`);
|
|
2551
|
+
}
|
|
2535
2552
|
return 1;
|
|
2536
2553
|
}
|
|
2537
2554
|
try {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export interface ParsedLifecycleEventArgs {
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
rest: string[];
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Parse lifecycle:event CLI args. */
|
|
8
|
+
export declare function parseArgs(argv: readonly string[]): ParsedLifecycleEventArgs;
|
|
9
|
+
/** Native lifecycle:event handler (#2631). */
|
|
10
|
+
export declare function run(argv: readonly string[]): number;
|
|
11
|
+
//# sourceMappingURL=lifecycle-event.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { runLifecycleEvent } from "@deftai/directive-core/lifecycle";
|
|
5
|
+
/** Parse lifecycle:event CLI args. */
|
|
6
|
+
export function parseArgs(argv) {
|
|
7
|
+
const parsed = {
|
|
8
|
+
projectRoot: ".",
|
|
9
|
+
rest: [],
|
|
10
|
+
};
|
|
11
|
+
let i = 0;
|
|
12
|
+
while (i < argv.length) {
|
|
13
|
+
const arg = argv[i];
|
|
14
|
+
if (arg === "--project-root") {
|
|
15
|
+
const value = argv[i + 1];
|
|
16
|
+
if (value === undefined) {
|
|
17
|
+
return { ...parsed, error: "argument --project-root: expected one argument" };
|
|
18
|
+
}
|
|
19
|
+
parsed.projectRoot = value;
|
|
20
|
+
i += 2;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (arg?.startsWith("--project-root=")) {
|
|
24
|
+
parsed.projectRoot = arg.slice("--project-root=".length);
|
|
25
|
+
i += 1;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
parsed.rest = argv.slice(i);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
/** Native lifecycle:event handler (#2631). */
|
|
34
|
+
export function run(argv) {
|
|
35
|
+
const args = parseArgs(argv);
|
|
36
|
+
if (args.error !== undefined) {
|
|
37
|
+
process.stderr.write(`lifecycle_event: ${args.error}\n`);
|
|
38
|
+
return 2;
|
|
39
|
+
}
|
|
40
|
+
return runLifecycleEvent(args.rest, { projectRoot: resolve(args.projectRoot) });
|
|
41
|
+
}
|
|
42
|
+
if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
43
|
+
process.exit(run(process.argv.slice(2)));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=lifecycle-event.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type PlatformPrimitive } from "@deftai/directive-core/review-monitor";
|
|
3
|
+
interface ParsedArgs {
|
|
4
|
+
pr: number | null;
|
|
5
|
+
monitorAgentId: string | null;
|
|
6
|
+
platformPrimitive: PlatformPrimitive | null;
|
|
7
|
+
repo: string | null;
|
|
8
|
+
headSha: string | null;
|
|
9
|
+
projectRoot: string;
|
|
10
|
+
parentSessionId: string | null;
|
|
11
|
+
help: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseRegisterArgs(argv: readonly string[]): ParsedArgs;
|
|
15
|
+
export declare function run(argv: readonly string[]): number;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=review-monitor-register.d.ts.map
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { REGISTER_HELP, registerReviewMonitor, } from "@deftai/directive-core/review-monitor";
|
|
5
|
+
const PRIMITIVES = new Set(["start_agent", "spawn_subagent", "cursor-task"]);
|
|
6
|
+
export function parseRegisterArgs(argv) {
|
|
7
|
+
const acc = {
|
|
8
|
+
pr: null,
|
|
9
|
+
monitorAgentId: null,
|
|
10
|
+
platformPrimitive: null,
|
|
11
|
+
repo: null,
|
|
12
|
+
headSha: null,
|
|
13
|
+
projectRoot: ".",
|
|
14
|
+
parentSessionId: null,
|
|
15
|
+
help: false,
|
|
16
|
+
};
|
|
17
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
18
|
+
const arg = argv[i];
|
|
19
|
+
if (arg === "--help" || arg === "-h") {
|
|
20
|
+
return { ...acc, help: true };
|
|
21
|
+
}
|
|
22
|
+
if (arg === "--pr") {
|
|
23
|
+
const value = argv[i + 1];
|
|
24
|
+
if (value === undefined) {
|
|
25
|
+
return { ...acc, error: "argument --pr: expected one argument" };
|
|
26
|
+
}
|
|
27
|
+
const n = Number(value);
|
|
28
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
29
|
+
return { ...acc, error: `invalid --pr value: ${value}` };
|
|
30
|
+
}
|
|
31
|
+
acc.pr = n;
|
|
32
|
+
i += 1;
|
|
33
|
+
}
|
|
34
|
+
else if (arg?.startsWith("--pr=")) {
|
|
35
|
+
const n = Number(arg.slice("--pr=".length));
|
|
36
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
37
|
+
return { ...acc, error: `invalid --pr value: ${arg}` };
|
|
38
|
+
}
|
|
39
|
+
acc.pr = n;
|
|
40
|
+
}
|
|
41
|
+
else if (arg === "--monitor-agent-id") {
|
|
42
|
+
const value = argv[i + 1];
|
|
43
|
+
if (value === undefined) {
|
|
44
|
+
return { ...acc, error: "argument --monitor-agent-id: expected one argument" };
|
|
45
|
+
}
|
|
46
|
+
acc.monitorAgentId = value;
|
|
47
|
+
i += 1;
|
|
48
|
+
}
|
|
49
|
+
else if (arg?.startsWith("--monitor-agent-id=")) {
|
|
50
|
+
acc.monitorAgentId = arg.slice("--monitor-agent-id=".length);
|
|
51
|
+
}
|
|
52
|
+
else if (arg === "--platform-primitive") {
|
|
53
|
+
const value = argv[i + 1];
|
|
54
|
+
if (value === undefined) {
|
|
55
|
+
return { ...acc, error: "argument --platform-primitive: expected one argument" };
|
|
56
|
+
}
|
|
57
|
+
if (!PRIMITIVES.has(value)) {
|
|
58
|
+
return { ...acc, error: `invalid --platform-primitive: ${value}` };
|
|
59
|
+
}
|
|
60
|
+
acc.platformPrimitive = value;
|
|
61
|
+
i += 1;
|
|
62
|
+
}
|
|
63
|
+
else if (arg?.startsWith("--platform-primitive=")) {
|
|
64
|
+
const value = arg.slice("--platform-primitive=".length);
|
|
65
|
+
if (!PRIMITIVES.has(value)) {
|
|
66
|
+
return { ...acc, error: `invalid --platform-primitive: ${value}` };
|
|
67
|
+
}
|
|
68
|
+
acc.platformPrimitive = value;
|
|
69
|
+
}
|
|
70
|
+
else if (arg === "--repo") {
|
|
71
|
+
const value = argv[i + 1];
|
|
72
|
+
if (value === undefined) {
|
|
73
|
+
return { ...acc, error: "argument --repo: expected one argument" };
|
|
74
|
+
}
|
|
75
|
+
acc.repo = value;
|
|
76
|
+
i += 1;
|
|
77
|
+
}
|
|
78
|
+
else if (arg?.startsWith("--repo=")) {
|
|
79
|
+
acc.repo = arg.slice("--repo=".length);
|
|
80
|
+
}
|
|
81
|
+
else if (arg === "--head-sha") {
|
|
82
|
+
const value = argv[i + 1];
|
|
83
|
+
if (value === undefined) {
|
|
84
|
+
return { ...acc, error: "argument --head-sha: expected one argument" };
|
|
85
|
+
}
|
|
86
|
+
acc.headSha = value;
|
|
87
|
+
i += 1;
|
|
88
|
+
}
|
|
89
|
+
else if (arg?.startsWith("--head-sha=")) {
|
|
90
|
+
acc.headSha = arg.slice("--head-sha=".length);
|
|
91
|
+
}
|
|
92
|
+
else if (arg === "--project-root") {
|
|
93
|
+
const value = argv[i + 1];
|
|
94
|
+
if (value === undefined) {
|
|
95
|
+
return { ...acc, error: "argument --project-root: expected one argument" };
|
|
96
|
+
}
|
|
97
|
+
acc.projectRoot = value;
|
|
98
|
+
i += 1;
|
|
99
|
+
}
|
|
100
|
+
else if (arg?.startsWith("--project-root=")) {
|
|
101
|
+
acc.projectRoot = arg.slice("--project-root=".length);
|
|
102
|
+
}
|
|
103
|
+
else if (arg === "--parent-session-id") {
|
|
104
|
+
const value = argv[i + 1];
|
|
105
|
+
if (value === undefined) {
|
|
106
|
+
return { ...acc, error: "argument --parent-session-id: expected one argument" };
|
|
107
|
+
}
|
|
108
|
+
acc.parentSessionId = value;
|
|
109
|
+
i += 1;
|
|
110
|
+
}
|
|
111
|
+
else if (arg?.startsWith("--parent-session-id=")) {
|
|
112
|
+
acc.parentSessionId = arg.slice("--parent-session-id=".length);
|
|
113
|
+
}
|
|
114
|
+
else if (arg?.startsWith("-")) {
|
|
115
|
+
return { ...acc, error: `unrecognized argument: ${arg}` };
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return { ...acc, error: `unrecognized argument: ${arg}` };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return acc;
|
|
122
|
+
}
|
|
123
|
+
export function run(argv) {
|
|
124
|
+
const args = parseRegisterArgs(argv);
|
|
125
|
+
if (args.help) {
|
|
126
|
+
process.stdout.write(REGISTER_HELP);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
if (args.error !== undefined) {
|
|
130
|
+
process.stderr.write(`review_monitor_register: ${args.error}\n`);
|
|
131
|
+
return 2;
|
|
132
|
+
}
|
|
133
|
+
if (args.pr === null) {
|
|
134
|
+
process.stderr.write("review_monitor_register: --pr is required\n");
|
|
135
|
+
return 2;
|
|
136
|
+
}
|
|
137
|
+
if (args.monitorAgentId === null || args.monitorAgentId.trim().length === 0) {
|
|
138
|
+
process.stderr.write("review_monitor_register: --monitor-agent-id is required\n");
|
|
139
|
+
return 2;
|
|
140
|
+
}
|
|
141
|
+
if (args.platformPrimitive === null) {
|
|
142
|
+
process.stderr.write("review_monitor_register: --platform-primitive is required\n");
|
|
143
|
+
return 2;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const { path, record } = registerReviewMonitor({
|
|
147
|
+
pr: args.pr,
|
|
148
|
+
repo: args.repo,
|
|
149
|
+
headSha: args.headSha,
|
|
150
|
+
platformPrimitive: args.platformPrimitive,
|
|
151
|
+
monitorAgentId: args.monitorAgentId,
|
|
152
|
+
projectRoot: resolve(args.projectRoot),
|
|
153
|
+
parentSessionId: args.parentSessionId,
|
|
154
|
+
});
|
|
155
|
+
process.stdout.write(`review_monitor_register: recorded PR #${record.pr} monitor ${record.monitor_agent_id} at ${path}\n`);
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
process.stderr.write(`review_monitor_register: ${String(err.message ?? err)}\n`);
|
|
160
|
+
return 2;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
164
|
+
process.exit(run(process.argv.slice(2)));
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=review-monitor-register.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type ReviewMonitorCallSite } from "@deftai/directive-core/review-monitor";
|
|
3
|
+
interface ParsedArgs {
|
|
4
|
+
pr: number | null;
|
|
5
|
+
projectRoot: string;
|
|
6
|
+
repo: string | null;
|
|
7
|
+
headSha: string | null;
|
|
8
|
+
callSite: ReviewMonitorCallSite;
|
|
9
|
+
approach3: boolean;
|
|
10
|
+
approach3Warned: boolean;
|
|
11
|
+
emitJson: boolean;
|
|
12
|
+
help: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseVerifyReviewMonitorArgs(argv: readonly string[]): ParsedArgs;
|
|
16
|
+
export declare function run(argv: readonly string[]): number;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=verify-review-monitor.d.ts.map
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { evaluateReviewMonitorGate, REVIEW_MONITOR_HELP, verifyResultToJson, } from "@deftai/directive-core/review-monitor";
|
|
5
|
+
const CALL_SITES = new Set([
|
|
6
|
+
"solo",
|
|
7
|
+
"swarm-phase5-6",
|
|
8
|
+
"swarm-phase6-cascade",
|
|
9
|
+
"unspecified",
|
|
10
|
+
]);
|
|
11
|
+
export function parseVerifyReviewMonitorArgs(argv) {
|
|
12
|
+
const acc = {
|
|
13
|
+
pr: null,
|
|
14
|
+
projectRoot: ".",
|
|
15
|
+
repo: null,
|
|
16
|
+
headSha: null,
|
|
17
|
+
callSite: "unspecified",
|
|
18
|
+
approach3: false,
|
|
19
|
+
approach3Warned: false,
|
|
20
|
+
emitJson: false,
|
|
21
|
+
help: false,
|
|
22
|
+
};
|
|
23
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
24
|
+
const arg = argv[i];
|
|
25
|
+
if (arg === "--help" || arg === "-h") {
|
|
26
|
+
return { ...acc, help: true };
|
|
27
|
+
}
|
|
28
|
+
if (arg === "--json") {
|
|
29
|
+
acc.emitJson = true;
|
|
30
|
+
}
|
|
31
|
+
else if (arg === "--approach3") {
|
|
32
|
+
acc.approach3 = true;
|
|
33
|
+
}
|
|
34
|
+
else if (arg === "--approach3-warned") {
|
|
35
|
+
acc.approach3Warned = true;
|
|
36
|
+
}
|
|
37
|
+
else if (arg === "--pr") {
|
|
38
|
+
const value = argv[i + 1];
|
|
39
|
+
if (value === undefined) {
|
|
40
|
+
return { ...acc, error: "argument --pr: expected one argument" };
|
|
41
|
+
}
|
|
42
|
+
const n = Number(value);
|
|
43
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
44
|
+
return { ...acc, error: `invalid --pr value: ${value}` };
|
|
45
|
+
}
|
|
46
|
+
acc.pr = n;
|
|
47
|
+
i += 1;
|
|
48
|
+
}
|
|
49
|
+
else if (arg?.startsWith("--pr=")) {
|
|
50
|
+
const n = Number(arg.slice("--pr=".length));
|
|
51
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
52
|
+
return { ...acc, error: `invalid --pr value: ${arg}` };
|
|
53
|
+
}
|
|
54
|
+
acc.pr = n;
|
|
55
|
+
}
|
|
56
|
+
else if (arg === "--repo") {
|
|
57
|
+
const value = argv[i + 1];
|
|
58
|
+
if (value === undefined) {
|
|
59
|
+
return { ...acc, error: "argument --repo: expected one argument" };
|
|
60
|
+
}
|
|
61
|
+
acc.repo = value;
|
|
62
|
+
i += 1;
|
|
63
|
+
}
|
|
64
|
+
else if (arg?.startsWith("--repo=")) {
|
|
65
|
+
acc.repo = arg.slice("--repo=".length);
|
|
66
|
+
}
|
|
67
|
+
else if (arg === "--head-sha") {
|
|
68
|
+
const value = argv[i + 1];
|
|
69
|
+
if (value === undefined) {
|
|
70
|
+
return { ...acc, error: "argument --head-sha: expected one argument" };
|
|
71
|
+
}
|
|
72
|
+
acc.headSha = value;
|
|
73
|
+
i += 1;
|
|
74
|
+
}
|
|
75
|
+
else if (arg?.startsWith("--head-sha=")) {
|
|
76
|
+
acc.headSha = arg.slice("--head-sha=".length);
|
|
77
|
+
}
|
|
78
|
+
else if (arg === "--project-root") {
|
|
79
|
+
const value = argv[i + 1];
|
|
80
|
+
if (value === undefined) {
|
|
81
|
+
return { ...acc, error: "argument --project-root: expected one argument" };
|
|
82
|
+
}
|
|
83
|
+
acc.projectRoot = value;
|
|
84
|
+
i += 1;
|
|
85
|
+
}
|
|
86
|
+
else if (arg?.startsWith("--project-root=")) {
|
|
87
|
+
acc.projectRoot = arg.slice("--project-root=".length);
|
|
88
|
+
}
|
|
89
|
+
else if (arg === "--call-site") {
|
|
90
|
+
const value = argv[i + 1];
|
|
91
|
+
if (value === undefined) {
|
|
92
|
+
return { ...acc, error: "argument --call-site: expected one argument" };
|
|
93
|
+
}
|
|
94
|
+
if (!CALL_SITES.has(value)) {
|
|
95
|
+
return { ...acc, error: `invalid --call-site: ${value}` };
|
|
96
|
+
}
|
|
97
|
+
acc.callSite = value;
|
|
98
|
+
i += 1;
|
|
99
|
+
}
|
|
100
|
+
else if (arg?.startsWith("--call-site=")) {
|
|
101
|
+
const value = arg.slice("--call-site=".length);
|
|
102
|
+
if (!CALL_SITES.has(value)) {
|
|
103
|
+
return { ...acc, error: `invalid --call-site: ${value}` };
|
|
104
|
+
}
|
|
105
|
+
acc.callSite = value;
|
|
106
|
+
}
|
|
107
|
+
else if (arg?.startsWith("-")) {
|
|
108
|
+
return { ...acc, error: `unrecognized argument: ${arg}` };
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return { ...acc, error: `unrecognized argument: ${arg}` };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return acc;
|
|
115
|
+
}
|
|
116
|
+
export function run(argv) {
|
|
117
|
+
const args = parseVerifyReviewMonitorArgs(argv);
|
|
118
|
+
if (args.help) {
|
|
119
|
+
process.stdout.write(REVIEW_MONITOR_HELP);
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
if (args.error !== undefined) {
|
|
123
|
+
process.stderr.write(`verify_review_monitor: ${args.error}\n`);
|
|
124
|
+
process.stderr.write("Try: task verify:review-monitor -- --help\n");
|
|
125
|
+
return 2;
|
|
126
|
+
}
|
|
127
|
+
if (args.pr === null) {
|
|
128
|
+
process.stderr.write("verify_review_monitor: --pr is required\n");
|
|
129
|
+
process.stderr.write("Try: task verify:review-monitor -- --help\n");
|
|
130
|
+
return 2;
|
|
131
|
+
}
|
|
132
|
+
const result = evaluateReviewMonitorGate({
|
|
133
|
+
pr: args.pr,
|
|
134
|
+
projectRoot: resolve(args.projectRoot),
|
|
135
|
+
repo: args.repo,
|
|
136
|
+
headSha: args.headSha,
|
|
137
|
+
callSite: args.callSite,
|
|
138
|
+
approach3: args.approach3,
|
|
139
|
+
approach3Warned: args.approach3Warned,
|
|
140
|
+
environ: process.env,
|
|
141
|
+
});
|
|
142
|
+
if (args.emitJson) {
|
|
143
|
+
process.stdout.write(`${JSON.stringify(verifyResultToJson(result), null, 2)}\n`);
|
|
144
|
+
}
|
|
145
|
+
else if (result.exitCode === 0) {
|
|
146
|
+
process.stdout.write(`${result.message}\n`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
process.stderr.write(`${result.message}\n`);
|
|
150
|
+
}
|
|
151
|
+
return result.exitCode;
|
|
152
|
+
}
|
|
153
|
+
if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
154
|
+
process.exit(run(process.argv.slice(2)));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=verify-review-monitor.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deftai/directive",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.3",
|
|
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.79.
|
|
35
|
-
"@deftai/directive-content": "^0.79.
|
|
34
|
+
"@deftai/directive-core": "^0.79.3",
|
|
35
|
+
"@deftai/directive-content": "^0.79.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc -b"
|