pi-taskflow 0.0.11 → 0.0.13
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/README.md +274 -6
- package/extensions/agents/analyst.md +30 -0
- package/extensions/agents/critic.md +31 -0
- package/extensions/agents/doc-writer.md +43 -0
- package/extensions/agents/executor-code.md +36 -0
- package/extensions/agents/executor-fast.md +26 -0
- package/extensions/agents/executor-ui.md +35 -0
- package/extensions/agents/executor.md +29 -0
- package/extensions/agents/final-arbiter.md +29 -0
- package/extensions/agents/plan-arbiter.md +35 -0
- package/extensions/agents/planner.md +30 -0
- package/extensions/agents/recover.md +28 -0
- package/extensions/agents/reviewer.md +37 -0
- package/extensions/agents/risk-reviewer.md +37 -0
- package/extensions/agents/scout.md +51 -0
- package/extensions/agents/security-reviewer.md +39 -0
- package/extensions/agents/test-engineer.md +31 -0
- package/extensions/agents/verifier.md +29 -0
- package/extensions/agents/visual-explorer.md +32 -0
- package/extensions/agents.ts +33 -2
- package/extensions/cache.ts +263 -0
- package/extensions/index.ts +201 -10
- package/extensions/init.ts +607 -0
- package/extensions/render.ts +39 -0
- package/extensions/runtime.ts +342 -17
- package/extensions/schema.ts +166 -1
- package/extensions/store.ts +16 -2
- package/package.json +4 -3
package/extensions/store.ts
CHANGED
|
@@ -40,6 +40,10 @@ export interface PhaseState {
|
|
|
40
40
|
model?: string;
|
|
41
41
|
error?: string;
|
|
42
42
|
inputHash?: string;
|
|
43
|
+
/** When this result was served from cache: 'cross-run' for the persistent
|
|
44
|
+
* cross-run store. (Within-run resume reuses prior state verbatim and is not
|
|
45
|
+
* flagged here.) */
|
|
46
|
+
cacheHit?: "cross-run";
|
|
43
47
|
startedAt?: number;
|
|
44
48
|
endedAt?: number;
|
|
45
49
|
/** Live fan-out progress for map/parallel phases. */
|
|
@@ -54,6 +58,10 @@ export interface PhaseState {
|
|
|
54
58
|
budgetTruncated?: boolean;
|
|
55
59
|
/** Human-in-the-loop outcome (approval phases only). */
|
|
56
60
|
approval?: { decision: "approve" | "reject" | "edit"; note?: string; auto?: boolean };
|
|
61
|
+
/** Loop iteration accounting (loop phases only). */
|
|
62
|
+
loop?: { iterations: number; stop: "until" | "converged" | "maxIterations" | "failed" };
|
|
63
|
+
/** Tournament outcome (tournament phases only). */
|
|
64
|
+
tournament?: { variants: number; winner: number; mode: "best" | "aggregate"; reason?: string };
|
|
57
65
|
/** Non-fatal diagnostic warnings accumulated during this phase (e.g.
|
|
58
66
|
* unresolved interpolation placeholders, suspicious templates). */
|
|
59
67
|
warnings?: string[];
|
|
@@ -249,7 +257,7 @@ function releaseLock(lockPath: string): void {
|
|
|
249
257
|
/**
|
|
250
258
|
* Execute `fn` while holding a file lock. Guarantees release even on throw.
|
|
251
259
|
*/
|
|
252
|
-
function withLock<T>(lockPath: string, fn: () => T): T {
|
|
260
|
+
export function withLock<T>(lockPath: string, fn: () => T): T {
|
|
253
261
|
acquireLock(lockPath);
|
|
254
262
|
try {
|
|
255
263
|
return fn();
|
|
@@ -560,6 +568,12 @@ function runsDir(cwd: string): string {
|
|
|
560
568
|
return path.join(projDir, "runs");
|
|
561
569
|
}
|
|
562
570
|
|
|
571
|
+
/** Root dir for the cross-run memoization cache (sibling of `runs`). */
|
|
572
|
+
export function cacheDir(cwd: string): string {
|
|
573
|
+
const projDir = findProjectFlowsDir(cwd, true)!;
|
|
574
|
+
return path.join(projDir, "cache");
|
|
575
|
+
}
|
|
576
|
+
|
|
563
577
|
export function newRunId(flowName: string): string {
|
|
564
578
|
const safe = flowName.replace(/[^\w.-]+/g, "_").slice(0, 24);
|
|
565
579
|
return `${safe}-${Date.now().toString(36)}-${crypto.randomBytes(3).toString("hex")}`;
|
|
@@ -743,7 +757,7 @@ export function hashInput(...parts: string[]): string {
|
|
|
743
757
|
* then rename over the target (rename is atomic on the same filesystem). Prevents
|
|
744
758
|
* a crash or concurrent write from leaving a half-written, corrupt JSON file.
|
|
745
759
|
*/
|
|
746
|
-
function writeFileAtomic(filePath: string, data: string): void {
|
|
760
|
+
export function writeFileAtomic(filePath: string, data: string): void {
|
|
747
761
|
// Ensure parent directory exists.
|
|
748
762
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
749
763
|
const tmp = `${filePath}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-taskflow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Lightweight workflow orchestration for the Pi coding agent — declarative multi-phase taskflows with dynamic fan-out, isolated subagent context, resumable runs, and saveable commands.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"test": "node --experimental-strip-types --test test/interpolate.test.ts test/condition.test.ts test/schema.test.ts test/usage.test.ts test/runtime.test.ts test/features.test.ts test/runner.test.ts test/store.test.ts test/agents.test.ts test/render.test.ts test/desugar.test.ts",
|
|
40
|
-
"test:e2e": "PI_TASKFLOW_PI_BIN=pi node --experimental-strip-types test/e2e.mts"
|
|
39
|
+
"test": "PI_TASKFLOW_BUILTIN_AGENTS_DIR= node --experimental-strip-types --test test/interpolate.test.ts test/condition.test.ts test/schema.test.ts test/usage.test.ts test/runtime.test.ts test/features.test.ts test/runner.test.ts test/store.test.ts test/agents.test.ts test/init.test.ts test/render.test.ts test/desugar.test.ts test/cache.test.ts test/loop.test.ts test/tournament.test.ts",
|
|
40
|
+
"test:e2e": "PI_TASKFLOW_PI_BIN=pi node --experimental-strip-types test/e2e.mts",
|
|
41
|
+
"test:dogfood-cache": "node --experimental-strip-types test/dogfood-cache.mts"
|
|
41
42
|
},
|
|
42
43
|
"pi": {
|
|
43
44
|
"extensions": [
|