@justjoshn/pi-pstack 0.15.36-pi.1 → 0.15.36-pi.7
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 +39 -0
- package/README.md +15 -12
- package/agents/ci-watcher.md +27 -0
- package/agents/thermo-nuclear-code-quality-review.md +23 -0
- package/assets/logo.png +0 -0
- package/automations/benny/FOR_AGENTS.md +1 -1
- package/automations/benny/README.md +2 -2
- package/automations/benny/skills/setup-benny/SKILL.md +5 -5
- package/bin/pstack-routines-supervisor +9 -0
- package/docs/guide/07-overnight.md +1 -1
- package/docs/guide/09-make-it-yours.md +1 -1
- package/docs/guide/10-recipes-and-pitfalls.md +1 -1
- package/docs/native-gaps.md +11 -5
- package/docs/parity-reverse-engineering.md +94 -0
- package/package.json +41 -6
- package/packaging/install-supervisor-unit.sh +164 -0
- package/packaging/launchd/com.pstack.routines-supervisor.plist.example +24 -0
- package/packaging/systemd/pstack-routines-supervisor.service.example +15 -0
- package/skills/architect/SKILL.md +1 -1
- package/skills/architect/references/runner-prompt.md +1 -1
- package/skills/arena/SKILL.md +3 -3
- package/skills/check-compiler-errors/SKILL.md +23 -0
- package/skills/create-skill/SKILL.md +515 -29
- package/skills/fix-ci/SKILL.md +29 -0
- package/skills/fix-merge-conflicts/SKILL.md +32 -0
- package/skills/get-pr-comments/SKILL.md +23 -0
- package/skills/how/SKILL.md +1 -1
- package/skills/ketchup-video/SKILL.md +2 -2
- package/skills/loop-on-ci/SKILL.md +50 -0
- package/skills/make-bot-ui/SKILL.md +2 -2
- package/skills/make-pr-easy-to-review/SKILL.md +59 -0
- package/skills/new-branch-and-pr/SKILL.md +29 -0
- package/skills/no-inline-imports/SKILL.md +12 -0
- package/skills/poteto-help/SKILL.md +4 -4
- package/skills/poteto-mode/playbooks/multi-phase-plan.md +1 -1
- package/skills/poteto-mode/playbooks/orchestrate.md +1 -1
- package/skills/pr-review-canvas/SKILL.md +176 -0
- package/skills/pr-review-canvas/renderer.js +170 -0
- package/skills/pr-review-canvas/styles.css +96 -0
- package/skills/pr-review-canvas/template.html +18 -0
- package/skills/reflect/SKILL.md +1 -1
- package/skills/review-and-ship/SKILL.md +41 -0
- package/skills/run-smoke-tests/SKILL.md +42 -0
- package/skills/statechart/scripts/test/cli.test.ts +1 -1
- package/skills/swarm/SKILL.md +2 -2
- package/skills/thermo-nuclear-code-quality-review/SKILL.md +192 -0
- package/skills/typescript-exhaustive-switch/SKILL.md +10 -0
- package/skills/verify-this/SKILL.md +74 -0
- package/skills/weekly-review/SKILL.md +32 -0
- package/skills/what-did-i-get-done/SKILL.md +31 -0
- package/skills/why/SKILL.md +1 -1
- package/skills/workflow-from-chats/SKILL.md +50 -0
- package/src/mode.ts +3 -3
- package/src/paths.ts +13 -0
- package/src/pi-command.ts +12 -0
- package/src/rule.ts +4 -4
- package/src/sections.ts +2 -1
- package/src/subscriptions/durable-store.ts +482 -0
- package/src/subscriptions/durable-types.ts +41 -0
- package/src/subscriptions/ensure-supervisor.ts +67 -0
- package/src/subscriptions/index.ts +231 -271
- package/src/subscriptions/supervisor-main.ts +88 -0
- package/src/subscriptions/supervisor.ts +271 -0
- package/src/subscriptions/webhook.ts +22 -9
- package/src/task/card.ts +29 -0
- package/src/task/records.ts +3 -8
- package/src/task/runner.ts +9 -14
- package/src/task/tool.ts +18 -21
- package/src/todo.ts +1 -2
- package/scripts/live-e2e.mjs +0 -257
- package/test/aliases.test.ts +0 -57
- package/test/ask.test.ts +0 -85
- package/test/autocomplete.test.ts +0 -39
- package/test/e2e/aliases.e2e.test.ts +0 -81
- package/test/e2e/ask.e2e.test.ts +0 -135
- package/test/e2e/harness.ts +0 -179
- package/test/e2e/host.e2e.test.ts +0 -193
- package/test/e2e/lifecycle.e2e.test.ts +0 -99
- package/test/e2e/mode.e2e.test.ts +0 -160
- package/test/e2e/package.e2e.test.ts +0 -67
- package/test/e2e/task.e2e.test.ts +0 -734
- package/test/e2e/todo.e2e.test.ts +0 -59
- package/test/fixtures/cursor-askquestion-calls.json +0 -806
- package/test/fixtures/fake-pi.mjs +0 -96
- package/test/fixtures/image-model.ts +0 -16
- package/test/fixtures/list-models.ts +0 -15
- package/test/fixtures/readonly-shell-exit.ts +0 -17
- package/test/fixtures/scripted-model.ts +0 -113
- package/test/loop.test.ts +0 -209
- package/test/mode.test.ts +0 -143
- package/test/plan.test.ts +0 -126
- package/test/readonly-shell-security.test.ts +0 -84
- package/test/readonly-shell.test.ts +0 -44
- package/test/records.test.ts +0 -143
- package/test/registry.test.ts +0 -18
- package/test/resources.test.ts +0 -162
- package/test/rule.test.ts +0 -92
- package/test/scripts.test.ts +0 -182
- package/test/sections.test.ts +0 -56
- package/test/subscriptions-cron.test.ts +0 -60
- package/test/subscriptions.test.ts +0 -598
- package/test/task-agents.test.ts +0 -49
- package/test/task-card.test.ts +0 -34
- package/test/task-fork.test.ts +0 -233
- package/test/task-format.test.ts +0 -65
- package/test/task-model.test.ts +0 -141
- package/test/task-runner.test.ts +0 -259
- package/test/task-schema.test.ts +0 -50
- package/test/task-status.test.ts +0 -155
- package/test/task-worktree.test.ts +0 -106
- package/test/todo.test.ts +0 -74
- package/test/visualize.test.ts +0 -152
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -16
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
import { piCommand } from '../pi-command.ts';
|
|
6
|
+
import { isSupervisorLive, readArm, readRegistry } from './durable-store.ts';
|
|
7
|
+
import type { ArmStatus, StoredSubscription } from './durable-types.ts';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_READY_MS = 2_000;
|
|
10
|
+
const POLL_MS = 50;
|
|
11
|
+
|
|
12
|
+
export function supervisorBinPath(): string {
|
|
13
|
+
return join(dirname(fileURLToPath(import.meta.url)), '../../bin/pstack-routines-supervisor');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type EnsureSupervisorSpawnOptions = {
|
|
17
|
+
/** Concrete port override forwarded as PSTACK_ROUTINES_PORT, including ephemeral port zero. */
|
|
18
|
+
routinesPort?: number;
|
|
19
|
+
/** Bin path override; production leaves this unset. */
|
|
20
|
+
binPath?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Spawns `pstack-routines-supervisor --workspace <cwd>` detached when no live lock exists.
|
|
25
|
+
* Idempotent when the supervisor is already running for that workspace.
|
|
26
|
+
* Spawn errors (missing bin) are swallowed so the interactive Pi process cannot crash.
|
|
27
|
+
*/
|
|
28
|
+
export function defaultEnsureSupervisor(cwd: string, options: EnsureSupervisorSpawnOptions = {}): void {
|
|
29
|
+
if (isSupervisorLive(cwd)) return;
|
|
30
|
+
const env: NodeJS.ProcessEnv = { ...process.env, PI_PSTACK_PI_COMMAND: JSON.stringify(piCommand()) };
|
|
31
|
+
if (options.routinesPort !== undefined) {
|
|
32
|
+
env['PSTACK_ROUTINES_PORT'] = String(options.routinesPort);
|
|
33
|
+
}
|
|
34
|
+
const child = spawn(options.binPath ?? supervisorBinPath(), ['--workspace', cwd], {
|
|
35
|
+
detached: true,
|
|
36
|
+
stdio: 'ignore',
|
|
37
|
+
env,
|
|
38
|
+
});
|
|
39
|
+
child.on('error', () => {
|
|
40
|
+
// Missing bin or other spawn failure: chat falls back to in-process arming.
|
|
41
|
+
});
|
|
42
|
+
child.unref();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Polls until supervisor.lock names a live pid, or the deadline passes. */
|
|
46
|
+
export async function waitForSupervisor(cwd: string, readyMs = DEFAULT_READY_MS, now = Date.now, sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))): Promise<boolean> {
|
|
47
|
+
if (isSupervisorLive(cwd)) return true;
|
|
48
|
+
const deadline = now() + readyMs;
|
|
49
|
+
while (now() < deadline) {
|
|
50
|
+
await sleep(POLL_MS);
|
|
51
|
+
if (isSupervisorLive(cwd)) return true;
|
|
52
|
+
}
|
|
53
|
+
return isSupervisorLive(cwd);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function waitForArm(cwd: string, sub: StoredSubscription, readyMs = DEFAULT_READY_MS): Promise<Extract<ArmStatus, { state: 'ready' }>> {
|
|
57
|
+
const deadline = Date.now() + readyMs;
|
|
58
|
+
for (;;) {
|
|
59
|
+
const current = readRegistry(cwd).subscriptions.find((entry) => entry.id === sub.id);
|
|
60
|
+
if (current?.lifecycle === 'cancelled') throw new Error(`Subscription ${sub.id} was cancelled while arming.`);
|
|
61
|
+
const status = readArm(cwd, sub);
|
|
62
|
+
if (status?.state === 'ready') return status;
|
|
63
|
+
if (status?.state === 'error') throw new Error(`Subscription ${sub.id} could not arm. ${status.message}`);
|
|
64
|
+
if (Date.now() >= deadline) throw new Error(`Subscription ${sub.id} readiness timed out. No matching live supervisor arm.`);
|
|
65
|
+
await new Promise<void>((resolve) => setTimeout(resolve, POLL_MS));
|
|
66
|
+
}
|
|
67
|
+
}
|