@bonesofspring/ai-rules 0.2.73 → 0.2.74
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/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/bin/lib/engine-scripts.js +8 -0
- package/docs/TEAM-DB.md +86 -5
- package/docs/openapi/team-db.v1.json +1164 -224
- package/package.json +1 -1
- package/presets/_shared/ai-local/scripts/action-signals.mjs +225 -0
- package/presets/_shared/ai-local/scripts/actions-report.mjs +210 -0
- package/presets/_shared/ai-local/scripts/processes.mjs +5 -4
- package/presets/_shared/ai-local/scripts/rr-scheduler-start.mjs +161 -0
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +347 -9
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +309 -4
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +239 -25
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +86 -1
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +15 -1
- package/presets/claude/android-kotlin/commands/README.md +4 -0
- package/presets/claude/android-kotlin/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/go/commands/README.md +4 -0
- package/presets/claude/go/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/ios-swift/commands/README.md +4 -0
- package/presets/claude/ios-swift/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/java/commands/README.md +4 -0
- package/presets/claude/java/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/mcp-ts/commands/README.md +4 -0
- package/presets/claude/mcp-ts/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/mol/commands/README.md +4 -0
- package/presets/claude/mol/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/next/commands/README.md +4 -0
- package/presets/claude/next/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/nuxt/commands/README.md +4 -0
- package/presets/claude/nuxt/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/php-hexagonal/commands/README.md +4 -0
- package/presets/claude/php-hexagonal/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/php-laravel/commands/README.md +4 -0
- package/presets/claude/php-laravel/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +15 -1
- package/presets/claude/svelte/commands/README.md +4 -0
- package/presets/claude/svelte/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/android-kotlin/commands/README.md +4 -0
- package/presets/cursor/android-kotlin/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/go/commands/README.md +4 -0
- package/presets/cursor/go/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/ios-swift/commands/README.md +4 -0
- package/presets/cursor/ios-swift/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/java/commands/README.md +4 -0
- package/presets/cursor/java/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/mcp-ts/commands/README.md +4 -0
- package/presets/cursor/mcp-ts/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/mol/commands/README.md +4 -0
- package/presets/cursor/mol/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/next/commands/README.md +4 -0
- package/presets/cursor/next/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/nuxt/commands/README.md +4 -0
- package/presets/cursor/nuxt/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/php-hexagonal/commands/README.md +4 -0
- package/presets/cursor/php-hexagonal/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/php-laravel/commands/README.md +4 -0
- package/presets/cursor/php-laravel/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +15 -1
- package/presets/cursor/svelte/commands/README.md +4 -0
- package/presets/cursor/svelte/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/android-kotlin/adapter-map.json +9 -1
- package/presets/mavis/android-kotlin/commands/README.md +4 -0
- package/presets/mavis/android-kotlin/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/go/adapter-map.json +9 -1
- package/presets/mavis/go/commands/README.md +4 -0
- package/presets/mavis/go/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/ios-swift/adapter-map.json +9 -1
- package/presets/mavis/ios-swift/commands/README.md +4 -0
- package/presets/mavis/ios-swift/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/java/adapter-map.json +9 -1
- package/presets/mavis/java/commands/README.md +4 -0
- package/presets/mavis/java/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/mcp-ts/adapter-map.json +9 -1
- package/presets/mavis/mcp-ts/commands/README.md +4 -0
- package/presets/mavis/mcp-ts/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/mol/adapter-map.json +9 -1
- package/presets/mavis/mol/commands/README.md +4 -0
- package/presets/mavis/mol/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/commands/README.md +4 -0
- package/presets/mavis/next/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/nuxt/adapter-map.json +9 -1
- package/presets/mavis/nuxt/commands/README.md +4 -0
- package/presets/mavis/nuxt/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +9 -1
- package/presets/mavis/php-hexagonal/commands/README.md +4 -0
- package/presets/mavis/php-hexagonal/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/php-laravel/adapter-map.json +9 -1
- package/presets/mavis/php-laravel/commands/README.md +4 -0
- package/presets/mavis/php-laravel/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +15 -1
- package/presets/mavis/svelte/adapter-map.json +9 -1
- package/presets/mavis/svelte/commands/README.md +4 -0
- package/presets/mavis/svelte/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/android-kotlin/adapter-map.json +9 -1
- package/presets/opencode/android-kotlin/commands/README.md +4 -0
- package/presets/opencode/android-kotlin/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/go/adapter-map.json +9 -1
- package/presets/opencode/go/commands/README.md +4 -0
- package/presets/opencode/go/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/ios-swift/adapter-map.json +9 -1
- package/presets/opencode/ios-swift/commands/README.md +4 -0
- package/presets/opencode/ios-swift/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/java/adapter-map.json +9 -1
- package/presets/opencode/java/commands/README.md +4 -0
- package/presets/opencode/java/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/mcp-ts/adapter-map.json +9 -1
- package/presets/opencode/mcp-ts/commands/README.md +4 -0
- package/presets/opencode/mcp-ts/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/mol/adapter-map.json +9 -1
- package/presets/opencode/mol/commands/README.md +4 -0
- package/presets/opencode/mol/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/commands/README.md +4 -0
- package/presets/opencode/next/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/nuxt/adapter-map.json +9 -1
- package/presets/opencode/nuxt/commands/README.md +4 -0
- package/presets/opencode/nuxt/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +9 -1
- package/presets/opencode/php-hexagonal/commands/README.md +4 -0
- package/presets/opencode/php-hexagonal/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/php-laravel/adapter-map.json +9 -1
- package/presets/opencode/php-laravel/commands/README.md +4 -0
- package/presets/opencode/php-laravel/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +15 -1
- package/presets/opencode/plugins/output-guard/README.md +42 -1
- package/presets/opencode/plugins/output-guard/actions.ts +201 -0
- package/presets/opencode/plugins/output-guard/index.ts +147 -6
- package/presets/opencode/svelte/adapter-map.json +9 -1
- package/presets/opencode/svelte/commands/README.md +4 -0
- package/presets/opencode/svelte/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/android-kotlin/adapter-map.json +9 -1
- package/presets/zcode/android-kotlin/commands/README.md +4 -0
- package/presets/zcode/android-kotlin/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/go/adapter-map.json +9 -1
- package/presets/zcode/go/commands/README.md +4 -0
- package/presets/zcode/go/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/ios-swift/adapter-map.json +9 -1
- package/presets/zcode/ios-swift/commands/README.md +4 -0
- package/presets/zcode/ios-swift/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/java/adapter-map.json +9 -1
- package/presets/zcode/java/commands/README.md +4 -0
- package/presets/zcode/java/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/mcp-ts/adapter-map.json +9 -1
- package/presets/zcode/mcp-ts/commands/README.md +4 -0
- package/presets/zcode/mcp-ts/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/mol/adapter-map.json +9 -1
- package/presets/zcode/mol/commands/README.md +4 -0
- package/presets/zcode/mol/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/commands/README.md +4 -0
- package/presets/zcode/next/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/nuxt/adapter-map.json +9 -1
- package/presets/zcode/nuxt/commands/README.md +4 -0
- package/presets/zcode/nuxt/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/php-hexagonal/adapter-map.json +9 -1
- package/presets/zcode/php-hexagonal/commands/README.md +4 -0
- package/presets/zcode/php-hexagonal/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/php-laravel/adapter-map.json +9 -1
- package/presets/zcode/php-laravel/commands/README.md +4 -0
- package/presets/zcode/php-laravel/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +15 -1
- package/presets/zcode/svelte/adapter-map.json +9 -1
- package/presets/zcode/svelte/commands/README.md +4 -0
- package/presets/zcode/svelte/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +15 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -76,12 +76,26 @@ function readSessionLease(id) {
|
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
80
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
81
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
82
|
+
// starts over instead of claiming an ancient first sighting.
|
|
83
|
+
function firstSeenAtOf(file, value, now) {
|
|
84
|
+
try {
|
|
85
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
86
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
87
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
88
|
+
} catch {}
|
|
89
|
+
return now;
|
|
90
|
+
}
|
|
79
91
|
function writeSessionLease(id, value) {
|
|
80
92
|
try {
|
|
81
93
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
82
94
|
const file = sessionLeasePath(id);
|
|
83
95
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
84
|
-
|
|
96
|
+
const now = new Date().toISOString();
|
|
97
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
98
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
85
99
|
fs.renameSync(temporary, file);
|
|
86
100
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
87
101
|
if (!name.endsWith('.json')) continue;
|
|
@@ -49,3 +49,7 @@ Slash commands are copied to `.claude/commands/` on `ai-rules init claude --pres
|
|
|
49
49
|
- Hooks: `../hooks/chain-team-phases.sh` (no `hooks.json` on Claude)
|
|
50
50
|
|
|
51
51
|
Create and edit commands in this preset folder (Claude Code slash commands).
|
|
52
|
+
|
|
53
|
+
## Scheduler
|
|
54
|
+
|
|
55
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -75,12 +75,26 @@ function readSessionLease(id) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
79
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
80
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
81
|
+
// starts over instead of claiming an ancient first sighting.
|
|
82
|
+
function firstSeenAtOf(file, value, now) {
|
|
83
|
+
try {
|
|
84
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
85
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
86
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
87
|
+
} catch {}
|
|
88
|
+
return now;
|
|
89
|
+
}
|
|
78
90
|
function writeSessionLease(id, value) {
|
|
79
91
|
try {
|
|
80
92
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
81
93
|
const file = sessionLeasePath(id);
|
|
82
94
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
83
|
-
|
|
95
|
+
const now = new Date().toISOString();
|
|
96
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
97
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
84
98
|
fs.renameSync(temporary, file);
|
|
85
99
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
86
100
|
if (!name.endsWith('.json')) continue;
|
|
@@ -11,3 +11,7 @@ Slash-command and on-demand scenario definitions. Copied to `.claude/commands/`
|
|
|
11
11
|
| `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
|
|
12
12
|
|
|
13
13
|
See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
|
|
14
|
+
|
|
15
|
+
## Scheduler
|
|
16
|
+
|
|
17
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -76,12 +76,26 @@ function readSessionLease(id) {
|
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
80
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
81
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
82
|
+
// starts over instead of claiming an ancient first sighting.
|
|
83
|
+
function firstSeenAtOf(file, value, now) {
|
|
84
|
+
try {
|
|
85
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
86
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
87
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
88
|
+
} catch {}
|
|
89
|
+
return now;
|
|
90
|
+
}
|
|
79
91
|
function writeSessionLease(id, value) {
|
|
80
92
|
try {
|
|
81
93
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
82
94
|
const file = sessionLeasePath(id);
|
|
83
95
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
84
|
-
|
|
96
|
+
const now = new Date().toISOString();
|
|
97
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
98
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
85
99
|
fs.renameSync(temporary, file);
|
|
86
100
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
87
101
|
if (!name.endsWith('.json')) continue;
|
|
@@ -9,3 +9,7 @@ Slash commands are copied to `.cursor/commands/` (Cursor) or `.claude/commands/`
|
|
|
9
9
|
| `/technical-retro` | Retro |
|
|
10
10
|
| `update.md` | Reinstall each installed tool with the preset recorded at init |
|
|
11
11
|
| `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
|
|
12
|
+
|
|
13
|
+
## Scheduler
|
|
14
|
+
|
|
15
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -78,12 +78,26 @@ function readSessionLease(id) {
|
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
82
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
83
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
84
|
+
// starts over instead of claiming an ancient first sighting.
|
|
85
|
+
function firstSeenAtOf(file, value, now) {
|
|
86
|
+
try {
|
|
87
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
88
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
89
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
90
|
+
} catch {}
|
|
91
|
+
return now;
|
|
92
|
+
}
|
|
81
93
|
function writeSessionLease(id, value) {
|
|
82
94
|
try {
|
|
83
95
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
84
96
|
const file = sessionLeasePath(id);
|
|
85
97
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
86
|
-
|
|
98
|
+
const now = new Date().toISOString();
|
|
99
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
100
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
87
101
|
fs.renameSync(temporary, file);
|
|
88
102
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
89
103
|
if (!name.endsWith('.json')) continue;
|
|
@@ -54,3 +54,7 @@ On OpenCode, `/task-evil` runs as the `task-evil` primary agent: the `question`
|
|
|
54
54
|
- Hooks: `../hooks.json`, `../hooks/chain-team-phases.sh`
|
|
55
55
|
|
|
56
56
|
Create and edit commands via `/commands` in Cursor or directly in this preset folder.
|
|
57
|
+
|
|
58
|
+
## Scheduler
|
|
59
|
+
|
|
60
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -75,12 +75,26 @@ function readSessionLease(id) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
79
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
80
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
81
|
+
// starts over instead of claiming an ancient first sighting.
|
|
82
|
+
function firstSeenAtOf(file, value, now) {
|
|
83
|
+
try {
|
|
84
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
85
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
86
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
87
|
+
} catch {}
|
|
88
|
+
return now;
|
|
89
|
+
}
|
|
78
90
|
function writeSessionLease(id, value) {
|
|
79
91
|
try {
|
|
80
92
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
81
93
|
const file = sessionLeasePath(id);
|
|
82
94
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
83
|
-
|
|
95
|
+
const now = new Date().toISOString();
|
|
96
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
97
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
84
98
|
fs.renameSync(temporary, file);
|
|
85
99
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
86
100
|
if (!name.endsWith('.json')) continue;
|
|
@@ -20,3 +20,7 @@ See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
|
|
|
20
20
|
|
|
21
21
|
- **`/ui-start`** — stop the running `team-tasks-ui` stack, run `team-db.mjs migrate-tasks`, then rebuild and start it.
|
|
22
22
|
- **`/ui-stop`** — stop the `team-tasks-ui` stack and the team-db API that `/ui-start` started.
|
|
23
|
+
|
|
24
|
+
## Scheduler
|
|
25
|
+
|
|
26
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -75,12 +75,26 @@ function readSessionLease(id) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
79
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
80
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
81
|
+
// starts over instead of claiming an ancient first sighting.
|
|
82
|
+
function firstSeenAtOf(file, value, now) {
|
|
83
|
+
try {
|
|
84
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
85
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
86
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
87
|
+
} catch {}
|
|
88
|
+
return now;
|
|
89
|
+
}
|
|
78
90
|
function writeSessionLease(id, value) {
|
|
79
91
|
try {
|
|
80
92
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
81
93
|
const file = sessionLeasePath(id);
|
|
82
94
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
83
|
-
|
|
95
|
+
const now = new Date().toISOString();
|
|
96
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
97
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
84
98
|
fs.renameSync(temporary, file);
|
|
85
99
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
86
100
|
if (!name.endsWith('.json')) continue;
|
|
@@ -49,3 +49,7 @@ Slash commands are copied to `.claude/commands/` on `ai-rules init claude --pres
|
|
|
49
49
|
- Hooks: `../hooks/chain-team-phases.sh` (no `hooks.json` on Claude)
|
|
50
50
|
|
|
51
51
|
Create and edit commands via Claude Code slash commands or directly in this preset folder.
|
|
52
|
+
|
|
53
|
+
## Scheduler
|
|
54
|
+
|
|
55
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -75,12 +75,26 @@ function readSessionLease(id) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
79
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
80
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
81
|
+
// starts over instead of claiming an ancient first sighting.
|
|
82
|
+
function firstSeenAtOf(file, value, now) {
|
|
83
|
+
try {
|
|
84
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
85
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
86
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
87
|
+
} catch {}
|
|
88
|
+
return now;
|
|
89
|
+
}
|
|
78
90
|
function writeSessionLease(id, value) {
|
|
79
91
|
try {
|
|
80
92
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
81
93
|
const file = sessionLeasePath(id);
|
|
82
94
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
83
|
-
|
|
95
|
+
const now = new Date().toISOString();
|
|
96
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
97
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
84
98
|
fs.renameSync(temporary, file);
|
|
85
99
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
86
100
|
if (!name.endsWith('.json')) continue;
|
|
@@ -11,3 +11,7 @@ Slash-command definitions and on-demand scenarios. Copied to `.claude/commands/`
|
|
|
11
11
|
| `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
|
|
12
12
|
|
|
13
13
|
See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
|
|
14
|
+
|
|
15
|
+
## Scheduler
|
|
16
|
+
|
|
17
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -77,12 +77,26 @@ function readSessionLease(id) {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
81
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
82
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
83
|
+
// starts over instead of claiming an ancient first sighting.
|
|
84
|
+
function firstSeenAtOf(file, value, now) {
|
|
85
|
+
try {
|
|
86
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
87
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
88
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
89
|
+
} catch {}
|
|
90
|
+
return now;
|
|
91
|
+
}
|
|
80
92
|
function writeSessionLease(id, value) {
|
|
81
93
|
try {
|
|
82
94
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
83
95
|
const file = sessionLeasePath(id);
|
|
84
96
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
85
|
-
|
|
97
|
+
const now = new Date().toISOString();
|
|
98
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
99
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
86
100
|
fs.renameSync(temporary, file);
|
|
87
101
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
88
102
|
if (!name.endsWith('.json')) continue;
|
|
@@ -11,3 +11,7 @@ Slash-command and on-demand scenario definitions. Copied to `.claude/commands/`
|
|
|
11
11
|
| `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
|
|
12
12
|
|
|
13
13
|
See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
|
|
14
|
+
|
|
15
|
+
## Scheduler
|
|
16
|
+
|
|
17
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -77,12 +77,26 @@ function readSessionLease(id) {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
81
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
82
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
83
|
+
// starts over instead of claiming an ancient first sighting.
|
|
84
|
+
function firstSeenAtOf(file, value, now) {
|
|
85
|
+
try {
|
|
86
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
87
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
88
|
+
if (previous && previous.slug === value && typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
89
|
+
} catch {}
|
|
90
|
+
return now;
|
|
91
|
+
}
|
|
80
92
|
function writeSessionLease(id, value) {
|
|
81
93
|
try {
|
|
82
94
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
83
95
|
const file = sessionLeasePath(id);
|
|
84
96
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
85
|
-
|
|
97
|
+
const now = new Date().toISOString();
|
|
98
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
99
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
86
100
|
fs.renameSync(temporary, file);
|
|
87
101
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
88
102
|
if (!name.endsWith('.json')) continue;
|
|
@@ -49,3 +49,7 @@ Slash commands are copied to `.claude/commands/` on `ai-rules init claude --pres
|
|
|
49
49
|
- Hooks: `../hooks/chain-team-phases.sh` (no `hooks.json` on Claude)
|
|
50
50
|
|
|
51
51
|
Create and edit commands via Claude Code slash commands or directly in this preset folder.
|
|
52
|
+
|
|
53
|
+
## Scheduler
|
|
54
|
+
|
|
55
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|