@skrr-ai/cli 0.1.21 → 0.1.22
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/commands/commitments/create.d.ts +1 -0
- package/dist/commands/commitments/create.js +19 -5
- package/dist/lib/commitments.d.ts +2 -0
- package/dist/lib/commitments.js +31 -1
- package/oclif.manifest.json +24859 -24843
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ export default class CommitmentsCreate extends BaseCommand {
|
|
|
62
62
|
measure: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
63
63
|
source: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
64
64
|
watch: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
65
|
+
'github-event': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
65
66
|
'metric-key': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
66
67
|
'watch-space': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
67
68
|
'watch-monitor': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -13,6 +13,15 @@ const commitment_product_1 = require("../../lib/commitment-product");
|
|
|
13
13
|
const commitments_1 = require("../../lib/commitments");
|
|
14
14
|
const DEFAULT_EVENT_DRIVEN_BACKSTOP_MS = 24 * 60 * 60 * 1000;
|
|
15
15
|
const DEFAULT_EVENT_SOURCES = new Set(['github', 'slack', 'email', 'calendar']);
|
|
16
|
+
const GITHUB_EVENT_OPTIONS = [
|
|
17
|
+
'pull_request_opened',
|
|
18
|
+
'pull_request_merged',
|
|
19
|
+
'review_requested',
|
|
20
|
+
'check_run_failed',
|
|
21
|
+
'check_run_succeeded',
|
|
22
|
+
'issue_opened',
|
|
23
|
+
'comment_created',
|
|
24
|
+
];
|
|
16
25
|
function record(value) {
|
|
17
26
|
return value && typeof value === 'object' && !Array.isArray(value)
|
|
18
27
|
? value
|
|
@@ -66,7 +75,7 @@ function hasEventCapableWatchedSource(payload) {
|
|
|
66
75
|
return Array.isArray(config?.events) ? hasStructurallyValidExplicitEvent(config) : true;
|
|
67
76
|
}
|
|
68
77
|
if (source === 'tasks') {
|
|
69
|
-
return
|
|
78
|
+
return goalId || configuredId(config, 'taskId', 'goalId', 'keyResultId');
|
|
70
79
|
}
|
|
71
80
|
if (source === 'goal') {
|
|
72
81
|
return goalId || configuredId(config, 'goalId', 'keyResultId');
|
|
@@ -113,9 +122,7 @@ function createCadenceFromFlags({ eventDriven, cadence: cadenceInput, cadenceMod
|
|
|
113
122
|
}
|
|
114
123
|
return {
|
|
115
124
|
mode: 'event_plus_interval',
|
|
116
|
-
intervalMs: cadenceInput
|
|
117
|
-
? (0, commitments_1.parseIntervalToMs)(cadenceInput)
|
|
118
|
-
: DEFAULT_EVENT_DRIVEN_BACKSTOP_MS,
|
|
125
|
+
intervalMs: cadenceInput ? (0, commitments_1.parseIntervalToMs)(cadenceInput) : DEFAULT_EVENT_DRIVEN_BACKSTOP_MS,
|
|
119
126
|
...(timezone ? { timezone } : {}),
|
|
120
127
|
};
|
|
121
128
|
}
|
|
@@ -180,7 +187,7 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
180
187
|
'<%= config.bin %> commitments create --agent <agent-id> --title "SLA" --outcome "p95 under 200ms" --criterion "p95 latency confirmed" --evaluator metric --measure <measure-id>',
|
|
181
188
|
'<%= config.bin %> commitments create --agent <agent-id> --title "AWS cost watch" --outcome "Cost regressions are investigated" --agent-directive-file ./aws-cost-policy.md',
|
|
182
189
|
'<%= config.bin %> commitments create --from-json commitment.json --json',
|
|
183
|
-
'<%= config.bin %> commitments create --agent <agent-id> --title "Keep CI healthy" --outcome "Failed checks are repaired" --watch github --event-driven --mode execute --delivery draft-pr --repo owner/repo --base main --status draft',
|
|
190
|
+
'<%= config.bin %> commitments create --agent <agent-id> --title "Keep CI healthy" --outcome "Failed checks are repaired" --watch github --github-event check_run_failed --event-driven --mode execute --delivery draft-pr --repo owner/repo --base main --status draft',
|
|
184
191
|
];
|
|
185
192
|
static flags = {
|
|
186
193
|
json: core_1.Flags.boolean({ description: 'Output the created commitment as JSON' }),
|
|
@@ -228,6 +235,11 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
228
235
|
multiple: true,
|
|
229
236
|
options: [...commitments_1.COMMITMENT_WATCHED_SOURCES],
|
|
230
237
|
}),
|
|
238
|
+
'github-event': core_1.Flags.string({
|
|
239
|
+
description: 'GitHub event to watch (repeatable; implies --watch github). Use check_run_failed for CI remediation.',
|
|
240
|
+
multiple: true,
|
|
241
|
+
options: [...GITHUB_EVENT_OPTIONS],
|
|
242
|
+
}),
|
|
231
243
|
'metric-key': core_1.Flags.string({
|
|
232
244
|
description: 'Metric key to read when --watch metrics is used (repeatable)',
|
|
233
245
|
multiple: true,
|
|
@@ -360,6 +372,8 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
360
372
|
metricKey: (0, triggers_1.splitRepeated)(flags['metric-key']),
|
|
361
373
|
spaceIds: resolvedSpaceIds,
|
|
362
374
|
monitorIds: (0, triggers_1.splitRepeated)(flags['watch-monitor']),
|
|
375
|
+
githubEvents: (0, triggers_1.splitRepeated)(flags['github-event']),
|
|
376
|
+
githubRepository: flags.repo,
|
|
363
377
|
});
|
|
364
378
|
if (built)
|
|
365
379
|
payload.watchedSources = built;
|
|
@@ -449,6 +449,8 @@ export declare function parseIntervalToMs(input: string): number;
|
|
|
449
449
|
export type WatchFlagInputs = {
|
|
450
450
|
watch?: string[];
|
|
451
451
|
metricKey?: string[];
|
|
452
|
+
githubEvents?: string[];
|
|
453
|
+
githubRepository?: string;
|
|
452
454
|
/** Already resolved to canonical space ids by the caller. */
|
|
453
455
|
spaceIds?: string[];
|
|
454
456
|
monitorIds?: string[];
|
package/dist/lib/commitments.js
CHANGED
|
@@ -438,11 +438,17 @@ function buildWatchedSources(inputs) {
|
|
|
438
438
|
const metricKeys = (inputs.metricKey ?? []).filter(Boolean);
|
|
439
439
|
const spaceIds = (inputs.spaceIds ?? []).filter(Boolean);
|
|
440
440
|
const monitorIds = (inputs.monitorIds ?? []).filter(Boolean);
|
|
441
|
+
const githubEvents = (inputs.githubEvents ?? []).filter(Boolean);
|
|
442
|
+
const githubRepository = String(inputs.githubRepository || '')
|
|
443
|
+
.trim()
|
|
444
|
+
.toLowerCase();
|
|
441
445
|
const effective = new Set(watched);
|
|
442
446
|
if (spaceIds.length)
|
|
443
447
|
effective.add('space');
|
|
444
448
|
if (monitorIds.length)
|
|
445
449
|
effective.add('monitor');
|
|
450
|
+
if (githubEvents.length)
|
|
451
|
+
effective.add('github');
|
|
446
452
|
if (effective.has('space') && spaceIds.length === 0) {
|
|
447
453
|
throw new Error('--watch space needs at least one --watch-space <space-id-or-ref>. ' +
|
|
448
454
|
'The `space` source requires a scope id, which the enum on its own cannot carry.');
|
|
@@ -466,7 +472,7 @@ function buildWatchedSources(inputs) {
|
|
|
466
472
|
seen.add(s);
|
|
467
473
|
}
|
|
468
474
|
}
|
|
469
|
-
for (const implied of ['space', 'monitor']) {
|
|
475
|
+
for (const implied of ['space', 'monitor', 'github']) {
|
|
470
476
|
if (effective.has(implied) && !seen.has(implied)) {
|
|
471
477
|
orderedSources.push(implied);
|
|
472
478
|
seen.add(implied);
|
|
@@ -487,6 +493,30 @@ function buildWatchedSources(inputs) {
|
|
|
487
493
|
else if (source === 'metrics' && metricKeys.length) {
|
|
488
494
|
rows.push({ source, enabled: true, config: { metricKeys } });
|
|
489
495
|
}
|
|
496
|
+
else if (source === 'github' && (githubEvents.length || githubRepository)) {
|
|
497
|
+
rows.push({
|
|
498
|
+
source,
|
|
499
|
+
enabled: true,
|
|
500
|
+
config: {
|
|
501
|
+
...(githubRepository ? { repository: githubRepository } : {}),
|
|
502
|
+
...(githubEvents.length
|
|
503
|
+
? {
|
|
504
|
+
events: githubEvents.map((eventType) => ({
|
|
505
|
+
entityType: 'github',
|
|
506
|
+
eventType,
|
|
507
|
+
...(githubRepository
|
|
508
|
+
? {
|
|
509
|
+
filterField: 'repoFullName',
|
|
510
|
+
filterMode: 'equals',
|
|
511
|
+
filterValue: githubRepository,
|
|
512
|
+
}
|
|
513
|
+
: {}),
|
|
514
|
+
})),
|
|
515
|
+
}
|
|
516
|
+
: {}),
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
}
|
|
490
520
|
else {
|
|
491
521
|
rows.push({ source, enabled: true });
|
|
492
522
|
}
|