@ilya-lesikov/pi-pi 0.4.0 → 0.6.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/3p/pi-ask-user/index.ts +65 -49
- package/3p/pi-subagents/src/agent-manager.ts +8 -0
- package/3p/pi-subagents/src/agent-runner.ts +112 -19
- package/3p/pi-subagents/src/index.ts +3 -0
- package/extensions/orchestrator/agents/brainstorm-reviewer.ts +32 -19
- package/extensions/orchestrator/agents/code-reviewer.ts +31 -17
- package/extensions/orchestrator/agents/constraints.ts +55 -0
- package/extensions/orchestrator/agents/explore.ts +13 -13
- package/extensions/orchestrator/agents/librarian.ts +12 -9
- package/extensions/orchestrator/agents/plan-reviewer.ts +31 -19
- package/extensions/orchestrator/agents/planner.ts +28 -23
- package/extensions/orchestrator/agents/registry.ts +2 -1
- package/extensions/orchestrator/agents/repo-context.ts +11 -0
- package/extensions/orchestrator/agents/task.ts +14 -11
- package/extensions/orchestrator/agents/tool-routing.ts +17 -32
- package/extensions/orchestrator/ast-search.ts +2 -1
- package/extensions/orchestrator/cbm.test.ts +35 -0
- package/extensions/orchestrator/cbm.ts +43 -13
- package/extensions/orchestrator/command-handlers.test.ts +390 -19
- package/extensions/orchestrator/command-handlers.ts +73 -31
- package/extensions/orchestrator/commands.test.ts +255 -2
- package/extensions/orchestrator/commands.ts +108 -10
- package/extensions/orchestrator/config.test.ts +289 -68
- package/extensions/orchestrator/config.ts +630 -121
- package/extensions/orchestrator/context.test.ts +177 -10
- package/extensions/orchestrator/context.ts +115 -14
- package/extensions/orchestrator/custom-footer.ts +2 -1
- package/extensions/orchestrator/doctor.test.ts +559 -0
- package/extensions/orchestrator/doctor.ts +664 -0
- package/extensions/orchestrator/event-handlers.test.ts +84 -22
- package/extensions/orchestrator/event-handlers.ts +1191 -360
- package/extensions/orchestrator/exa.test.ts +46 -0
- package/extensions/orchestrator/exa.ts +16 -10
- package/extensions/orchestrator/flant-infra.test.ts +224 -0
- package/extensions/orchestrator/flant-infra.ts +110 -41
- package/extensions/orchestrator/index.ts +13 -2
- package/extensions/orchestrator/integration.test.ts +2866 -118
- package/extensions/orchestrator/log.test.ts +219 -0
- package/extensions/orchestrator/log.ts +153 -0
- package/extensions/orchestrator/model-registry.test.ts +238 -0
- package/extensions/orchestrator/model-registry.ts +282 -0
- package/extensions/orchestrator/model-version.test.ts +27 -0
- package/extensions/orchestrator/model-version.ts +19 -0
- package/extensions/orchestrator/orchestrator.test.ts +206 -56
- package/extensions/orchestrator/orchestrator.ts +295 -148
- package/extensions/orchestrator/phases/brainstorm.test.ts +10 -7
- package/extensions/orchestrator/phases/brainstorm.ts +41 -35
- package/extensions/orchestrator/phases/implementation.ts +7 -11
- package/extensions/orchestrator/phases/machine.test.ts +27 -8
- package/extensions/orchestrator/phases/machine.ts +13 -0
- package/extensions/orchestrator/phases/planning.ts +57 -29
- package/extensions/orchestrator/phases/review-task.ts +3 -3
- package/extensions/orchestrator/phases/review.ts +38 -39
- package/extensions/orchestrator/phases/spawn-blocking.test.ts +69 -0
- package/extensions/orchestrator/phases/verdict.test.ts +139 -0
- package/extensions/orchestrator/phases/verdict.ts +82 -0
- package/extensions/orchestrator/plannotator.test.ts +85 -0
- package/extensions/orchestrator/plannotator.ts +24 -6
- package/extensions/orchestrator/pp-menu.test.ts +134 -0
- package/extensions/orchestrator/pp-menu.ts +2631 -392
- package/extensions/orchestrator/repo-utils.test.ts +151 -0
- package/extensions/orchestrator/repo-utils.ts +67 -0
- package/extensions/orchestrator/spawn-cleanup.test.ts +57 -0
- package/extensions/orchestrator/spawn-cleanup.ts +35 -0
- package/extensions/orchestrator/state.test.ts +76 -6
- package/extensions/orchestrator/state.ts +89 -26
- package/extensions/orchestrator/subagent-session-marker.test.ts +36 -0
- package/extensions/orchestrator/test-helpers.ts +217 -0
- package/extensions/orchestrator/tracer.test.ts +132 -0
- package/extensions/orchestrator/tracer.ts +127 -0
- package/extensions/orchestrator/transition-controller.test.ts +207 -0
- package/extensions/orchestrator/transition-controller.ts +259 -0
- package/extensions/orchestrator/usage-tracker.test.ts +435 -0
- package/extensions/orchestrator/usage-tracker.ts +23 -2
- package/extensions/orchestrator/validate-artifacts.test.ts +83 -1
- package/package.json +2 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { getDefaultConfig, GLOBAL_CONFIG_PATH, parseDuration } from "./config.js";
|
|
4
|
+
import * as configModule from "./config.js";
|
|
5
|
+
import * as flantInfra from "./flant-infra.js";
|
|
6
|
+
import { formatDuration, formatSourceTags, getConfigSourceInfo, pickMaxReviewPasses } from "./pp-menu.js";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
vi.restoreAllMocks();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("settings helpers", () => {
|
|
13
|
+
it("formatDuration renders compact human-readable values", () => {
|
|
14
|
+
expect(formatDuration(999)).toBe("999ms");
|
|
15
|
+
expect(formatDuration(30000)).toBe("30s");
|
|
16
|
+
expect(formatDuration(300000)).toBe("5m");
|
|
17
|
+
expect(formatDuration(3600000)).toBe("1h");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("parseDuration accepts units and raw milliseconds", () => {
|
|
21
|
+
expect(parseDuration("30s")).toBe(30000);
|
|
22
|
+
expect(parseDuration("5m")).toBe(300000);
|
|
23
|
+
expect(parseDuration("1h")).toBe(3600000);
|
|
24
|
+
expect(parseDuration("1500")).toBe(1500);
|
|
25
|
+
expect(parseDuration("250ms")).toBe(250);
|
|
26
|
+
expect(parseDuration("bad")).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("formatSourceTags combines matching source tags", () => {
|
|
30
|
+
const tags = formatSourceTags("info", {
|
|
31
|
+
activeValue: "info",
|
|
32
|
+
defaultValue: "debug",
|
|
33
|
+
flantValue: "info",
|
|
34
|
+
globalValue: "warn",
|
|
35
|
+
projectValue: "info",
|
|
36
|
+
source: "project",
|
|
37
|
+
});
|
|
38
|
+
expect(tags).toBe("(active, flant, project)");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("getConfigSourceInfo resolves project-over-global-over-flant-over-default", () => {
|
|
42
|
+
const cwd = "/tmp/pp-menu-test";
|
|
43
|
+
const projectPath = join(cwd, ".pp", "config.json");
|
|
44
|
+
|
|
45
|
+
vi.spyOn(configModule, "readRawConfig").mockImplementation((path: string) => {
|
|
46
|
+
if (path === GLOBAL_CONFIG_PATH) return { general: { autoCommit: true } };
|
|
47
|
+
if (path === projectPath) return { general: { autoCommit: false } };
|
|
48
|
+
return {};
|
|
49
|
+
});
|
|
50
|
+
vi.spyOn(flantInfra, "getFlantGeneratedConfig").mockReturnValue({ general: { autoCommit: true } } as any);
|
|
51
|
+
|
|
52
|
+
const orchestrator = {
|
|
53
|
+
cwd,
|
|
54
|
+
config: {
|
|
55
|
+
...getDefaultConfig(),
|
|
56
|
+
general: {
|
|
57
|
+
...getDefaultConfig().general,
|
|
58
|
+
autoCommit: false,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
} as any;
|
|
62
|
+
|
|
63
|
+
const info = getConfigSourceInfo(orchestrator, ["general", "autoCommit"]);
|
|
64
|
+
expect(info.source).toBe("project");
|
|
65
|
+
expect(info.activeValue).toBe(false);
|
|
66
|
+
expect(info.defaultValue).toBe(true);
|
|
67
|
+
expect(info.flantValue).toBe(true);
|
|
68
|
+
expect(info.globalValue).toBe(true);
|
|
69
|
+
expect(info.projectValue).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("getConfigSourceInfo reports flant source when only flant overrides default", () => {
|
|
73
|
+
const cwd = "/tmp/pp-menu-test-flant";
|
|
74
|
+
const projectPath = join(cwd, ".pp", "config.json");
|
|
75
|
+
|
|
76
|
+
vi.spyOn(configModule, "readRawConfig").mockImplementation((path: string) => {
|
|
77
|
+
if (path === GLOBAL_CONFIG_PATH) return {};
|
|
78
|
+
if (path === projectPath) return {};
|
|
79
|
+
return {};
|
|
80
|
+
});
|
|
81
|
+
vi.spyOn(flantInfra, "getFlantGeneratedConfig").mockReturnValue({ general: { autoCommit: false } } as any);
|
|
82
|
+
|
|
83
|
+
const orchestrator = {
|
|
84
|
+
cwd,
|
|
85
|
+
config: {
|
|
86
|
+
...getDefaultConfig(),
|
|
87
|
+
general: {
|
|
88
|
+
...getDefaultConfig().general,
|
|
89
|
+
autoCommit: false,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
} as any;
|
|
93
|
+
|
|
94
|
+
const info = getConfigSourceInfo(orchestrator, ["general", "autoCommit"]);
|
|
95
|
+
expect(info.source).toBe("flant");
|
|
96
|
+
expect(info.defaultValue).toBe(true);
|
|
97
|
+
expect(info.flantValue).toBe(false);
|
|
98
|
+
expect(info.globalValue).toBeUndefined();
|
|
99
|
+
expect(info.projectValue).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("pickMaxReviewPasses", () => {
|
|
104
|
+
function makeInputCtx(responses: (string | undefined)[]) {
|
|
105
|
+
let i = 0;
|
|
106
|
+
return {
|
|
107
|
+
ui: {
|
|
108
|
+
input: vi.fn(async () => responses[i++]),
|
|
109
|
+
notify: vi.fn(),
|
|
110
|
+
},
|
|
111
|
+
} as any;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
it('returns 999 for "-" (unlimited)', async () => {
|
|
115
|
+
const ctx = makeInputCtx(["-"]);
|
|
116
|
+
expect(await pickMaxReviewPasses(ctx, 3)).toBe(999);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("returns the entered positive integer", async () => {
|
|
120
|
+
const ctx = makeInputCtx(["5"]);
|
|
121
|
+
expect(await pickMaxReviewPasses(ctx, 3)).toBe(5);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("re-prompts on non-integer junk then accepts a valid integer", async () => {
|
|
125
|
+
const ctx = makeInputCtx(["3abc", "1.5", "4"]);
|
|
126
|
+
expect(await pickMaxReviewPasses(ctx, 3)).toBe(4);
|
|
127
|
+
expect(ctx.ui.notify).toHaveBeenCalledTimes(2);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("returns null when input is cancelled or empty", async () => {
|
|
131
|
+
expect(await pickMaxReviewPasses(makeInputCtx([undefined]), 3)).toBeNull();
|
|
132
|
+
expect(await pickMaxReviewPasses(makeInputCtx([""]), 3)).toBeNull();
|
|
133
|
+
});
|
|
134
|
+
});
|