@ilya-lesikov/pi-pi 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/3p/pi-ask-user/index.ts +1835 -0
- package/3p/pi-ask-user/package.json +50 -0
- package/3p/pi-ask-user/single-select-layout.ts +203 -0
- package/3p/pi-lsp/extensions/lsp/client.ts +542 -0
- package/3p/pi-lsp/extensions/lsp/config.ts +135 -0
- package/3p/pi-lsp/extensions/lsp/effects/command.ts +42 -0
- package/3p/pi-lsp/extensions/lsp/effects/filesystem.ts +50 -0
- package/3p/pi-lsp/extensions/lsp/effects/runtime.ts +21 -0
- package/3p/pi-lsp/extensions/lsp/errors.ts +113 -0
- package/3p/pi-lsp/extensions/lsp/formatting.ts +315 -0
- package/3p/pi-lsp/extensions/lsp/index.ts +231 -0
- package/3p/pi-lsp/extensions/lsp/protocol.ts +209 -0
- package/3p/pi-lsp/extensions/lsp/retry.ts +39 -0
- package/3p/pi-lsp/extensions/lsp/tools/programs.ts +293 -0
- package/3p/pi-lsp/extensions/lsp/tools.ts +89 -0
- package/3p/pi-lsp/extensions/lsp/types.ts +243 -0
- package/3p/pi-lsp/package.json +54 -0
- package/3p/pi-plannotator/AGENTS.md +583 -0
- package/3p/pi-plannotator/apps/pi-extension/README.md +228 -0
- package/3p/pi-plannotator/apps/pi-extension/assistant-message.ts +128 -0
- package/3p/pi-plannotator/apps/pi-extension/config.test.ts +166 -0
- package/3p/pi-plannotator/apps/pi-extension/config.ts +318 -0
- package/3p/pi-plannotator/apps/pi-extension/current-pi-session.ts +147 -0
- package/3p/pi-plannotator/apps/pi-extension/index.ts +1279 -0
- package/3p/pi-plannotator/apps/pi-extension/package.json +56 -0
- package/3p/pi-plannotator/apps/pi-extension/plannotator-browser.test.ts +13 -0
- package/3p/pi-plannotator/apps/pi-extension/plannotator-browser.ts +616 -0
- package/3p/pi-plannotator/apps/pi-extension/plannotator-events.ts +342 -0
- package/3p/pi-plannotator/apps/pi-extension/plannotator.json +12 -0
- package/3p/pi-plannotator/apps/pi-extension/server/agent-jobs.ts +515 -0
- package/3p/pi-plannotator/apps/pi-extension/server/ai-runtime.ts +169 -0
- package/3p/pi-plannotator/apps/pi-extension/server/annotations.ts +85 -0
- package/3p/pi-plannotator/apps/pi-extension/server/external-annotations.ts +189 -0
- package/3p/pi-plannotator/apps/pi-extension/server/handlers.ts +210 -0
- package/3p/pi-plannotator/apps/pi-extension/server/helpers.ts +78 -0
- package/3p/pi-plannotator/apps/pi-extension/server/ide.ts +46 -0
- package/3p/pi-plannotator/apps/pi-extension/server/integrations.ts +195 -0
- package/3p/pi-plannotator/apps/pi-extension/server/network.test.ts +158 -0
- package/3p/pi-plannotator/apps/pi-extension/server/network.ts +268 -0
- package/3p/pi-plannotator/apps/pi-extension/server/pr.ts +126 -0
- package/3p/pi-plannotator/apps/pi-extension/server/project.ts +64 -0
- package/3p/pi-plannotator/apps/pi-extension/server/reference.ts +362 -0
- package/3p/pi-plannotator/apps/pi-extension/server/serverAnnotate.ts +199 -0
- package/3p/pi-plannotator/apps/pi-extension/server/serverPlan.ts +505 -0
- package/3p/pi-plannotator/apps/pi-extension/server/serverReview.ts +1229 -0
- package/3p/pi-plannotator/apps/pi-extension/server/vcs.ts +121 -0
- package/3p/pi-plannotator/apps/pi-extension/server.test.ts +966 -0
- package/3p/pi-plannotator/apps/pi-extension/server.ts +44 -0
- package/3p/pi-plannotator/apps/pi-extension/tool-scope.test.ts +88 -0
- package/3p/pi-plannotator/apps/pi-extension/tool-scope.ts +39 -0
- package/3p/pi-plannotator/apps/pi-extension/tsconfig.json +16 -0
- package/3p/pi-plannotator/apps/pi-extension/vendor.sh +48 -0
- package/3p/pi-plannotator/package.json +53 -0
- package/3p/pi-plannotator/packages/ai/ai.test.ts +1407 -0
- package/3p/pi-plannotator/packages/ai/base-session.ts +94 -0
- package/3p/pi-plannotator/packages/ai/context.ts +250 -0
- package/3p/pi-plannotator/packages/ai/endpoints.ts +326 -0
- package/3p/pi-plannotator/packages/ai/index.ts +105 -0
- package/3p/pi-plannotator/packages/ai/package.json +21 -0
- package/3p/pi-plannotator/packages/ai/provider.ts +103 -0
- package/3p/pi-plannotator/packages/ai/providers/claude-agent-sdk.ts +447 -0
- package/3p/pi-plannotator/packages/ai/providers/codex-sdk.ts +430 -0
- package/3p/pi-plannotator/packages/ai/providers/command-path.ts +115 -0
- package/3p/pi-plannotator/packages/ai/providers/opencode-sdk.ts +546 -0
- package/3p/pi-plannotator/packages/ai/providers/pi-events.ts +110 -0
- package/3p/pi-plannotator/packages/ai/providers/pi-sdk-node.ts +425 -0
- package/3p/pi-plannotator/packages/ai/providers/pi-sdk.ts +469 -0
- package/3p/pi-plannotator/packages/ai/session-manager.ts +195 -0
- package/3p/pi-plannotator/packages/ai/tsconfig.json +15 -0
- package/3p/pi-plannotator/packages/ai/types.ts +379 -0
- package/3p/pi-plannotator/packages/server/agent-jobs.ts +538 -0
- package/3p/pi-plannotator/packages/server/agent-review-message.test.ts +135 -0
- package/3p/pi-plannotator/packages/server/agent-review-message.ts +243 -0
- package/3p/pi-plannotator/packages/server/ai-runtime.ts +108 -0
- package/3p/pi-plannotator/packages/server/annotate.ts +401 -0
- package/3p/pi-plannotator/packages/server/browser.test.ts +87 -0
- package/3p/pi-plannotator/packages/server/browser.ts +245 -0
- package/3p/pi-plannotator/packages/server/claude-review.ts +352 -0
- package/3p/pi-plannotator/packages/server/code-nav.ts +73 -0
- package/3p/pi-plannotator/packages/server/codex-review-schema.json +41 -0
- package/3p/pi-plannotator/packages/server/codex-review.ts +330 -0
- package/3p/pi-plannotator/packages/server/config.ts +8 -0
- package/3p/pi-plannotator/packages/server/draft.ts +1 -0
- package/3p/pi-plannotator/packages/server/editor-annotations.ts +76 -0
- package/3p/pi-plannotator/packages/server/external-annotations.test.ts +18 -0
- package/3p/pi-plannotator/packages/server/external-annotations.ts +207 -0
- package/3p/pi-plannotator/packages/server/git.ts +141 -0
- package/3p/pi-plannotator/packages/server/goal-setup.test.ts +55 -0
- package/3p/pi-plannotator/packages/server/goal-setup.ts +248 -0
- package/3p/pi-plannotator/packages/server/ide.ts +43 -0
- package/3p/pi-plannotator/packages/server/image.test.ts +63 -0
- package/3p/pi-plannotator/packages/server/image.ts +66 -0
- package/3p/pi-plannotator/packages/server/index.ts +648 -0
- package/3p/pi-plannotator/packages/server/integrations.test.ts +172 -0
- package/3p/pi-plannotator/packages/server/integrations.ts +214 -0
- package/3p/pi-plannotator/packages/server/jj.test.ts +69 -0
- package/3p/pi-plannotator/packages/server/jj.ts +86 -0
- package/3p/pi-plannotator/packages/server/p4.ts +417 -0
- package/3p/pi-plannotator/packages/server/package.json +40 -0
- package/3p/pi-plannotator/packages/server/path-utils.ts +18 -0
- package/3p/pi-plannotator/packages/server/pr.ts +146 -0
- package/3p/pi-plannotator/packages/server/project.test.ts +115 -0
- package/3p/pi-plannotator/packages/server/project.ts +45 -0
- package/3p/pi-plannotator/packages/server/reference-handlers.ts +404 -0
- package/3p/pi-plannotator/packages/server/remote.test.ts +150 -0
- package/3p/pi-plannotator/packages/server/remote.ts +74 -0
- package/3p/pi-plannotator/packages/server/repo.ts +80 -0
- package/3p/pi-plannotator/packages/server/resolve-file.test.ts +310 -0
- package/3p/pi-plannotator/packages/server/review-workspace.test.ts +1032 -0
- package/3p/pi-plannotator/packages/server/review-workspace.ts +48 -0
- package/3p/pi-plannotator/packages/server/review.ts +1318 -0
- package/3p/pi-plannotator/packages/server/sessions.ts +111 -0
- package/3p/pi-plannotator/packages/server/share-url.ts +53 -0
- package/3p/pi-plannotator/packages/server/shared-handlers.test.ts +43 -0
- package/3p/pi-plannotator/packages/server/shared-handlers.ts +177 -0
- package/3p/pi-plannotator/packages/server/storage.test.ts +176 -0
- package/3p/pi-plannotator/packages/server/storage.ts +17 -0
- package/3p/pi-plannotator/packages/server/tour/tour-review.test.ts +146 -0
- package/3p/pi-plannotator/packages/server/tour/tour-review.ts +604 -0
- package/3p/pi-plannotator/packages/server/tsconfig.json +15 -0
- package/3p/pi-plannotator/packages/server/vcs.test.ts +48 -0
- package/3p/pi-plannotator/packages/server/vcs.ts +80 -0
- package/3p/pi-plannotator/packages/shared/agent-jobs.ts +132 -0
- package/3p/pi-plannotator/packages/shared/agents.ts +53 -0
- package/3p/pi-plannotator/packages/shared/annotate-args.test.ts +386 -0
- package/3p/pi-plannotator/packages/shared/annotate-args.ts +107 -0
- package/3p/pi-plannotator/packages/shared/at-reference.test.ts +99 -0
- package/3p/pi-plannotator/packages/shared/at-reference.ts +52 -0
- package/3p/pi-plannotator/packages/shared/checklist.ts +52 -0
- package/3p/pi-plannotator/packages/shared/code-file.test.ts +112 -0
- package/3p/pi-plannotator/packages/shared/code-file.ts +41 -0
- package/3p/pi-plannotator/packages/shared/code-nav.test.ts +515 -0
- package/3p/pi-plannotator/packages/shared/code-nav.ts +436 -0
- package/3p/pi-plannotator/packages/shared/compress.ts +51 -0
- package/3p/pi-plannotator/packages/shared/config.ts +262 -0
- package/3p/pi-plannotator/packages/shared/crypto.test.ts +172 -0
- package/3p/pi-plannotator/packages/shared/crypto.ts +97 -0
- package/3p/pi-plannotator/packages/shared/data-dir.ts +42 -0
- package/3p/pi-plannotator/packages/shared/diff-paths.test.ts +30 -0
- package/3p/pi-plannotator/packages/shared/diff-paths.ts +137 -0
- package/3p/pi-plannotator/packages/shared/draft.ts +64 -0
- package/3p/pi-plannotator/packages/shared/external-annotation.ts +397 -0
- package/3p/pi-plannotator/packages/shared/extract-code-paths.test.ts +59 -0
- package/3p/pi-plannotator/packages/shared/extract-code-paths.ts +66 -0
- package/3p/pi-plannotator/packages/shared/favicon.ts +5 -0
- package/3p/pi-plannotator/packages/shared/feedback-templates.test.ts +65 -0
- package/3p/pi-plannotator/packages/shared/feedback-templates.ts +29 -0
- package/3p/pi-plannotator/packages/shared/goal-setup.test.ts +231 -0
- package/3p/pi-plannotator/packages/shared/goal-setup.ts +336 -0
- package/3p/pi-plannotator/packages/shared/html-to-markdown.test.ts +62 -0
- package/3p/pi-plannotator/packages/shared/html-to-markdown.ts +32 -0
- package/3p/pi-plannotator/packages/shared/improvement-hooks.test.ts +135 -0
- package/3p/pi-plannotator/packages/shared/improvement-hooks.ts +115 -0
- package/3p/pi-plannotator/packages/shared/integrations-common.ts +243 -0
- package/3p/pi-plannotator/packages/shared/jj-core.test.ts +236 -0
- package/3p/pi-plannotator/packages/shared/jj-core.ts +433 -0
- package/3p/pi-plannotator/packages/shared/package.json +55 -0
- package/3p/pi-plannotator/packages/shared/pfm-reminder.test.ts +88 -0
- package/3p/pi-plannotator/packages/shared/pfm-reminder.ts +80 -0
- package/3p/pi-plannotator/packages/shared/pr-github.ts +661 -0
- package/3p/pi-plannotator/packages/shared/pr-gitlab.test.ts +202 -0
- package/3p/pi-plannotator/packages/shared/pr-gitlab.ts +620 -0
- package/3p/pi-plannotator/packages/shared/pr-provider.test.ts +266 -0
- package/3p/pi-plannotator/packages/shared/pr-provider.ts +123 -0
- package/3p/pi-plannotator/packages/shared/pr-stack.test.ts +104 -0
- package/3p/pi-plannotator/packages/shared/pr-stack.ts +194 -0
- package/3p/pi-plannotator/packages/shared/pr-types.ts +326 -0
- package/3p/pi-plannotator/packages/shared/project.ts +71 -0
- package/3p/pi-plannotator/packages/shared/prompts-integration.test.ts +421 -0
- package/3p/pi-plannotator/packages/shared/prompts.test.ts +504 -0
- package/3p/pi-plannotator/packages/shared/prompts.ts +247 -0
- package/3p/pi-plannotator/packages/shared/reference-common.ts +87 -0
- package/3p/pi-plannotator/packages/shared/repo.ts +71 -0
- package/3p/pi-plannotator/packages/shared/resolve-file.test.ts +113 -0
- package/3p/pi-plannotator/packages/shared/resolve-file.ts +509 -0
- package/3p/pi-plannotator/packages/shared/review-args.test.ts +64 -0
- package/3p/pi-plannotator/packages/shared/review-args.ts +85 -0
- package/3p/pi-plannotator/packages/shared/review-core.test.ts +286 -0
- package/3p/pi-plannotator/packages/shared/review-core.ts +895 -0
- package/3p/pi-plannotator/packages/shared/review-workspace-node.ts +230 -0
- package/3p/pi-plannotator/packages/shared/review-workspace.ts +436 -0
- package/3p/pi-plannotator/packages/shared/semantic-diff-types.ts +76 -0
- package/3p/pi-plannotator/packages/shared/semantic-diff.test.ts +322 -0
- package/3p/pi-plannotator/packages/shared/semantic-diff.ts +520 -0
- package/3p/pi-plannotator/packages/shared/storage.ts +378 -0
- package/3p/pi-plannotator/packages/shared/tour.ts +61 -0
- package/3p/pi-plannotator/packages/shared/tsconfig.json +15 -0
- package/3p/pi-plannotator/packages/shared/types.ts +29 -0
- package/3p/pi-plannotator/packages/shared/url-to-markdown.test.ts +177 -0
- package/3p/pi-plannotator/packages/shared/url-to-markdown.ts +351 -0
- package/3p/pi-plannotator/packages/shared/vcs-core.test.ts +332 -0
- package/3p/pi-plannotator/packages/shared/vcs-core.ts +482 -0
- package/3p/pi-plannotator/packages/shared/worktree-pool.test.ts +162 -0
- package/3p/pi-plannotator/packages/shared/worktree-pool.ts +103 -0
- package/3p/pi-plannotator/packages/shared/worktree.ts +119 -0
- package/3p/pi-subagents/package.json +50 -0
- package/3p/pi-subagents/src/agent-manager.ts +413 -0
- package/3p/pi-subagents/src/agent-runner.ts +502 -0
- package/3p/pi-subagents/src/agent-types.ts +248 -0
- package/3p/pi-subagents/src/context.ts +58 -0
- package/3p/pi-subagents/src/cross-extension-rpc.ts +135 -0
- package/3p/pi-subagents/src/custom-agents.ts +137 -0
- package/3p/pi-subagents/src/default-agents.ts +144 -0
- package/3p/pi-subagents/src/env.ts +33 -0
- package/3p/pi-subagents/src/group-join.ts +141 -0
- package/3p/pi-subagents/src/index.ts +1811 -0
- package/3p/pi-subagents/src/invocation-config.ts +40 -0
- package/3p/pi-subagents/src/memory.ts +165 -0
- package/3p/pi-subagents/src/model-resolver.ts +81 -0
- package/3p/pi-subagents/src/output-file.ts +77 -0
- package/3p/pi-subagents/src/prompts.ts +85 -0
- package/3p/pi-subagents/src/skill-loader.ts +79 -0
- package/3p/pi-subagents/src/types.ts +111 -0
- package/3p/pi-subagents/src/ui/agent-widget.ts +496 -0
- package/3p/pi-subagents/src/ui/conversation-viewer.ts +250 -0
- package/3p/pi-subagents/src/worktree.ts +162 -0
- package/3p/pi-tasks/package.json +52 -0
- package/3p/pi-tasks/src/auto-clear.ts +91 -0
- package/3p/pi-tasks/src/index.ts +1150 -0
- package/3p/pi-tasks/src/process-tracker.ts +140 -0
- package/3p/pi-tasks/src/reminder-cadence.ts +90 -0
- package/3p/pi-tasks/src/task-store.ts +324 -0
- package/3p/pi-tasks/src/tasks-config.ts +27 -0
- package/3p/pi-tasks/src/types.ts +40 -0
- package/3p/pi-tasks/src/ui/settings-menu.ts +152 -0
- package/3p/pi-tasks/src/ui/task-widget.ts +296 -0
- package/AGENTS.md +28 -0
- package/LICENSE +201 -0
- package/extensions/orchestrator/agents/brainstorm-reviewer.ts +77 -0
- package/extensions/orchestrator/agents/code-reviewer.ts +89 -0
- package/extensions/orchestrator/agents/explore.ts +33 -0
- package/extensions/orchestrator/agents/librarian.ts +43 -0
- package/extensions/orchestrator/agents/plan-reviewer.ts +75 -0
- package/extensions/orchestrator/agents/planner.ts +61 -0
- package/extensions/orchestrator/agents/registry.ts +156 -0
- package/extensions/orchestrator/agents/task.ts +50 -0
- package/extensions/orchestrator/agents/tool-routing.ts +84 -0
- package/extensions/orchestrator/ast-search.ts +85 -0
- package/extensions/orchestrator/cbm.ts +330 -0
- package/extensions/orchestrator/command-handlers.test.ts +163 -0
- package/extensions/orchestrator/command-handlers.ts +116 -0
- package/extensions/orchestrator/commands.test.ts +81 -0
- package/extensions/orchestrator/commands.ts +75 -0
- package/extensions/orchestrator/config.test.ts +221 -0
- package/extensions/orchestrator/config.ts +230 -0
- package/extensions/orchestrator/context.test.ts +293 -0
- package/extensions/orchestrator/context.ts +206 -0
- package/extensions/orchestrator/event-handlers.test.ts +190 -0
- package/extensions/orchestrator/event-handlers.ts +1416 -0
- package/extensions/orchestrator/exa.ts +104 -0
- package/extensions/orchestrator/flant-infra.ts +486 -0
- package/extensions/orchestrator/index.ts +80 -0
- package/extensions/orchestrator/integration.test.ts +1214 -0
- package/extensions/orchestrator/orchestrator.test.ts +252 -0
- package/extensions/orchestrator/orchestrator.ts +538 -0
- package/extensions/orchestrator/phases/brainstorm.test.ts +15 -0
- package/extensions/orchestrator/phases/brainstorm.ts +273 -0
- package/extensions/orchestrator/phases/implementation.ts +40 -0
- package/extensions/orchestrator/phases/machine.test.ts +293 -0
- package/extensions/orchestrator/phases/machine.ts +209 -0
- package/extensions/orchestrator/phases/planning.ts +255 -0
- package/extensions/orchestrator/phases/review.ts +193 -0
- package/extensions/orchestrator/plannotator.ts +56 -0
- package/extensions/orchestrator/pp-menu.ts +866 -0
- package/extensions/orchestrator/state.test.ts +343 -0
- package/extensions/orchestrator/state.ts +237 -0
- package/extensions/orchestrator/validate-artifacts.test.ts +88 -0
- package/extensions/orchestrator/validate-artifacts.ts +272 -0
- package/extensions/orchestrator/vendor.d.ts +26 -0
- package/package.json +73 -0
- package/scripts/postinstall.sh +18 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import type { DiffType, VcsSelection } from "./server.js";
|
|
6
|
+
import { getRecentAssistantMessages } from "./assistant-message.js";
|
|
7
|
+
import {
|
|
8
|
+
getLastAssistantMessageText,
|
|
9
|
+
getStartupErrorMessage,
|
|
10
|
+
openArchiveBrowserAction,
|
|
11
|
+
openCodeReview,
|
|
12
|
+
openLastMessageAnnotation,
|
|
13
|
+
openMarkdownAnnotation,
|
|
14
|
+
startCodeReviewBrowserSession,
|
|
15
|
+
startLastMessageAnnotationSession,
|
|
16
|
+
startMarkdownAnnotationSession,
|
|
17
|
+
startPlanReviewBrowserSession,
|
|
18
|
+
} from "./plannotator-browser.js";
|
|
19
|
+
|
|
20
|
+
export const PLANNOTATOR_REQUEST_CHANNEL = "plannotator:request" as const;
|
|
21
|
+
export const PLANNOTATOR_REVIEW_RESULT_CHANNEL = "plannotator:review-result" as const;
|
|
22
|
+
export const PLANNOTATOR_TIMEOUT_MS = 5_000;
|
|
23
|
+
|
|
24
|
+
export type PlannotatorAction =
|
|
25
|
+
| "plan-review"
|
|
26
|
+
| "review-status"
|
|
27
|
+
| "code-review"
|
|
28
|
+
| "annotate"
|
|
29
|
+
| "annotate-last"
|
|
30
|
+
| "archive";
|
|
31
|
+
|
|
32
|
+
export interface PlannotatorHandledResponse<T> {
|
|
33
|
+
status: "handled";
|
|
34
|
+
result: T;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface PlannotatorUnavailableResponse {
|
|
38
|
+
status: "unavailable";
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PlannotatorErrorResponse {
|
|
43
|
+
status: "error";
|
|
44
|
+
error: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type PlannotatorResponse<T> =
|
|
48
|
+
| PlannotatorHandledResponse<T>
|
|
49
|
+
| PlannotatorUnavailableResponse
|
|
50
|
+
| PlannotatorErrorResponse;
|
|
51
|
+
|
|
52
|
+
export interface PlannotatorRequestBase<A extends PlannotatorAction, P, R> {
|
|
53
|
+
requestId: string;
|
|
54
|
+
action: A;
|
|
55
|
+
payload: P;
|
|
56
|
+
respond: (response: PlannotatorResponse<R>) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface PlannotatorPlanReviewPayload {
|
|
60
|
+
planFilePath?: string;
|
|
61
|
+
planContent: string;
|
|
62
|
+
origin?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface PlannotatorPlanReviewStartResult {
|
|
66
|
+
status: "pending";
|
|
67
|
+
reviewId: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface PlannotatorReviewResultEvent {
|
|
71
|
+
reviewId: string;
|
|
72
|
+
approved: boolean;
|
|
73
|
+
feedback?: string;
|
|
74
|
+
savedPath?: string;
|
|
75
|
+
agentSwitch?: string;
|
|
76
|
+
permissionMode?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface PlannotatorReviewStatusPayload {
|
|
80
|
+
reviewId: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type PlannotatorReviewStatusResult =
|
|
84
|
+
| { status: "pending" }
|
|
85
|
+
| ({ status: "completed" } & PlannotatorReviewResultEvent)
|
|
86
|
+
| { status: "missing" };
|
|
87
|
+
|
|
88
|
+
export interface PlannotatorCodeReviewPayload {
|
|
89
|
+
diffType?: DiffType;
|
|
90
|
+
defaultBranch?: string;
|
|
91
|
+
vcsType?: VcsSelection;
|
|
92
|
+
useLocal?: boolean;
|
|
93
|
+
cwd?: string;
|
|
94
|
+
prUrl?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface PlannotatorCodeReviewResult {
|
|
98
|
+
approved: boolean;
|
|
99
|
+
feedback?: string;
|
|
100
|
+
annotations?: unknown[];
|
|
101
|
+
agentSwitch?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface PlannotatorAnnotatePayload {
|
|
105
|
+
filePath: string;
|
|
106
|
+
markdown?: string;
|
|
107
|
+
mode?: "annotate" | "annotate-folder" | "annotate-last";
|
|
108
|
+
folderPath?: string;
|
|
109
|
+
/** Enable review-gate UX (Approve / Annotate / Close). */
|
|
110
|
+
gate?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface PlannotatorAnnotationResult {
|
|
114
|
+
feedback: string;
|
|
115
|
+
/** True when the reviewer closed the session without providing feedback. */
|
|
116
|
+
exit?: boolean;
|
|
117
|
+
/** True when the reviewer clicked Approve in review-gate mode. */
|
|
118
|
+
approved?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface PlannotatorArchivePayload {
|
|
122
|
+
customPlanPath?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface PlannotatorArchiveResult {
|
|
126
|
+
opened: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type PlannotatorRequestMap = {
|
|
130
|
+
"plan-review": PlannotatorRequestBase<"plan-review", PlannotatorPlanReviewPayload, PlannotatorPlanReviewStartResult>;
|
|
131
|
+
"review-status": PlannotatorRequestBase<"review-status", PlannotatorReviewStatusPayload, PlannotatorReviewStatusResult>;
|
|
132
|
+
"code-review": PlannotatorRequestBase<"code-review", PlannotatorCodeReviewPayload, PlannotatorCodeReviewResult>;
|
|
133
|
+
annotate: PlannotatorRequestBase<"annotate", PlannotatorAnnotatePayload, PlannotatorAnnotationResult>;
|
|
134
|
+
"annotate-last": PlannotatorRequestBase<"annotate-last", PlannotatorAnnotatePayload, PlannotatorAnnotationResult>;
|
|
135
|
+
archive: PlannotatorRequestBase<"archive", PlannotatorArchivePayload, PlannotatorArchiveResult>;
|
|
136
|
+
};
|
|
137
|
+
export type PlannotatorRequest = PlannotatorRequestMap[PlannotatorAction];
|
|
138
|
+
export type PlannotatorResponseMap = {
|
|
139
|
+
"plan-review": PlannotatorResponse<PlannotatorPlanReviewStartResult>;
|
|
140
|
+
"review-status": PlannotatorResponse<PlannotatorReviewStatusResult>;
|
|
141
|
+
"code-review": PlannotatorResponse<PlannotatorCodeReviewResult>;
|
|
142
|
+
annotate: PlannotatorResponse<PlannotatorAnnotationResult>;
|
|
143
|
+
"annotate-last": PlannotatorResponse<PlannotatorAnnotationResult>;
|
|
144
|
+
archive: PlannotatorResponse<PlannotatorArchiveResult>;
|
|
145
|
+
};
|
|
146
|
+
function isPlannotatorAction(value: unknown): value is PlannotatorAction {
|
|
147
|
+
return (
|
|
148
|
+
value === "plan-review" ||
|
|
149
|
+
value === "review-status" ||
|
|
150
|
+
value === "code-review" ||
|
|
151
|
+
value === "annotate" ||
|
|
152
|
+
value === "annotate-last" ||
|
|
153
|
+
value === "archive"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const REVIEW_STATUS_PATH = join(homedir(), ".pi", "plannotator-review-status.json");
|
|
158
|
+
|
|
159
|
+
type StoredReviewStatus = Record<string, PlannotatorReviewStatusResult>;
|
|
160
|
+
|
|
161
|
+
function readStoredReviewStatuses(): StoredReviewStatus {
|
|
162
|
+
try {
|
|
163
|
+
if (!existsSync(REVIEW_STATUS_PATH)) return {};
|
|
164
|
+
const raw = readFileSync(REVIEW_STATUS_PATH, "utf-8");
|
|
165
|
+
const parsed = JSON.parse(raw) as StoredReviewStatus;
|
|
166
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
167
|
+
} catch {
|
|
168
|
+
return {};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function writeStoredReviewStatuses(statuses: StoredReviewStatus): void {
|
|
173
|
+
mkdirSync(dirname(REVIEW_STATUS_PATH), { recursive: true });
|
|
174
|
+
writeFileSync(REVIEW_STATUS_PATH, JSON.stringify(statuses, null, 2));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function setStoredReviewStatus(reviewId: string, status: PlannotatorReviewStatusResult): void {
|
|
178
|
+
const statuses = readStoredReviewStatuses();
|
|
179
|
+
statuses[reviewId] = status;
|
|
180
|
+
writeStoredReviewStatuses(statuses);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function getStoredReviewStatus(reviewId: string): PlannotatorReviewStatusResult {
|
|
184
|
+
return readStoredReviewStatuses()[reviewId] ?? { status: "missing" };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function createActiveSessionContext() {
|
|
188
|
+
let currentCtx: ExtensionContext | undefined;
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
set(ctx: ExtensionContext): void {
|
|
192
|
+
currentCtx = ctx;
|
|
193
|
+
},
|
|
194
|
+
clear(): void {
|
|
195
|
+
currentCtx = undefined;
|
|
196
|
+
},
|
|
197
|
+
get(): ExtensionContext | undefined {
|
|
198
|
+
return currentCtx;
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function registerPlannotatorEventListeners(pi: ExtensionAPI): void {
|
|
204
|
+
const activeSessionContext = createActiveSessionContext();
|
|
205
|
+
|
|
206
|
+
// Plannotator event requests are handled against the latest active session.
|
|
207
|
+
// The active context is intentionally session-scoped and replaced on each session_start.
|
|
208
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
209
|
+
activeSessionContext.set(ctx);
|
|
210
|
+
});
|
|
211
|
+
pi.events.on(PLANNOTATOR_REQUEST_CHANNEL, async (data) => {
|
|
212
|
+
const request = data as Partial<PlannotatorRequest> | null;
|
|
213
|
+
const ctx = activeSessionContext.get();
|
|
214
|
+
|
|
215
|
+
if (!request || typeof request.respond !== "function" || !isPlannotatorAction(request.action)) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
if (request.action === "review-status") {
|
|
221
|
+
const reviewId = request.payload?.reviewId;
|
|
222
|
+
if (typeof reviewId !== "string" || !reviewId.trim()) {
|
|
223
|
+
request.respond({ status: "error", error: "Missing reviewId for review-status request." });
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
request.respond({ status: "handled", result: getStoredReviewStatus(reviewId) });
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (!ctx) {
|
|
231
|
+
request.respond({ status: "unavailable", error: "Plannotator context is not ready yet." });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
switch (request.action) {
|
|
236
|
+
case "plan-review": {
|
|
237
|
+
const planContent = request.payload?.planContent;
|
|
238
|
+
if (typeof planContent !== "string" || !planContent.trim()) {
|
|
239
|
+
request.respond({ status: "error", error: "Missing planContent for plan-review request." });
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const session = await startPlanReviewBrowserSession(ctx, planContent);
|
|
243
|
+
setStoredReviewStatus(session.reviewId, { status: "pending" });
|
|
244
|
+
session.onDecision((result) => {
|
|
245
|
+
const reviewResult = {
|
|
246
|
+
reviewId: session.reviewId,
|
|
247
|
+
approved: result.approved,
|
|
248
|
+
feedback: result.feedback,
|
|
249
|
+
savedPath: result.savedPath,
|
|
250
|
+
agentSwitch: result.agentSwitch,
|
|
251
|
+
permissionMode: result.permissionMode,
|
|
252
|
+
} satisfies PlannotatorReviewResultEvent;
|
|
253
|
+
setStoredReviewStatus(session.reviewId, { status: "completed", ...reviewResult });
|
|
254
|
+
pi.events.emit(PLANNOTATOR_REVIEW_RESULT_CHANNEL, reviewResult);
|
|
255
|
+
});
|
|
256
|
+
request.respond({
|
|
257
|
+
status: "handled",
|
|
258
|
+
result: {
|
|
259
|
+
status: "pending",
|
|
260
|
+
reviewId: session.reviewId,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
case "code-review": {
|
|
266
|
+
const result = await openCodeReview(ctx, {
|
|
267
|
+
cwd: request.payload?.cwd,
|
|
268
|
+
defaultBranch: request.payload?.defaultBranch,
|
|
269
|
+
diffType: request.payload?.diffType,
|
|
270
|
+
vcsType: request.payload?.vcsType,
|
|
271
|
+
useLocal: request.payload?.useLocal,
|
|
272
|
+
prUrl: request.payload?.prUrl,
|
|
273
|
+
});
|
|
274
|
+
request.respond({ status: "handled", result });
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
case "annotate": {
|
|
278
|
+
const payload = request.payload;
|
|
279
|
+
if (!payload?.filePath) {
|
|
280
|
+
request.respond({ status: "error", error: "Missing filePath for annotate request." });
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const sourceConverted = /\.html?$/i.test(payload.filePath) || /^https?:\/\//i.test(payload.filePath);
|
|
284
|
+
const result = await openMarkdownAnnotation(
|
|
285
|
+
ctx,
|
|
286
|
+
payload.filePath,
|
|
287
|
+
payload.markdown ?? "",
|
|
288
|
+
payload.mode ?? "annotate",
|
|
289
|
+
payload.folderPath,
|
|
290
|
+
undefined,
|
|
291
|
+
sourceConverted,
|
|
292
|
+
payload.gate,
|
|
293
|
+
);
|
|
294
|
+
request.respond({ status: "handled", result });
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
case "annotate-last": {
|
|
298
|
+
const payload = request.payload;
|
|
299
|
+
const usePayloadText = !!payload?.markdown?.trim();
|
|
300
|
+
const lastText = usePayloadText ? payload!.markdown! : getLastAssistantMessageText(ctx);
|
|
301
|
+
if (!lastText) {
|
|
302
|
+
request.respond({ status: "unavailable", error: "No assistant message found in session." });
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const recent = usePayloadText ? [] : getRecentAssistantMessages(ctx, 25);
|
|
306
|
+
const pickerMessages = recent.length > 1 ? recent : undefined;
|
|
307
|
+
const result = await openLastMessageAnnotation(ctx, lastText, payload?.gate, pickerMessages);
|
|
308
|
+
request.respond({ status: "handled", result });
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
case "archive": {
|
|
312
|
+
const result = await openArchiveBrowserAction(ctx, request.payload?.customPlanPath);
|
|
313
|
+
request.respond({ status: "handled", result });
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} catch (err) {
|
|
318
|
+
const message = getStartupErrorMessage(err);
|
|
319
|
+
if (/unavailable|not available/i.test(message)) {
|
|
320
|
+
request.respond({ status: "unavailable", error: message });
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
request.respond({ status: "error", error: message });
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export {
|
|
329
|
+
getLastAssistantMessageText,
|
|
330
|
+
hasPlanBrowserHtml,
|
|
331
|
+
hasReviewBrowserHtml,
|
|
332
|
+
startCodeReviewBrowserSession,
|
|
333
|
+
startLastMessageAnnotationSession,
|
|
334
|
+
startMarkdownAnnotationSession,
|
|
335
|
+
getStartupErrorMessage,
|
|
336
|
+
openArchiveBrowserAction,
|
|
337
|
+
openCodeReview,
|
|
338
|
+
openLastMessageAnnotation,
|
|
339
|
+
openMarkdownAnnotation,
|
|
340
|
+
openPlanReviewBrowser,
|
|
341
|
+
startPlanReviewBrowserSession,
|
|
342
|
+
} from "./plannotator-browser.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"phases": {
|
|
3
|
+
"planning": {
|
|
4
|
+
"activeTools": ["grep", "find", "ls", "plannotator_submit_plan"],
|
|
5
|
+
"statusLabel": "⏸ plan",
|
|
6
|
+
"systemPrompt": "[PLANNOTATOR - PLANNING PHASE]\nYou are in plan mode. You MUST NOT make any changes to the codebase — no edits, no commits, no installs, no destructive commands. During planning you may only write or edit markdown files (.md, .mdx) inside the working directory.\n\nAvailable tools: read, bash, grep, find, ls, write (markdown only), edit (markdown only), plannotator_submit_plan\n\nDo not run destructive bash commands (rm, git push, npm install, etc.) — focus on reading and exploring the codebase. Web fetching (curl, wget) is fine.\n\n## Iterative Planning Workflow\n\nYou are pair-planning with the user. Explore the code to build context, then write your findings into a markdown plan file as you go. The plan starts as a rough skeleton and gradually becomes the final plan.\n\n### Picking a plan file\n\nChoose a descriptive filename for your plan. Convention: `PLAN.md` at the repo root for a single focused plan, or `plans/<short-name>.md` for projects that keep multiple plans. Reuse the same filename across revisions of the same plan so version history links up.\n\n### The Loop\n\nRepeat this cycle until the plan is complete:\n\n1. **Explore** — Use read, grep, find, ls, and bash to understand the codebase. Actively search for existing functions, utilities, and patterns that can be reused — avoid proposing new code when suitable implementations already exist.\n2. **Update the plan file** — After each discovery, immediately capture what you learned in the plan. Don't wait until the end. Use write for the initial draft, then edit for all subsequent updates.\n3. **Ask the user** — When you hit an ambiguity or decision you can't resolve from code alone, ask. Then go back to step 1.\n\n### First Turn\n\nStart by quickly scanning key files to form an initial understanding of the task scope. Then write a skeleton plan (headers and rough notes) and ask the user your first round of questions. Don't explore exhaustively before engaging the user.\n\n### Asking Good Questions\n\n- Never ask what you could find out by reading the code.\n- Batch related questions together.\n- Focus on things only the user can answer: requirements, preferences, tradeoffs, edge-case priorities.\n- Scale depth to the task — a vague feature request needs many rounds; a focused bug fix may need one or none.\n\n### Plan File Structure\n\nYour plan file should use markdown with clear sections:\n- **Context** — Why this change is being made: the problem, what prompted it, the intended outcome.\n- **Approach** — Your recommended approach only, not all alternatives considered.\n- **Files to modify** — List the critical file paths that will be changed.\n- **Reuse** — Reference existing functions and utilities you found, with their file paths.\n- **Steps** — Implementation checklist:\n - [ ] Step 1 description\n - [ ] Step 2 description\n- **Verification** — How to test the changes end-to-end (run the code, run tests, manual checks).\n\nKeep the plan concise enough to scan quickly, but detailed enough to execute effectively.\n\n### When to Submit\n\nYour plan is ready when you've addressed all ambiguities and it covers: what to change, which files to modify, what existing code to reuse, and how to verify. Call plannotator_submit_plan with the path to your plan file to submit for review.\n\n### Revising After Feedback\n\nWhen the user denies a plan with feedback:\n1. Read the plan file to see the current plan.\n2. Use the edit tool to make targeted changes addressing the feedback — do NOT rewrite the entire file.\n3. Call plannotator_submit_plan again with the same filePath to resubmit.\n\n### Ending Your Turn\n\nYour turn should only end by either:\n- Asking the user a question to gather more information.\n- Calling plannotator_submit_plan when the plan is ready for review.\n\nDo not end your turn without doing one of these two things."
|
|
7
|
+
},
|
|
8
|
+
"executing": {
|
|
9
|
+
"systemPrompt": "[PLANNOTATOR - EXECUTING PLAN]\nFull tool access is enabled. Execute the plan from ${planFilePath}.\n\nRemaining steps:\n${todoList}\n\nExecute each step in order. After completing a step, include [DONE:n] in your response where n is the step number."
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|