pi-loop 0.1.0
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/agents/code-reviewer.md +82 -0
- package/agents/coder.md +82 -0
- package/agents/decomposer.md +55 -0
- package/agents/judge.md +90 -0
- package/agents/review-optimizer.md +44 -0
- package/dist/agents/adapter.d.ts +9 -0
- package/dist/agents/adapter.d.ts.map +1 -0
- package/dist/agents/adapter.js +41 -0
- package/dist/agents/adapter.js.map +1 -0
- package/dist/agents/factory.d.ts +7 -0
- package/dist/agents/factory.d.ts.map +1 -0
- package/dist/agents/factory.js +49 -0
- package/dist/agents/factory.js.map +1 -0
- package/dist/agents/registry.d.ts +4 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +98 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/types.d.ts +21 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +39 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/args.d.ts +38 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +160 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands.d.ts +29 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +362 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/output.d.ts +33 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +99 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +31 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +70 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +41 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +5 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/checkpoint.d.ts +18 -0
- package/dist/core/checkpoint.d.ts.map +1 -0
- package/dist/core/checkpoint.js +32 -0
- package/dist/core/checkpoint.js.map +1 -0
- package/dist/core/judge.d.ts +11 -0
- package/dist/core/judge.d.ts.map +1 -0
- package/dist/core/judge.js +91 -0
- package/dist/core/judge.js.map +1 -0
- package/dist/core/learnings.d.ts +4 -0
- package/dist/core/learnings.d.ts.map +1 -0
- package/dist/core/learnings.js +33 -0
- package/dist/core/learnings.js.map +1 -0
- package/dist/core/orchestrator.d.ts +64 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js +499 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/plan.d.ts +7 -0
- package/dist/core/plan.d.ts.map +1 -0
- package/dist/core/plan.js +15 -0
- package/dist/core/plan.js.map +1 -0
- package/dist/core/readiness-policy.d.ts +11 -0
- package/dist/core/readiness-policy.d.ts.map +1 -0
- package/dist/core/readiness-policy.js +24 -0
- package/dist/core/readiness-policy.js.map +1 -0
- package/dist/core/scheduling-policy.d.ts +9 -0
- package/dist/core/scheduling-policy.d.ts.map +1 -0
- package/dist/core/scheduling-policy.js +56 -0
- package/dist/core/scheduling-policy.js.map +1 -0
- package/dist/core/task-backend.d.ts +55 -0
- package/dist/core/task-backend.d.ts.map +1 -0
- package/dist/core/task-backend.js +76 -0
- package/dist/core/task-backend.js.map +1 -0
- package/dist/core/task-state.d.ts +26 -0
- package/dist/core/task-state.d.ts.map +1 -0
- package/dist/core/task-state.js +182 -0
- package/dist/core/task-state.js.map +1 -0
- package/dist/core/wiring.d.ts +12 -0
- package/dist/core/wiring.d.ts.map +1 -0
- package/dist/core/wiring.js +131 -0
- package/dist/core/wiring.js.map +1 -0
- package/dist/git/conflict.d.ts +6 -0
- package/dist/git/conflict.d.ts.map +1 -0
- package/dist/git/conflict.js +25 -0
- package/dist/git/conflict.js.map +1 -0
- package/dist/git/repo.d.ts +13 -0
- package/dist/git/repo.d.ts.map +1 -0
- package/dist/git/repo.js +74 -0
- package/dist/git/repo.js.map +1 -0
- package/dist/git/same-branch.d.ts +9 -0
- package/dist/git/same-branch.d.ts.map +1 -0
- package/dist/git/same-branch.js +55 -0
- package/dist/git/same-branch.js.map +1 -0
- package/dist/git/worktree.d.ts +14 -0
- package/dist/git/worktree.d.ts.map +1 -0
- package/dist/git/worktree.js +78 -0
- package/dist/git/worktree.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/linear/backend.d.ts +38 -0
- package/dist/integrations/linear/backend.d.ts.map +1 -0
- package/dist/integrations/linear/backend.js +374 -0
- package/dist/integrations/linear/backend.js.map +1 -0
- package/dist/integrations/linear/client.d.ts +19 -0
- package/dist/integrations/linear/client.d.ts.map +1 -0
- package/dist/integrations/linear/client.js +86 -0
- package/dist/integrations/linear/client.js.map +1 -0
- package/dist/integrations/linear/comment-templates.d.ts +14 -0
- package/dist/integrations/linear/comment-templates.d.ts.map +1 -0
- package/dist/integrations/linear/comment-templates.js +50 -0
- package/dist/integrations/linear/comment-templates.js.map +1 -0
- package/dist/integrations/linear/contract.d.ts +15 -0
- package/dist/integrations/linear/contract.d.ts.map +1 -0
- package/dist/integrations/linear/contract.js +86 -0
- package/dist/integrations/linear/contract.js.map +1 -0
- package/dist/integrations/linear/types.d.ts +39 -0
- package/dist/integrations/linear/types.d.ts.map +1 -0
- package/dist/integrations/linear/types.js +2 -0
- package/dist/integrations/linear/types.js.map +1 -0
- package/dist/swarm/pool.d.ts +33 -0
- package/dist/swarm/pool.d.ts.map +1 -0
- package/dist/swarm/pool.js +182 -0
- package/dist/swarm/pool.js.map +1 -0
- package/dist/swarm/scheduler.d.ts +38 -0
- package/dist/swarm/scheduler.d.ts.map +1 -0
- package/dist/swarm/scheduler.js +191 -0
- package/dist/swarm/scheduler.js.map +1 -0
- package/dist/swarm/worker.d.ts +49 -0
- package/dist/swarm/worker.d.ts.map +1 -0
- package/dist/swarm/worker.js +180 -0
- package/dist/swarm/worker.js.map +1 -0
- package/dist/tools/bash-tool.d.ts +24 -0
- package/dist/tools/bash-tool.d.ts.map +1 -0
- package/dist/tools/bash-tool.js +177 -0
- package/dist/tools/bash-tool.js.map +1 -0
- package/dist/tools/file-tools.d.ts +3 -0
- package/dist/tools/file-tools.d.ts.map +1 -0
- package/dist/tools/file-tools.js +68 -0
- package/dist/tools/file-tools.js.map +1 -0
- package/dist/tools/git-tools.d.ts +3 -0
- package/dist/tools/git-tools.d.ts.map +1 -0
- package/dist/tools/git-tools.js +44 -0
- package/dist/tools/git-tools.js.map +1 -0
- package/dist/tools/learnings-tool.d.ts +3 -0
- package/dist/tools/learnings-tool.d.ts.map +1 -0
- package/dist/tools/learnings-tool.js +48 -0
- package/dist/tools/learnings-tool.js.map +1 -0
- package/dist/tools/plan-tool.d.ts +3 -0
- package/dist/tools/plan-tool.d.ts.map +1 -0
- package/dist/tools/plan-tool.js +24 -0
- package/dist/tools/plan-tool.js.map +1 -0
- package/dist/tools/task-tools.d.ts +3 -0
- package/dist/tools/task-tools.d.ts.map +1 -0
- package/dist/tools/task-tools.js +108 -0
- package/dist/tools/task-tools.js.map +1 -0
- package/dist/tools/test-tool.d.ts +3 -0
- package/dist/tools/test-tool.d.ts.map +1 -0
- package/dist/tools/test-tool.js +43 -0
- package/dist/tools/test-tool.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { Type } from "@sinclair/typebox";
|
|
4
|
+
function textResult(text) {
|
|
5
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
6
|
+
}
|
|
7
|
+
export function learningsTools(learningsPath) {
|
|
8
|
+
const readLearningsTool = {
|
|
9
|
+
name: "read_learnings",
|
|
10
|
+
label: "Read Learnings",
|
|
11
|
+
description: "Read the current Learnings.md file containing accumulated insights, patterns, and mistakes discovered during development.",
|
|
12
|
+
parameters: Type.Object({}),
|
|
13
|
+
execute: async () => {
|
|
14
|
+
try {
|
|
15
|
+
const content = await readFile(learningsPath, "utf-8");
|
|
16
|
+
return textResult(content);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return textResult("No learnings recorded yet.");
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const appendLearningsTool = {
|
|
24
|
+
name: "append_learnings",
|
|
25
|
+
label: "Append Learning",
|
|
26
|
+
description: "Append a new learning entry to Learnings.md. Use this to record insights, patterns, mistakes, or useful discoveries.",
|
|
27
|
+
parameters: Type.Object({
|
|
28
|
+
entry: Type.String({ description: "The learning entry to append" }),
|
|
29
|
+
}),
|
|
30
|
+
execute: async (_toolCallId, params) => {
|
|
31
|
+
const { entry } = params;
|
|
32
|
+
let existing = "";
|
|
33
|
+
try {
|
|
34
|
+
existing = await readFile(learningsPath, "utf-8");
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
await mkdir(dirname(learningsPath), { recursive: true });
|
|
38
|
+
existing = "# Learnings\n\n";
|
|
39
|
+
}
|
|
40
|
+
const timestamp = new Date().toISOString();
|
|
41
|
+
const updated = existing.trimEnd() + `\n\n- [${timestamp}] ${entry}`;
|
|
42
|
+
await writeFile(learningsPath, updated + "\n", "utf-8");
|
|
43
|
+
return textResult("Learning recorded.");
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return [readLearningsTool, appendLearningsTool];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=learnings-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learnings-tool.js","sourceRoot":"","sources":["../../src/tools/learnings-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACp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,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACzD,QAAQ,GAAG,iBAAiB,CAAC;YAC9B,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,UAAU,SAAS,KAAK,KAAK,EAAE,CAAC;YACrE,MAAM,SAAS,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;YAExD,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;QACzC,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-tool.d.ts","sourceRoot":"","sources":["../../src/tools/plan-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAM9E,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAiBvD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
function textResult(text) {
|
|
4
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
5
|
+
}
|
|
6
|
+
export function planTools(planPath) {
|
|
7
|
+
const readPlanTool = {
|
|
8
|
+
name: "read_plan",
|
|
9
|
+
label: "Read Plan",
|
|
10
|
+
description: "Read the Plan.md file containing the project plan, goals, architecture decisions, and implementation strategy. This is read-only.",
|
|
11
|
+
parameters: Type.Object({}),
|
|
12
|
+
execute: async () => {
|
|
13
|
+
try {
|
|
14
|
+
const content = await readFile(planPath, "utf-8");
|
|
15
|
+
return textResult(content);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return textResult("Plan.md not found.");
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return [readPlanTool];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=plan-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-tool.js","sourceRoot":"","sources":["../../src/tools/plan-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAgB;IACzC,MAAM,YAAY,GAAc;QAC/B,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,mIAAmI;QAChJ,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,KAAK,IAAI,EAAE;YACnB,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAClD,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,YAAY,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../src/tools/task-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,6BAA6B,CAAC;AAM9E,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CA0HxD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
function textResult(text) {
|
|
4
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
5
|
+
}
|
|
6
|
+
export function taskTools(tasksPath) {
|
|
7
|
+
const readTasksTool = {
|
|
8
|
+
name: "read_tasks",
|
|
9
|
+
label: "Read Tasks",
|
|
10
|
+
description: "Read the current Tasks.md file containing all task definitions, statuses, and dependencies.",
|
|
11
|
+
parameters: Type.Object({}),
|
|
12
|
+
execute: async () => {
|
|
13
|
+
try {
|
|
14
|
+
const content = await readFile(tasksPath, "utf-8");
|
|
15
|
+
return textResult(content);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return textResult("Tasks.md not found or empty.");
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const updateTaskTool = {
|
|
23
|
+
name: "update_task",
|
|
24
|
+
label: "Update Task",
|
|
25
|
+
description: "Update the status of a task in Tasks.md. For rejected tasks, increments attempt count and records the rejection reason.",
|
|
26
|
+
parameters: Type.Object({
|
|
27
|
+
task_id: Type.String({ description: "The task ID (e.g., T-001)" }),
|
|
28
|
+
status: Type.String({ description: "New status: pending, in-progress, done, rejected" }),
|
|
29
|
+
rejection_reason: Type.Optional(Type.String({ description: "Reason for rejection (required when status is 'rejected')" })),
|
|
30
|
+
}),
|
|
31
|
+
execute: async (_toolCallId, params) => {
|
|
32
|
+
const { task_id, status, rejection_reason } = params;
|
|
33
|
+
const content = await readFile(tasksPath, "utf-8");
|
|
34
|
+
const lines = content.split("\n");
|
|
35
|
+
let found = false;
|
|
36
|
+
const updated = lines.map((line) => {
|
|
37
|
+
if (!line.includes(task_id))
|
|
38
|
+
return line;
|
|
39
|
+
found = true;
|
|
40
|
+
let updatedLine = line
|
|
41
|
+
.replace(/\[pending\]/, `[${status}]`)
|
|
42
|
+
.replace(/\[in-progress\]/, `[${status}]`)
|
|
43
|
+
.replace(/\[done\]/, `[${status}]`)
|
|
44
|
+
.replace(/\[rejected\]/, `[${status}]`);
|
|
45
|
+
if (status === "rejected") {
|
|
46
|
+
const attemptMatch = updatedLine.match(/\(attempt (\d+)\)/);
|
|
47
|
+
if (attemptMatch) {
|
|
48
|
+
const nextAttempt = parseInt(attemptMatch[1], 10) + 1;
|
|
49
|
+
updatedLine = updatedLine.replace(/\(attempt \d+\)/, `(attempt ${nextAttempt})`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
updatedLine += " (attempt 1)";
|
|
53
|
+
}
|
|
54
|
+
if (rejection_reason) {
|
|
55
|
+
updatedLine += ` | Rejection: ${rejection_reason}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return updatedLine;
|
|
59
|
+
});
|
|
60
|
+
if (!found) {
|
|
61
|
+
throw new Error(`Task ${task_id} not found in Tasks.md`);
|
|
62
|
+
}
|
|
63
|
+
await writeFile(tasksPath, updated.join("\n"), "utf-8");
|
|
64
|
+
return textResult(`Task ${task_id} updated to '${status}'`);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
const createSubtasksTool = {
|
|
68
|
+
name: "create_subtasks",
|
|
69
|
+
label: "Create Subtasks",
|
|
70
|
+
description: "Create subtasks under a parent task in Tasks.md.",
|
|
71
|
+
parameters: Type.Object({
|
|
72
|
+
parent_id: Type.String({ description: "Parent task ID (e.g., T-001)" }),
|
|
73
|
+
subtasks: Type.Array(Type.Object({
|
|
74
|
+
id: Type.String({ description: "Subtask ID (e.g., T-001-a)" }),
|
|
75
|
+
title: Type.String({ description: "Subtask title" }),
|
|
76
|
+
estimate: Type.String({ description: "Time estimate (e.g., '3min')" }),
|
|
77
|
+
dependencies: Type.Array(Type.String(), { description: "IDs of tasks this depends on" }),
|
|
78
|
+
}), { description: "Array of subtasks to create" }),
|
|
79
|
+
}),
|
|
80
|
+
execute: async (_toolCallId, params) => {
|
|
81
|
+
const { parent_id, subtasks } = params;
|
|
82
|
+
const content = await readFile(tasksPath, "utf-8");
|
|
83
|
+
const lines = content.split("\n");
|
|
84
|
+
let insertIndex = -1;
|
|
85
|
+
for (let i = 0; i < lines.length; i++) {
|
|
86
|
+
if (lines[i].includes(parent_id)) {
|
|
87
|
+
insertIndex = i + 1;
|
|
88
|
+
while (insertIndex < lines.length && lines[insertIndex].match(/^\s{2,}/)) {
|
|
89
|
+
insertIndex++;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (insertIndex === -1) {
|
|
95
|
+
throw new Error(`Parent task ${parent_id} not found in Tasks.md`);
|
|
96
|
+
}
|
|
97
|
+
const subtaskLines = subtasks.map((st) => {
|
|
98
|
+
const deps = st.dependencies.length > 0 ? ` [depends: ${st.dependencies.join(", ")}]` : "";
|
|
99
|
+
return ` - ${st.id} [pending] ${st.title} (~${st.estimate})${deps}`;
|
|
100
|
+
});
|
|
101
|
+
lines.splice(insertIndex, 0, ...subtaskLines);
|
|
102
|
+
await writeFile(tasksPath, lines.join("\n"), "utf-8");
|
|
103
|
+
return textResult(`Created ${subtasks.length} subtasks under ${parent_id}`);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
return [readTasksTool, updateTaskTool, createSubtasksTool];
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=task-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-tools.js","sourceRoot":"","sources":["../../src/tools/task-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC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-tool.d.ts","sourceRoot":"","sources":["../../src/tools/test-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,CA0ClD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
export function testTools(cwd) {
|
|
4
|
+
const runTestsTool = {
|
|
5
|
+
name: "run_tests",
|
|
6
|
+
label: "Run Tests",
|
|
7
|
+
description: "Run the project test suite. Returns stdout, stderr, and exit code. Defaults to 'npm test' if no command is provided.",
|
|
8
|
+
parameters: Type.Object({
|
|
9
|
+
command: Type.Optional(Type.String({ description: "Test command to run (default: 'npm test')" })),
|
|
10
|
+
}),
|
|
11
|
+
execute: async (_toolCallId, params, signal) => {
|
|
12
|
+
const { command: cmd } = params;
|
|
13
|
+
const command = cmd ?? "npm test";
|
|
14
|
+
const parts = command.split(/\s+/);
|
|
15
|
+
const bin = parts[0];
|
|
16
|
+
const args = parts.slice(1);
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const child = execFile(bin, args, { cwd, timeout: 120_000 }, (error, stdout, stderr) => {
|
|
19
|
+
const output = [stdout, stderr].filter(Boolean).join("\n");
|
|
20
|
+
const exitCode = error ? 1 : 0;
|
|
21
|
+
resolve({
|
|
22
|
+
content: [{ type: "text", text: `Exit code: ${exitCode}\n\n${output || "(no output)"}` }],
|
|
23
|
+
details: { exitCode },
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
if (signal) {
|
|
27
|
+
const onAbort = () => {
|
|
28
|
+
child.kill("SIGTERM");
|
|
29
|
+
reject(new Error("Test run aborted"));
|
|
30
|
+
};
|
|
31
|
+
if (signal.aborted) {
|
|
32
|
+
child.kill("SIGTERM");
|
|
33
|
+
reject(new Error("Test run aborted"));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return [runTestsTool];
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=test-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-tool.js","sourceRoot":"","sources":["../../src/tools/test-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,MAAM,YAAY,GAAc;QAC/B,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,sHAAsH;QACnI,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC,CAAC;SACjG,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAA8B,CAAC;YACxD,MAAM,OAAO,GAAG,GAAG,IAAI,UAAU,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACnC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAE5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,O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ker-judge architecture for AI-driven development",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pi-loop": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"lint": "biome check src/",
|
|
24
|
+
"lint:fix": "biome check --write src/",
|
|
25
|
+
"format": "biome format --write src/"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@mariozechner/pi-agent-core": "latest",
|
|
29
|
+
"@mariozechner/pi-ai": "latest",
|
|
30
|
+
"@sinclair/typebox": "^0.34.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@biomejs/biome": "^1.9.0",
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
|
+
"dotenv": "^17.3.1",
|
|
36
|
+
"typescript": "^5.7.0",
|
|
37
|
+
"vitest": "^3.0.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"agents"
|
|
45
|
+
],
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|