pi-long-task 0.3.9 → 0.3.10
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 +219 -5
- package/package.json +1 -1
- package/src/coordinator.ts +33 -7
- package/src/coverage_goal.ts +90 -0
- package/src/goal_discovery.ts +739 -0
- package/src/goal_loop.ts +567 -0
- package/src/goal_orchestrator.ts +396 -0
- package/src/goal_review.ts +575 -0
- package/src/goal_spec.ts +670 -0
- package/src/goal_state.ts +227 -0
- package/src/goal_todo_execution.ts +309 -0
- package/src/goal_todo_generation.ts +539 -0
- package/src/index.ts +89 -2
- package/src/input_router.ts +124 -6
- package/src/render.ts +223 -4
- package/src/todo_generator.ts +135 -7
- package/src/types.ts +66 -3
- package/src/worker_session.ts +23 -2
package/src/types.ts
CHANGED
|
@@ -6,18 +6,80 @@ import type { SessionOutcome } from "./worker_session.ts";
|
|
|
6
6
|
|
|
7
7
|
export const PiLongTaskParams = Type.Object(
|
|
8
8
|
{
|
|
9
|
-
inputText: Type.
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
inputText: Type.Optional(
|
|
10
|
+
Type.String({
|
|
11
|
+
description:
|
|
12
|
+
"Optional TODO file content or the user's long-task instructions to process. Natural-language routing parses commit and goal separately.",
|
|
13
|
+
}),
|
|
14
|
+
),
|
|
12
15
|
commit: Type.Boolean({
|
|
13
16
|
description:
|
|
14
17
|
"Whether Pi Long Task may commit completed worker changes. Use true when the user asks for commits or committing as work progresses; otherwise use false.",
|
|
15
18
|
}),
|
|
19
|
+
goal: Type.Optional(
|
|
20
|
+
Type.String({
|
|
21
|
+
description: "Optional high-level goal or desired outcome for the long-task run.",
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
{ additionalProperties: false },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const PiGoalTaskParams = Type.Object(
|
|
29
|
+
{
|
|
30
|
+
goal: Type.String({
|
|
31
|
+
description:
|
|
32
|
+
"High-level goal to achieve through repeated TODO generation, long-task execution, and reviewer iterations until complete or stopped by limits.",
|
|
33
|
+
}),
|
|
34
|
+
commit: Type.Optional(
|
|
35
|
+
Type.Boolean({
|
|
36
|
+
description:
|
|
37
|
+
"Whether worker long tasks may commit completed TODO work during the goal loop. Defaults to true for goal loops.",
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
maxIterations: Type.Optional(
|
|
41
|
+
Type.Integer({
|
|
42
|
+
minimum: 1,
|
|
43
|
+
description: "Maximum number of generate → execute → review iterations before stopping. Defaults to 50.",
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
timeoutMs: Type.Optional(
|
|
47
|
+
Type.Integer({
|
|
48
|
+
minimum: 1,
|
|
49
|
+
description: "Overall goal-loop timeout in milliseconds. Defaults to 172800000 (48 hours).",
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
iterationTimeoutMs: Type.Optional(
|
|
53
|
+
Type.Integer({
|
|
54
|
+
minimum: 1,
|
|
55
|
+
description:
|
|
56
|
+
"Timeout budget in milliseconds for each generated TODO worker iteration. Defaults to 10800000 (3 hours).",
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
59
|
+
reviewerTimeoutMs: Type.Optional(
|
|
60
|
+
Type.Integer({
|
|
61
|
+
minimum: 1,
|
|
62
|
+
description: "Timeout budget in milliseconds for each reviewer session. Defaults to 1800000 (30 minutes).",
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
maxAttemptsPerTask: Type.Optional(
|
|
66
|
+
Type.Integer({
|
|
67
|
+
minimum: 1,
|
|
68
|
+
description: "Maximum attempts for each TODO inside worker long-task runs.",
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
maxBashTimeoutMs: Type.Optional(
|
|
72
|
+
Type.Integer({
|
|
73
|
+
minimum: 1,
|
|
74
|
+
description: "Maximum bash command timeout in milliseconds allowed in worker sessions.",
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
16
77
|
},
|
|
17
78
|
{ additionalProperties: false },
|
|
18
79
|
);
|
|
19
80
|
|
|
20
81
|
export type PiLongTaskInput = Static<typeof PiLongTaskParams>;
|
|
82
|
+
export type PiGoalTaskInput = Static<typeof PiGoalTaskParams>;
|
|
21
83
|
|
|
22
84
|
export type CoordinatorStatus = "done" | "partial" | "blocked" | "failed";
|
|
23
85
|
|
|
@@ -64,5 +126,6 @@ export interface PiLongTaskResult {
|
|
|
64
126
|
taskProgress: TaskProgressModel;
|
|
65
127
|
workerCostTotal: number;
|
|
66
128
|
commit: boolean;
|
|
129
|
+
goal?: string;
|
|
67
130
|
error?: string;
|
|
68
131
|
}
|
package/src/worker_session.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { coverageGoalAction, coverageGoalVerification, parseCoverageGoal } from "./coverage_goal.ts";
|
|
1
2
|
import { hasTaskResult, hasTaskResultStatus, isDoneStatus, parseReportedStatus } from "./result_writer.ts";
|
|
2
3
|
import type { Task } from "./todo_parser.ts";
|
|
3
4
|
|
|
@@ -8,6 +9,7 @@ export interface WorkerTaskPromptOptions {
|
|
|
8
9
|
commitRequested: boolean;
|
|
9
10
|
previousAttempts?: string;
|
|
10
11
|
globalInstructions?: string;
|
|
12
|
+
goal?: string;
|
|
11
13
|
maxBashTimeoutSeconds: number;
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -22,7 +24,7 @@ export function taskLabel(task: Pick<Task, "taskId" | "title">): string {
|
|
|
22
24
|
|
|
23
25
|
export function buildTaskPrompt(options: WorkerTaskPromptOptions): string {
|
|
24
26
|
const commitText = options.commitRequested
|
|
25
|
-
? "Pi Long Task will commit after your session if needed. Do not run git commit."
|
|
27
|
+
? "Commit mode is enabled: complete your assigned work and report status accurately; Pi Long Task will commit eligible completed work after your session if needed. Do not run git commit."
|
|
26
28
|
: "Do not run git commit. Pi Long Task was started with commits disabled.";
|
|
27
29
|
|
|
28
30
|
const previousAttempts = (options.previousAttempts || "").trim();
|
|
@@ -47,11 +49,30 @@ ${globalInstructions}
|
|
|
47
49
|
`
|
|
48
50
|
: "";
|
|
49
51
|
|
|
52
|
+
const goal = (options.goal || "").trim();
|
|
53
|
+
const coverageGoal = parseCoverageGoal(goal);
|
|
54
|
+
const coverageGoalText = coverageGoal
|
|
55
|
+
? `
|
|
56
|
+
|
|
57
|
+
Coverage goal guidance:
|
|
58
|
+
- ${coverageGoalAction(coverageGoal)}
|
|
59
|
+
- ${coverageGoalVerification(coverageGoal)} Prefer the project-specific coverage script when available (for example, \`npm run test:coverage\`, \`npm run coverage\`, or \`npm test -- --coverage\`).`
|
|
60
|
+
: "";
|
|
61
|
+
const goalText = goal
|
|
62
|
+
? `
|
|
63
|
+
|
|
64
|
+
Long task goal:
|
|
65
|
+
|
|
66
|
+
\`\`\`text
|
|
67
|
+
${goal}
|
|
68
|
+
\`\`\`${coverageGoalText}`
|
|
69
|
+
: "";
|
|
70
|
+
|
|
50
71
|
return `You are one Pi SDK worker session assigned to exactly one TODO task.
|
|
51
72
|
|
|
52
73
|
Assigned TODO file path: \`${options.todoPath}\`
|
|
53
74
|
Assigned task: \`${taskLabel(options.task)}\`
|
|
54
|
-
Attempt: ${options.attempt}
|
|
75
|
+
Attempt: ${options.attempt}${goalText}
|
|
55
76
|
|
|
56
77
|
Rules:
|
|
57
78
|
- Work only on the assigned task below. Do not start or fix other TODO tasks.
|