@mrclrchtr/supi-review 4.3.0 → 4.5.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.
Files changed (35) hide show
  1. package/README.md +16 -3
  2. package/node_modules/@mrclrchtr/supi-code-intelligence/README.md +83 -218
  3. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  5. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  8. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  9. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  10. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +1 -1
  11. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +6 -6
  12. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  13. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  14. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  15. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  16. package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +8 -7
  17. package/node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts +2 -2
  18. package/node_modules/@mrclrchtr/supi-code-intelligence/src/{ui/markdown → overview}/overview-data.ts +1 -1
  19. package/node_modules/@mrclrchtr/supi-code-intelligence/src/overview/types.ts +21 -0
  20. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/collect.ts +39 -26
  21. package/node_modules/@mrclrchtr/supi-code-intelligence/src/{ui/markdown → session/orientation}/gather.ts +44 -24
  22. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-types.ts +23 -0
  23. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-workflow.ts +1 -11
  24. package/node_modules/@mrclrchtr/supi-code-intelligence/src/types/execution.ts +1 -1
  25. package/node_modules/@mrclrchtr/supi-code-intelligence/src/types/index.ts +1 -1
  26. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  27. package/package.json +4 -4
  28. package/src/config.ts +19 -1
  29. package/src/review.ts +7 -0
  30. package/src/tool/agent-review-tools.ts +11 -1
  31. package/src/tool/child-session-runner.ts +1 -2
  32. package/src/tool/post-review-policy.ts +102 -0
  33. package/node_modules/@mrclrchtr/supi-code-intelligence/src/types/details.ts +0 -18
  34. package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/types.ts +0 -75
  35. /package/node_modules/@mrclrchtr/supi-code-intelligence/src/{ui/markdown → overview}/overview.ts +0 -0
@@ -0,0 +1,102 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { wrapExtensionContext } from "@mrclrchtr/supi-core/context";
3
+ import type { PostReviewPolicy } from "../config.ts";
4
+ import type { ReviewBatchDetails, ReviewOutputReference } from "../types.ts";
5
+
6
+ function findingCount(details: ReviewBatchDetails): number {
7
+ return details.results.reduce(
8
+ (total, result) => total + (result.status === "completed" ? result.findings.length : 0),
9
+ 0,
10
+ );
11
+ }
12
+
13
+ function policyInstructions(policy: PostReviewPolicy): string[] {
14
+ switch (policy) {
15
+ case "ask":
16
+ return [
17
+ "Do not inspect or edit yet. Ask the user what to do, using ask_user when available and a plain question otherwise.",
18
+ "Offer: Verify findings, Verify + fix confirmed findings, Fix all, Fix selected, Report only. If Fix selected is chosen, ask which findings in a follow-up selection.",
19
+ ];
20
+ case "verify":
21
+ return [
22
+ "Independently confirm or refute every finding against the reviewed target. Do not edit yet.",
23
+ "Present the verification, then ask whether to fix all confirmed findings, fix selected confirmed findings, or report only.",
24
+ ];
25
+ case "verify-and-fix":
26
+ return [
27
+ "Independently confirm or refute every finding, then fix every confirmed finding that still applies in the live checkout.",
28
+ ];
29
+ case "fix":
30
+ return ["Fix every reported finding, including non-blocking and low-confidence findings."];
31
+ case "report":
32
+ return [
33
+ "Report the review result and stop. Do not verify findings, edit code, or ask a post-review question.",
34
+ ];
35
+ }
36
+ }
37
+
38
+ /** Build the model-facing containing-Agent protocol for a review that returned findings. */
39
+ export function buildPostReviewInstruction(
40
+ policy: PostReviewPolicy,
41
+ details: ReviewBatchDetails,
42
+ output: ReviewOutputReference,
43
+ ): string | undefined {
44
+ const findings = findingCount(details);
45
+ if (findings === 0) return undefined;
46
+
47
+ const lines = [
48
+ `The completed review reported ${findings} finding${findings === 1 ? "" : "s"}. The configured Post-Review Policy is \`${policy}\`.`,
49
+ "A direct user instruction specifically about what to do with this review's findings overrides the configured default. Generic authorization to edit code and your own prior plan do not.",
50
+ ];
51
+ if (output.nextOffset !== undefined) {
52
+ lines.push(
53
+ `Before responding, retrieve every remaining output page with supi_review_output, starting with ${JSON.stringify({ artifactId: output.artifactId, offset: output.nextOffset })}.`,
54
+ );
55
+ }
56
+ if (details.results.some((result) => result.status !== "completed")) {
57
+ lines.push(
58
+ "Some Review Tasks did not complete. Act on available findings from completed tasks and report the incomplete tasks.",
59
+ );
60
+ }
61
+ lines.push(
62
+ ...policyInstructions(policy),
63
+ "Whenever this flow results in fixes, reconcile duplicate findings and verify incompatible ones. If the live checkout differs from the reviewed after-state, re-verify affected findings against live code and fix those that still apply.",
64
+ "After non-trivial edits, run an existing targeted check when available; report what ran or why it was skipped.",
65
+ );
66
+ return wrapExtensionContext("supi-review", lines.join("\n"), {
67
+ kind: "post-review-policy",
68
+ policy,
69
+ });
70
+ }
71
+
72
+ /** Append the configured protocol to an agent-facing review tool result. */
73
+ export function withPostReviewInstruction(
74
+ text: string,
75
+ policy: PostReviewPolicy,
76
+ details: ReviewBatchDetails,
77
+ output: ReviewOutputReference,
78
+ ): string {
79
+ const instruction = buildPostReviewInstruction(policy, details, output);
80
+ return instruction ? `${text}\n\n${instruction}` : text;
81
+ }
82
+
83
+ /** Queue the post-review Agent turn used by the interactive command surface. */
84
+ export function queuePostReviewTurn(
85
+ pi: ExtensionAPI,
86
+ policy: PostReviewPolicy,
87
+ details: ReviewBatchDetails,
88
+ output: ReviewOutputReference,
89
+ ): void {
90
+ if (policy === "report") return;
91
+ const content = buildPostReviewInstruction(policy, details, output);
92
+ if (!content) return;
93
+ pi.sendMessage(
94
+ {
95
+ customType: "supi-review-followup",
96
+ content,
97
+ display: false,
98
+ details: { policy, output },
99
+ },
100
+ { deliverAs: "followUp", triggerTurn: true },
101
+ );
102
+ }
@@ -1,18 +0,0 @@
1
- /**
2
- * Compatibility export for tool-result detail shapes.
3
- *
4
- * Public code-intelligence details are assembled in `src/tool/result/`.
5
- * Import new result assembly code from `../tool/result/types.ts` directly.
6
- */
7
- export type {
8
- AnchoredResolutionMetadata,
9
- AnchoredResolutionSource,
10
- ContextDetails,
11
- DisambiguationCandidate,
12
- HealthDetails,
13
- HealthSectionDetails,
14
- InspectDetails,
15
- OrientationSectionDetails,
16
- ResolveDetails,
17
- SearchDetails,
18
- } from "../tool/result/types.ts";
@@ -1,75 +0,0 @@
1
- // Shared typed data interfaces between use-case and presentation layers.
2
-
3
- import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
4
- import type { ArchitectureModel } from "../../analysis/architecture/model.ts";
5
- import type { CodeProvider } from "../../analysis/provider.ts";
6
- import type { AnchorKind } from "../../session/target-store.ts";
7
- import type { InspectDetails } from "../../types/details.ts";
8
-
9
- // ── Overview use-case ───────────────────────────────────────────────
10
-
11
- export interface OverviewModule {
12
- name: string;
13
- shortName: string;
14
- description: string | null;
15
- /** Manifest-declared package relationships to other discovered packages. */
16
- declaredDependencies: string[];
17
- /** Field-labelled manifest path declarations, never selected by precedence. */
18
- declaredEntrypoints: string[];
19
- }
20
-
21
- export interface OverviewData {
22
- projectName: string | null;
23
- projectDescription: string | null;
24
- modules: OverviewModule[];
25
- /** Detected source languages (e.g. ["ts", "js", "py"]). */
26
- detectedLanguages: string[] | null;
27
- }
28
-
29
- // ── Inspect use-case ─────────────────────────────────────────────────
30
-
31
- export interface InspectInput {
32
- file: string;
33
- line: number;
34
- character: number;
35
- maxResults?: number;
36
- }
37
-
38
- export interface InspectDeps {
39
- provider: CodeProvider | null;
40
- cwd: string;
41
- lspRuntime: WorkspaceLspRuntimeState;
42
- }
43
-
44
- export interface InspectUseCaseResult {
45
- content: string;
46
- details: InspectDetails;
47
- }
48
-
49
- // ── Orientation use-case ─────────────────────────────────────────────────
50
-
51
- export type OrientationSection = "defs" | "docs" | "diagnostics";
52
-
53
- export interface OrientationTarget {
54
- file: string;
55
- line: number;
56
- character: number;
57
- name: string | null;
58
- kind: string | null;
59
- /** Which anchor this target carries; strict consumers refuse declaration anchors. */
60
- anchorKind: AnchorKind;
61
- }
62
-
63
- export interface OrientationInput {
64
- target?: OrientationTarget | null;
65
- /** Resolved orientation focus path for project/module/directory/file orientation. */
66
- focus?: string;
67
- maxResults?: number;
68
- }
69
-
70
- export interface OrientationDeps {
71
- model: ArchitectureModel;
72
- provider: CodeProvider | null;
73
- cwd: string;
74
- lspRuntime: WorkspaceLspRuntimeState;
75
- }