@diegopetrucci/pi-extensions 0.1.24 → 0.1.26

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.
@@ -0,0 +1,135 @@
1
+ # triage-comments
2
+
3
+ Adds `/triage-comments` plus a read-only `triage_comments` subagent tool for evidence-based review-comment triage.
4
+
5
+ Use it when you want The Last Harness to inspect selected PR feedback, classify whether each comment is valid, cite local evidence, draft review-thread responses, and propose handling options. It does **not** implement changes; after triage, the main agent should ask which handling option to take before editing anything.
6
+
7
+ ## Install
8
+
9
+ ### Standalone npm package
10
+
11
+ ```bash
12
+ pi install npm:@diegopetrucci/pi-triage-comments
13
+ ```
14
+
15
+ ### Collection package
16
+
17
+ ```bash
18
+ pi install npm:@diegopetrucci/pi-extensions
19
+ ```
20
+
21
+ ### GitHub package
22
+
23
+ ```bash
24
+ pi install git:github.com/diegopetrucci/pi-extensions
25
+ ```
26
+
27
+ Then reload pi:
28
+
29
+ ```text
30
+ /reload
31
+ ```
32
+
33
+ ## Slash command flow
34
+
35
+ The extension registers `/triage-comments` as an interactive intake flow.
36
+
37
+ ```text
38
+ /triage-comments
39
+ /triage-comments paste
40
+ /triage-comments pr 123
41
+ /triage-comments pr https://github.com/owner/repo/pull/123
42
+ /triage-comments 123
43
+ ```
44
+
45
+ - With no arguments, The Last Harness asks whether to paste feedback or fetch PR comments.
46
+ - `paste` opens an editor for multiline reviewer feedback, then sends one selected feedback item to the main agent.
47
+ - `pr <PR URL or number>` fetches PR review comments, PR issue comments, and review bodies with `gh`, displays them as numbered items with stable IDs, and asks whether to investigate all displayed comments or an explicit subset such as `1,3-5`.
48
+ - If more than 50 comments are fetched, you must choose a subset of at most 50 comments.
49
+ - The command sends a normal user message instructing the main agent to call `triage_comments` with the selected payload. It does not directly edit files or post GitHub replies.
50
+
51
+ The slash command requires interactive UI mode for the editor, PR comment display, and all/subset confirmation. In non-UI modes it prints usage instead of running the intake flow.
52
+
53
+ ## GitHub CLI requirements
54
+
55
+ PR mode requires:
56
+
57
+ - running inside a git checkout;
58
+ - GitHub CLI `gh` installed and on `PATH`;
59
+ - `gh auth login` completed for the target host/repository, including private repositories;
60
+ - a PR number that `gh pr view` can resolve from the current checkout, or a full GitHub PR URL.
61
+
62
+ The command uses read-only `gh` calls to fetch PR metadata, review comments, issue comments, and review bodies. It does not post comments, submit reviews, checkout branches, or mutate GitHub.
63
+
64
+ ## `triage_comments` tool behavior
65
+
66
+ The tool accepts selected comments and optional PR, base, diff, and caller context. Comment entries can be plain strings or objects with fields such as `body`, `path`, `line`, `startLine`, `side`, `diffHunk`, `author`, `url`, `createdAt`, and `metadata`.
67
+
68
+ When called, it launches an isolated in-memory subagent with:
69
+
70
+ - no inherited extensions, skills, prompt templates, themes, context files, or agents files;
71
+ - read-only tools only: `read`, `grep`, `find`, `ls`, and guarded `bash`;
72
+ - a local-checkout path guard for file inspection;
73
+ - a bash guard that allows only direct read-only `git`, `gh`, or `pwd` invocations and blocks write/edit tools, shell pipelines, redirection, destructive git commands, and mutating `gh`/GitHub API calls;
74
+ - a fixed triage output format with verdicts, evidence, reasoning, suggested responses, handling options, and a list of read-only checks performed.
75
+
76
+ Verdicts are one of `valid`, `invalid`, `partially valid`, `subjective`, or `needs clarification`.
77
+
78
+ ## Read-only and approval guarantees
79
+
80
+ - The slash command only collects/selects comments and asks the main agent to run triage.
81
+ - The subagent is explicitly instructed not to implement changes.
82
+ - Runtime guards block write tools, filesystem mutation through shell syntax, mutating git commands, and mutating GitHub CLI/API calls.
83
+ - The generated prompt tells the main agent to summarize findings and ask which handling option to take before implementation.
84
+ - Suggested responses are drafts for the user/agent to adapt; the extension does not post them to GitHub.
85
+
86
+ ## Examples
87
+
88
+ Paste a reviewer note:
89
+
90
+ ```text
91
+ /triage-comments paste
92
+ ```
93
+
94
+ Fetch a PR, inspect comments 1 and 3 through 5, then triage only that subset:
95
+
96
+ ```text
97
+ /triage-comments pr https://github.com/owner/repo/pull/123
98
+ # selection prompt: 1,3-5
99
+ ```
100
+
101
+ Ask the agent to use the tool directly:
102
+
103
+ ```text
104
+ Use triage_comments on this review comment and do not implement anything yet:
105
+
106
+ {
107
+ "comments": [
108
+ {
109
+ "body": "This helper appears to ignore the configured timeout.",
110
+ "path": "src/client.ts",
111
+ "line": 42,
112
+ "url": "https://github.com/owner/repo/pull/123#discussion_r123"
113
+ }
114
+ ],
115
+ "pr": {
116
+ "number": 123,
117
+ "repository": "owner/repo"
118
+ },
119
+ "context": "Classify the comment and suggest response options only."
120
+ }
121
+ ```
122
+
123
+ Typical output includes a summary, per-comment verdicts with citations, a suggested reply, handling options, and the reminder:
124
+
125
+ ```text
126
+ Do not implement changes from this triage automatically; ask the parent/user which option to take before implementation.
127
+ ```
128
+
129
+ ## Limitations
130
+
131
+ - At most 50 comments can be triaged in one tool call.
132
+ - The subagent has an 8-turn and 8-minute budget.
133
+ - PR mode depends on the GitHub API data available to `gh`; authentication, permissions, host configuration, and API availability can affect what is fetched.
134
+ - The tool validates against the current local checkout. If the checkout does not match the PR head/base or supplied diff context, the result may be `needs clarification` or call out stale/missing evidence.
135
+ - Paste mode treats the editor contents as one feedback item; use PR mode or direct tool calls for multiple separately numbered comments.