copilot-tap-extension 1.1.3 → 1.1.4
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/extension.mjs +46 -14
- package/dist/skills/monitor/SKILL.md +9 -26
- package/dist/version.json +1 -1
- package/package.json +1 -1
package/dist/extension.mjs
CHANGED
|
@@ -3851,6 +3851,20 @@ function clampLimit(value, fallback = 20) {
|
|
|
3851
3851
|
function nowIso() {
|
|
3852
3852
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3853
3853
|
}
|
|
3854
|
+
function parseIntervalSchedule(value) {
|
|
3855
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
3856
|
+
return null;
|
|
3857
|
+
}
|
|
3858
|
+
return value.map((item, index) => {
|
|
3859
|
+
const parsed = parseLoopInterval(item);
|
|
3860
|
+
if (parsed === null || parsed.idle === true || !Number.isFinite(parsed.ms) || parsed.ms <= 0) {
|
|
3861
|
+
throw new Error(
|
|
3862
|
+
`Invalid interval schedule entry at index ${index}: '${item}'. Schedule entries must be non-blank intervals greater than 0 and cannot be 'idle'.`
|
|
3863
|
+
);
|
|
3864
|
+
}
|
|
3865
|
+
return parsed;
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3854
3868
|
function parseLoopInterval(value) {
|
|
3855
3869
|
if (value === void 0 || value === null || String(value).trim() === "") {
|
|
3856
3870
|
return null;
|
|
@@ -4306,7 +4320,11 @@ function buildEmitterState(spec, baseCwd, defaults = {}) {
|
|
|
4306
4320
|
if (command && prompt) {
|
|
4307
4321
|
throw new Error(`Emitter '${name}' cannot define both command and prompt. Choose one emitter type.`);
|
|
4308
4322
|
}
|
|
4309
|
-
const
|
|
4323
|
+
const schedule = parseIntervalSchedule(spec.everySchedule);
|
|
4324
|
+
if (schedule && spec.every != null && String(spec.every).trim() !== "") {
|
|
4325
|
+
throw new Error(`Emitter '${name}': 'every' and 'everySchedule' are mutually exclusive. Use one or the other.`);
|
|
4326
|
+
}
|
|
4327
|
+
const interval = schedule ? null : parseLoopInterval(spec.every);
|
|
4310
4328
|
const lifespan = normalizeLifespan(spec.scope, defaults.scope ?? LIFESPAN.TEMPORARY);
|
|
4311
4329
|
const ownership = normalizeOwnership(spec.managedBy, defaults.managedBy ?? OWNERSHIP.MODEL_OWNED);
|
|
4312
4330
|
const eventFilter = createEventFilter(
|
|
@@ -4321,7 +4339,7 @@ function buildEmitterState(spec, baseCwd, defaults = {}) {
|
|
|
4321
4339
|
throw new Error(`Emitter '${name}': every='idle' is only valid for prompt emitters, not command emitters.`);
|
|
4322
4340
|
}
|
|
4323
4341
|
runSchedule = RUN_SCHEDULE.IDLE;
|
|
4324
|
-
} else if (interval) {
|
|
4342
|
+
} else if (interval || schedule) {
|
|
4325
4343
|
runSchedule = RUN_SCHEDULE.TIMED;
|
|
4326
4344
|
} else if (prompt) {
|
|
4327
4345
|
runSchedule = RUN_SCHEDULE.ONE_TIME;
|
|
@@ -4336,8 +4354,10 @@ function buildEmitterState(spec, baseCwd, defaults = {}) {
|
|
|
4336
4354
|
prompt: prompt || null,
|
|
4337
4355
|
emitterType,
|
|
4338
4356
|
runSchedule,
|
|
4339
|
-
every: interval?.text ?? null,
|
|
4340
|
-
everyMs: interval?.ms ?? null,
|
|
4357
|
+
every: interval?.text ?? (schedule ? schedule[0].text : null),
|
|
4358
|
+
everyMs: interval?.ms ?? (schedule ? schedule[0].ms : null),
|
|
4359
|
+
everySchedule: schedule ? schedule.map((s) => s.text) : null,
|
|
4360
|
+
everyScheduleMs: schedule ? schedule.map((s) => s.ms) : null,
|
|
4341
4361
|
requestedCwd: spec.cwd ?? null,
|
|
4342
4362
|
cwd: resolveRequestedCwd(baseCwd, spec.cwd),
|
|
4343
4363
|
stream: normalizeName(spec.channel, name),
|
|
@@ -4446,15 +4466,16 @@ function formatRunningEmitter(emitter, stream) {
|
|
|
4446
4466
|
return [
|
|
4447
4467
|
`- ${emitter.name}:`,
|
|
4448
4468
|
` status=${emitter.status}`,
|
|
4449
|
-
` scope=${emitter.
|
|
4450
|
-
` managedBy=${emitter.
|
|
4469
|
+
` scope=${emitter.lifespan}`,
|
|
4470
|
+
` managedBy=${emitter.ownership}`,
|
|
4451
4471
|
` emitterType=${emitter.emitterType}`,
|
|
4452
4472
|
` runSchedule=${emitter.runSchedule}`,
|
|
4453
|
-
` stream=${emitter.
|
|
4473
|
+
` stream=${emitter.stream}`,
|
|
4454
4474
|
` sessionInjector=${stream?.sessionInjector?.enabled ? "on" : "off"}`,
|
|
4455
4475
|
` cwd=${emitter.cwd}`,
|
|
4456
4476
|
` ${describeEmitterWork(emitter)}`,
|
|
4457
|
-
emitter.
|
|
4477
|
+
emitter.everySchedule ? ` everySchedule=[${emitter.everySchedule.join(", ")}]` : null,
|
|
4478
|
+
emitter.every && !emitter.everySchedule ? ` every=${emitter.every}` : null,
|
|
4458
4479
|
emitter.maxRuns ? ` maxRuns=${emitter.maxRuns}` : null,
|
|
4459
4480
|
` autoStart=${emitter.autoStart}`,
|
|
4460
4481
|
` includeStderr=${emitter.includeStderr}`,
|
|
@@ -4636,6 +4657,16 @@ function createLifecycle({ lineRouter, sessionPort }) {
|
|
|
4636
4657
|
void runScheduledIteration(emitter);
|
|
4637
4658
|
}, delayMs);
|
|
4638
4659
|
}
|
|
4660
|
+
function nextDelay(emitter) {
|
|
4661
|
+
if (emitter.runSchedule === RUN_SCHEDULE.IDLE) {
|
|
4662
|
+
return IDLE_PROMPT_DELAY_MS;
|
|
4663
|
+
}
|
|
4664
|
+
if (emitter.everyScheduleMs) {
|
|
4665
|
+
const idx = Math.min(Math.max(0, emitter.runCount - 1), emitter.everyScheduleMs.length - 1);
|
|
4666
|
+
return emitter.everyScheduleMs[idx];
|
|
4667
|
+
}
|
|
4668
|
+
return emitter.everyMs;
|
|
4669
|
+
}
|
|
4639
4670
|
async function runScheduledIteration(emitter) {
|
|
4640
4671
|
if (emitter.stopRequested || emitter.inFlight) {
|
|
4641
4672
|
return;
|
|
@@ -4673,13 +4704,12 @@ function createLifecycle({ lineRouter, sessionPort }) {
|
|
|
4673
4704
|
return;
|
|
4674
4705
|
}
|
|
4675
4706
|
emitter.status = EMITTER_STATUS.WAITING;
|
|
4676
|
-
|
|
4677
|
-
scheduleIteration(emitter, delay);
|
|
4707
|
+
scheduleIteration(emitter, nextDelay(emitter));
|
|
4678
4708
|
return;
|
|
4679
4709
|
}
|
|
4680
4710
|
if (result.deferred) {
|
|
4681
4711
|
emitter.status = EMITTER_STATUS.WAITING;
|
|
4682
|
-
const retryDelay = emitter.runSchedule === RUN_SCHEDULE.IDLE ? IDLE_PROMPT_BACKOFF_MS : emitter
|
|
4712
|
+
const retryDelay = emitter.runSchedule === RUN_SCHEDULE.IDLE ? IDLE_PROMPT_BACKOFF_MS : nextDelay(emitter);
|
|
4683
4713
|
if (emitter.runSchedule !== RUN_SCHEDULE.IDLE) {
|
|
4684
4714
|
lineRouter.appendSystemMessage(
|
|
4685
4715
|
emitter,
|
|
@@ -4705,11 +4735,11 @@ function createLifecycle({ lineRouter, sessionPort }) {
|
|
|
4705
4735
|
return;
|
|
4706
4736
|
}
|
|
4707
4737
|
emitter.status = EMITTER_STATUS.WAITING;
|
|
4708
|
-
const failRetryDelay = emitter.runSchedule === RUN_SCHEDULE.IDLE ? IDLE_PROMPT_BACKOFF_MS : emitter
|
|
4738
|
+
const failRetryDelay = emitter.runSchedule === RUN_SCHEDULE.IDLE ? IDLE_PROMPT_BACKOFF_MS : nextDelay(emitter);
|
|
4709
4739
|
scheduleIteration(emitter, failRetryDelay);
|
|
4710
4740
|
}
|
|
4711
4741
|
function startScheduled(emitter) {
|
|
4712
|
-
const scheduleLabel = emitter.runSchedule === RUN_SCHEDULE.TIMED ? `every ${emitter.every}` : emitter.runSchedule === RUN_SCHEDULE.IDLE ? "when idle" : RUN_SCHEDULE.ONE_TIME;
|
|
4742
|
+
const scheduleLabel = emitter.runSchedule === RUN_SCHEDULE.TIMED ? emitter.everySchedule ? `backoff [${emitter.everySchedule.join(", ")}]` : `every ${emitter.every}` : emitter.runSchedule === RUN_SCHEDULE.IDLE ? "when idle" : RUN_SCHEDULE.ONE_TIME;
|
|
4713
4743
|
const initialDelayMs = 0;
|
|
4714
4744
|
const firstRunLabel = "";
|
|
4715
4745
|
lineRouter.appendSystemMessage(
|
|
@@ -5088,6 +5118,7 @@ function createEmitterTools({ streams, configStore, supervisor, getBaseCwd }) {
|
|
|
5088
5118
|
channel: { type: "string", description: "EventStream to receive accepted events." },
|
|
5089
5119
|
cwd: { type: "string", description: "Optional working directory relative to the session cwd." },
|
|
5090
5120
|
every: { type: "string", description: "Optional repeat interval like 30s, 5m, 2h, or 1d. Use 'idle' for prompts that re-run whenever the session is idle. When omitted, commands run continuously and prompts run once." },
|
|
5121
|
+
everySchedule: { type: "array", minItems: 1, items: { type: "string" }, description: "Optional backoff schedule \u2014 an ordered non-empty list of interval strings (e.g. ['10s','20s','30s','1m','2m','5m','10m']). The emitter uses each interval in sequence, then repeats the last one forever. Overrides 'every' when provided. Cannot be 'idle' entries." },
|
|
5091
5122
|
scope: { type: "string", description: "Use 'temporary' for session-only or 'persistent' to write config." },
|
|
5092
5123
|
managedBy: { type: "string", description: "Ownership label: 'userOwned' or 'modelOwned'." },
|
|
5093
5124
|
autoStart: { type: "boolean", description: "When persistent, whether the emitter should auto-start next session." },
|
|
@@ -5122,7 +5153,8 @@ function createEmitterTools({ streams, configStore, supervisor, getBaseCwd }) {
|
|
|
5122
5153
|
`ownership=${emitter.ownership}`,
|
|
5123
5154
|
`emitterType=${emitter.emitterType}`,
|
|
5124
5155
|
`runSchedule=${emitter.runSchedule}`,
|
|
5125
|
-
emitter.
|
|
5156
|
+
emitter.everySchedule ? `everySchedule=[${emitter.everySchedule.join(", ")}]` : null,
|
|
5157
|
+
emitter.every && !emitter.everySchedule ? `every=${emitter.every}` : null,
|
|
5126
5158
|
emitter.maxRuns ? `maxRuns=${emitter.maxRuns}` : null,
|
|
5127
5159
|
`stream=${emitter.stream}`,
|
|
5128
5160
|
`sessionInjector=${streams.ensure(emitter.stream).sessionInjector.enabled ? "on" : "off"}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: monitor
|
|
3
3
|
description: "Start a self-tuning command monitor. Use when the user says 'monitor', 'watch', 'tail', 'track', 'keep an eye on', or wants a shell command to run continuously while Copilot automatically reviews and tunes the output filters over time."
|
|
4
|
-
argument-hint: "
|
|
4
|
+
argument-hint: "<shell-command>"
|
|
5
5
|
user-invocable: true
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,33 +9,18 @@ Start a CommandEmitter for the given shell command paired with a companion Promp
|
|
|
9
9
|
|
|
10
10
|
## Expected input
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
The entire invocation is the shell command to run continuously.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
2. The rest of the input is the shell command to run continuously.
|
|
16
|
-
|
|
17
|
-
Example (with explicit interval):
|
|
14
|
+
Example:
|
|
18
15
|
|
|
19
16
|
```text
|
|
20
|
-
/monitor
|
|
17
|
+
/monitor tail -f /var/log/app.log
|
|
21
18
|
```
|
|
22
19
|
|
|
23
20
|
means:
|
|
24
21
|
|
|
25
|
-
- `reviewInterval = "10m"` — companion reviews the stream every 10 minutes
|
|
26
22
|
- `command = "tail -f /var/log/app.log"`
|
|
27
23
|
|
|
28
|
-
Example (default interval):
|
|
29
|
-
|
|
30
|
-
```text
|
|
31
|
-
/monitor docker logs -f mycontainer
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
means:
|
|
35
|
-
|
|
36
|
-
- `reviewInterval = "5m"` (default)
|
|
37
|
-
- `command = "docker logs -f mycontainer"`
|
|
38
|
-
|
|
39
24
|
If the command is missing, ask the user for it instead of guessing.
|
|
40
25
|
|
|
41
26
|
## What to create
|
|
@@ -57,7 +42,7 @@ Use `tap_start_emitter` to start the CommandEmitter:
|
|
|
57
42
|
Use `tap_start_emitter` to start a second emitter immediately after the command emitter:
|
|
58
43
|
|
|
59
44
|
- `prompt` — a **fully self-contained** instruction (see template below).
|
|
60
|
-
- `
|
|
45
|
+
- `everySchedule: ["10s", "20s", "30s", "1m", "2m", "5m", "10m"]` — backoff schedule: reviews start very frequent to validate the monitor quickly, then space out as it stabilises.
|
|
61
46
|
- `scope = "temporary"`, `managedBy = "modelOwned"`.
|
|
62
47
|
- Name it `<command-emitter-name>-review`.
|
|
63
48
|
- `subscribe = false` — review is internal housekeeping, not user-facing.
|
|
@@ -89,13 +74,13 @@ Substitute the real emitter name and stream name into the prompt before passing
|
|
|
89
74
|
|
|
90
75
|
When this skill is invoked:
|
|
91
76
|
|
|
92
|
-
1. Parse the
|
|
77
|
+
1. Parse the command from the invocation.
|
|
93
78
|
2. Start the CommandEmitter.
|
|
94
|
-
3. Start the companion PromptEmitter using the self-contained prompt template
|
|
79
|
+
3. Start the companion PromptEmitter using the self-contained prompt template and the hardcoded backoff schedule.
|
|
95
80
|
4. Confirm to the user:
|
|
96
81
|
- Command emitter name and stream.
|
|
97
82
|
- Initial filter patterns (or "none set — companion will tune on first review").
|
|
98
|
-
- Companion reviewer name and review
|
|
83
|
+
- Companion reviewer name and its review schedule (first check in 10s, backing off to 10m).
|
|
99
84
|
5. Stop there — do not immediately inspect stream history or simulate a review.
|
|
100
85
|
|
|
101
86
|
## Stopping the monitor
|
|
@@ -124,6 +109,4 @@ Remind the companion (via the prompt) to be conservative:
|
|
|
124
109
|
|
|
125
110
|
## If the input is incomplete
|
|
126
111
|
|
|
127
|
-
If the
|
|
128
|
-
|
|
129
|
-
If only an interval is given with no command, ask for the command.
|
|
112
|
+
If the invocation contains no recognisable shell command, ask the user for it.
|
package/dist/version.json
CHANGED