@gtheys/pi-flow 0.0.0-stage → 0.2.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/README.md +833 -2
- package/adhoc/tracker.ts +360 -0
- package/aven/client.ts +996 -0
- package/aven/status.ts +395 -0
- package/brainstorm/args.ts +24 -0
- package/brainstorm/artifact.ts +67 -0
- package/brainstorm/paths.ts +43 -0
- package/brainstorm/prompt.ts +172 -0
- package/brainstorm/refs.ts +41 -0
- package/config.schema.json +161 -0
- package/config.ts +577 -0
- package/feedback/args.ts +21 -0
- package/feedback/prompt.ts +177 -0
- package/feedback/triage.ts +88 -0
- package/flow/agent-role.ts +46 -0
- package/flow/answer-wake.ts +212 -0
- package/flow/answer.ts +183 -0
- package/flow/args.ts +48 -0
- package/flow/ask-emitter.ts +331 -0
- package/flow/attribution.ts +145 -0
- package/flow/aven-resolve-exec.ts +95 -0
- package/flow/aven-resolve.ts +80 -0
- package/flow/awaiting-approval.ts +32 -0
- package/flow/binding-heal.ts +68 -0
- package/flow/cost-autopush.ts +162 -0
- package/flow/cost-command.ts +122 -0
- package/flow/cost-rows-journal.ts +296 -0
- package/flow/cost-rows-push.ts +112 -0
- package/flow/cost-rows-rows.ts +209 -0
- package/flow/cost-rows.ts +228 -0
- package/flow/cost.ts +173 -0
- package/flow/durable-refs.ts +287 -0
- package/flow/effect-gate.ts +137 -0
- package/flow/ensure-labels.ts +44 -0
- package/flow/frame.ts +172 -0
- package/flow/gates.ts +211 -0
- package/flow/jira-ref.ts +212 -0
- package/flow/label-gate.ts +149 -0
- package/flow/land-gate.ts +98 -0
- package/flow/lifecycle-policy.ts +162 -0
- package/flow/live-wait.ts +52 -0
- package/flow/liveness.ts +408 -0
- package/flow/loop-deps.ts +210 -0
- package/flow/loop-settle.ts +531 -0
- package/flow/loop.ts +437 -0
- package/flow/orchestrate.ts +45 -0
- package/flow/phase-command.ts +287 -0
- package/flow/phase-emoji.ts +13 -0
- package/flow/phase-prompts.ts +251 -0
- package/flow/picker.ts +307 -0
- package/flow/push.ts +475 -0
- package/flow/reconcile-command.ts +253 -0
- package/flow/reconcile-deps.ts +329 -0
- package/flow/reconcile.ts +738 -0
- package/flow/ref-kind.ts +80 -0
- package/flow/resume-picker.ts +222 -0
- package/flow/resume.ts +116 -0
- package/flow/run-health.ts +252 -0
- package/flow/run-liveness.ts +33 -0
- package/flow/state-metrics.ts +559 -0
- package/flow/status.ts +105 -0
- package/flow/step-output.ts +416 -0
- package/flow/steps.ts +73 -0
- package/flow/terminal-purge.ts +281 -0
- package/flow/turn-generation.ts +19 -0
- package/flow/v2-emission.ts +381 -0
- package/flow/v2-resume.ts +100 -0
- package/flow/vocabulary.ts +261 -0
- package/flow/widget.ts +448 -0
- package/flow/worktree-context.ts +136 -0
- package/flow-diagram/assemble.ts +27 -0
- package/flow-diagram/command.ts +252 -0
- package/flow-diagram/translate.ts +862 -0
- package/flow-diagram/vendor/harness-profiler/LICENSE +21 -0
- package/flow-diagram/vendor/harness-profiler/PIN.md +64 -0
- package/flow-diagram/vendor/harness-profiler/hp.js +960 -0
- package/flow-diagram/vendor/harness-profiler/load.ts +66 -0
- package/flow-diagram/vendor/harness-profiler/view.html +436 -0
- package/gates.ts +20 -0
- package/herdr/sync.ts +355 -0
- package/herdr/viewer.ts +432 -0
- package/implement/args.ts +21 -0
- package/implement/prompt.ts +98 -0
- package/implement/retry.ts +57 -0
- package/implement/routing.ts +31 -0
- package/index.ts +3206 -0
- package/mode-profile.ts +56 -0
- package/package.json +205 -4
- package/phase-state.ts +18 -0
- package/plan/args.ts +20 -0
- package/plan/prompt.ts +251 -0
- package/plan/size-check.ts +46 -0
- package/plan-tools/helpers.ts +177 -0
- package/plan-tools/jira-branch-tool.ts +54 -0
- package/plan-tools/jira-branch.ts +109 -0
- package/plan-tools/jira-issue.ts +85 -0
- package/plan-tools/resolve-feature-path.ts +30 -0
- package/plan-tools/resolve-notes-path.ts +37 -0
- package/plan-tools/resolve-spec-path.ts +31 -0
- package/pr-quality/index.ts +908 -0
- package/review/LICENSE +19 -0
- package/review/deviation.ts +252 -0
- package/review/review.ts +3053 -0
- package/review/sem-guidance.d.mts +8 -0
- package/review/sem-guidance.mjs +89 -0
- package/review/verdict.ts +13 -0
- package/run-state.ts +2046 -0
- package/run-title.ts +91 -0
- package/server/consumer.ts +146 -0
- package/server/daemon.ts +1094 -0
- package/server/lifecycle.ts +679 -0
- package/server/pending.ts +267 -0
- package/server/staleness.ts +320 -0
- package/server/writer.ts +86 -0
- package/shared/diff-base.ts +138 -0
- package/shared/flow-base.ts +210 -0
- package/shared/sonarqube-utils.ts +415 -0
- package/shared/stable-range.ts +102 -0
- package/slugify.ts +13 -0
- package/sonarqube/sonarqube.ts +821 -0
- package/spec-review/approve.ts +91 -0
- package/spec-review/args.ts +21 -0
- package/spec-review/aven-spec.ts +142 -0
- package/spec-review/commands.ts +336 -0
- package/spec-review/escape-regexp.ts +7 -0
- package/spec-review/open-in-pane.ts +166 -0
- package/spec-review/picker.ts +74 -0
- package/spec-review/prompt.ts +72 -0
- package/spec-review/publish-args.ts +33 -0
- package/spec-review/publish.ts +210 -0
- package/telemetry/attributes.ts +118 -0
- package/telemetry/content.ts +140 -0
- package/telemetry/dispatch.ts +521 -0
- package/telemetry/exporter.ts +124 -0
- package/telemetry/index.ts +776 -0
- package/telemetry/loki.ts +224 -0
- package/tools/code-review-parse.ts +518 -0
- package/tools/code-review.ts +312 -0
- package/tools/deviation.ts +737 -0
- package/tools/flow-submit.ts +302 -0
- package/tools/land.ts +608 -0
- package/tools/phase-complete.ts +476 -0
- package/tools/result.ts +18 -0
- package/tools/review-deps.ts +44 -0
- package/tools/run-attempt.ts +312 -0
- package/tools/spec-approve.ts +265 -0
- package/validate/args.ts +22 -0
- package/validate/deviation-gate.ts +229 -0
- package/validate/gate-target.ts +371 -0
- package/validate/gate.ts +79 -0
- package/validate/paths.ts +20 -0
- package/validate/personal.ts +104 -0
- package/validate/prompt.ts +525 -0
- package/validate/review-gate.ts +134 -0
- package/validate/subtask-range.ts +113 -0
- package/work-mode.ts +19 -0
- package/worktree/bootstrap.ts +243 -0
- package/worktree/branch.ts +168 -0
- package/worktree/herdr.ts +447 -0
- package/worktree/index.ts +1447 -0
- package/worktree/orphan.ts +384 -0
- package/worktree/remove-guards.ts +99 -0
- package/worktree/residue.ts +216 -0
- package/worktree/sweep.ts +526 -0
package/mode-profile.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// AIDEV-NOTE: PMR-T22H — data-only mode table. Every mode-keyed decision
|
|
2
|
+
// value lives here so prompts and gates read the value instead of
|
|
3
|
+
// re-deriving it from `mode === 'work'`; the prompt prose itself stays in
|
|
4
|
+
// the prompt modules. Add a row here when a mode decision is data, not
|
|
5
|
+
// prose. PMR-V31Z 1.1 removed the `landingRoute` row: landing is no longer
|
|
6
|
+
// mode-keyed data (flow_land's route param is optional with default 'pr';
|
|
7
|
+
// the param itself is deleted with the merge-main leg in phase 4).
|
|
8
|
+
import type { Phase } from './flow/orchestrate.ts'
|
|
9
|
+
import type { WorkMode } from './work-mode.ts'
|
|
10
|
+
|
|
11
|
+
export interface ModeProfile {
|
|
12
|
+
/** Gate-time diff-base resolution. work: the flowbasesha recorded at
|
|
13
|
+
* worktree create (legacy fallback: the recorded branch). personal: the
|
|
14
|
+
* creation-time flowbasesha with a fail-closed integrity probe —
|
|
15
|
+
* merge-base(HEAD, <local flowbase branch>) must EQUAL the recorded sha
|
|
16
|
+
* (PMR-5NZB; the ONE shared resolver is shared/stable-range.ts, consumed
|
|
17
|
+
* by every personal gate per the PMR-R4AP single-resolver rule). A
|
|
18
|
+
* mid-flow rebase or base-merge refuses ('diverged') — never re-anchor
|
|
19
|
+
* to a moving base, never the base's upstream ref (PMR-MH1Y, DQ7Z):
|
|
20
|
+
* personal never pushes, upstream lags local main. This REPLACES the
|
|
21
|
+
* PMR-7N3D gate-time merge-base policy (replaced-mechanism history:
|
|
22
|
+
* personal used to re-anchor to merge-base(HEAD, <local branch>) at
|
|
23
|
+
* gate time). */
|
|
24
|
+
baseResolution: 'recorded-sha' | 'recorded-sha-integrity'
|
|
25
|
+
/** Env var naming the external notes/artifact root for this mode. */
|
|
26
|
+
artifactRootEnv: 'LLM_NOTES_ROOT' | 'PERSONAL_FEATURES'
|
|
27
|
+
/** Whether Jira IDs are valid flow/research refs (work repos sync Jira;
|
|
28
|
+
* personal repos are aven-only — PMR-PCVK ambiguity rule). */
|
|
29
|
+
acceptsJiraRefs: boolean
|
|
30
|
+
/** Branch derivation rule for the implement phase. Work mode derives via
|
|
31
|
+
* jira_create_branch; personal mode's worktree-tool branch carries the
|
|
32
|
+
* active flow ref — `<type>/<REF>-<slug>`, bare `<type>/<slug>` outside a
|
|
33
|
+
* flow (PMR-902B; prose lives in implement/prompt.ts). */
|
|
34
|
+
branchRule: 'jira_create_branch' | 'ref-prefixed-slug'
|
|
35
|
+
/** Phases /flow runs, in order. Both modes run the full PIV order —
|
|
36
|
+
* personal feedback is its own wrap-up phase (PMR-81SX, unfolding
|
|
37
|
+
* PMR-GFM5's earlier fold). */
|
|
38
|
+
phases: readonly Phase[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const MODE_PROFILE: Record<WorkMode, ModeProfile> = {
|
|
42
|
+
work: {
|
|
43
|
+
baseResolution: 'recorded-sha',
|
|
44
|
+
artifactRootEnv: 'LLM_NOTES_ROOT',
|
|
45
|
+
acceptsJiraRefs: true,
|
|
46
|
+
branchRule: 'jira_create_branch',
|
|
47
|
+
phases: ['plan', 'implement', 'validate', 'feedback'],
|
|
48
|
+
},
|
|
49
|
+
personal: {
|
|
50
|
+
baseResolution: 'recorded-sha-integrity',
|
|
51
|
+
artifactRootEnv: 'PERSONAL_FEATURES',
|
|
52
|
+
acceptsJiraRefs: false,
|
|
53
|
+
branchRule: 'ref-prefixed-slug',
|
|
54
|
+
phases: ['plan', 'implement', 'validate', 'feedback'],
|
|
55
|
+
},
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,207 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtheys/pi-flow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Pi extension — PIV flow orchestrator (phase commands, gate tools, review/sonarqube/pr-quality, work-mode detection, run-state journal)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --test test/*.test.ts test/*.test.mjs",
|
|
11
|
+
"test:stress": "node scripts/stress.mjs"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/gtheys/pi-my-rifle-ext.git",
|
|
17
|
+
"directory": "packages/pi-flow"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"README.md",
|
|
24
|
+
"adhoc/tracker.ts",
|
|
25
|
+
"flow-diagram/command.ts",
|
|
26
|
+
"flow-diagram/translate.ts",
|
|
27
|
+
"flow-diagram/assemble.ts",
|
|
28
|
+
"flow-diagram/vendor/harness-profiler/hp.js",
|
|
29
|
+
"flow-diagram/vendor/harness-profiler/load.ts",
|
|
30
|
+
"flow-diagram/vendor/harness-profiler/view.html",
|
|
31
|
+
"flow-diagram/vendor/harness-profiler/LICENSE",
|
|
32
|
+
"flow-diagram/vendor/harness-profiler/PIN.md",
|
|
33
|
+
"aven/client.ts",
|
|
34
|
+
"aven/status.ts",
|
|
35
|
+
"config.schema.json",
|
|
36
|
+
"config.ts",
|
|
37
|
+
"feedback/args.ts",
|
|
38
|
+
"feedback/prompt.ts",
|
|
39
|
+
"feedback/triage.ts",
|
|
40
|
+
"flow/answer.ts",
|
|
41
|
+
"flow/answer-wake.ts",
|
|
42
|
+
"flow/awaiting-approval.ts",
|
|
43
|
+
"flow/effect-gate.ts",
|
|
44
|
+
"flow/args.ts",
|
|
45
|
+
"flow/ask-emitter.ts",
|
|
46
|
+
"flow/live-wait.ts",
|
|
47
|
+
"flow/agent-role.ts",
|
|
48
|
+
"flow/attribution.ts",
|
|
49
|
+
"flow/aven-resolve-exec.ts",
|
|
50
|
+
"flow/aven-resolve.ts",
|
|
51
|
+
"flow/binding-heal.ts",
|
|
52
|
+
"flow/cost.ts",
|
|
53
|
+
"flow/cost-rows.ts",
|
|
54
|
+
"flow/cost-rows-journal.ts",
|
|
55
|
+
"flow/cost-rows-push.ts",
|
|
56
|
+
"flow/cost-rows-rows.ts",
|
|
57
|
+
"flow/push.ts",
|
|
58
|
+
"flow/reconcile.ts",
|
|
59
|
+
"flow/reconcile-deps.ts",
|
|
60
|
+
"flow/liveness.ts",
|
|
61
|
+
"flow/reconcile-command.ts",
|
|
62
|
+
"flow/cost-autopush.ts",
|
|
63
|
+
"flow/terminal-purge.ts",
|
|
64
|
+
"flow/turn-generation.ts",
|
|
65
|
+
"flow/cost-command.ts",
|
|
66
|
+
"flow/durable-refs.ts",
|
|
67
|
+
"flow/step-output.ts",
|
|
68
|
+
"telemetry/attributes.ts",
|
|
69
|
+
"telemetry/content.ts",
|
|
70
|
+
"telemetry/dispatch.ts",
|
|
71
|
+
"telemetry/exporter.ts",
|
|
72
|
+
"telemetry/index.ts",
|
|
73
|
+
"telemetry/loki.ts",
|
|
74
|
+
"flow/ensure-labels.ts",
|
|
75
|
+
"flow/jira-ref.ts",
|
|
76
|
+
"flow/label-gate.ts",
|
|
77
|
+
"flow/land-gate.ts",
|
|
78
|
+
"flow/lifecycle-policy.ts",
|
|
79
|
+
"flow/loop.ts",
|
|
80
|
+
"flow/loop-deps.ts",
|
|
81
|
+
"flow/loop-settle.ts",
|
|
82
|
+
"flow/frame.ts",
|
|
83
|
+
"flow/gates.ts",
|
|
84
|
+
"flow/orchestrate.ts",
|
|
85
|
+
"flow/phase-command.ts",
|
|
86
|
+
"flow/phase-emoji.ts",
|
|
87
|
+
"flow/phase-prompts.ts",
|
|
88
|
+
"flow/picker.ts",
|
|
89
|
+
"flow/ref-kind.ts",
|
|
90
|
+
"flow/resume-picker.ts",
|
|
91
|
+
"flow/resume.ts",
|
|
92
|
+
"flow/run-health.ts",
|
|
93
|
+
"flow/run-liveness.ts",
|
|
94
|
+
"flow/state-metrics.ts",
|
|
95
|
+
"flow/status.ts",
|
|
96
|
+
"flow/steps.ts",
|
|
97
|
+
"flow/v2-emission.ts",
|
|
98
|
+
"flow/v2-resume.ts",
|
|
99
|
+
"flow/vocabulary.ts",
|
|
100
|
+
"flow/widget.ts",
|
|
101
|
+
"flow/worktree-context.ts",
|
|
102
|
+
"gates.ts",
|
|
103
|
+
"herdr/sync.ts",
|
|
104
|
+
"herdr/viewer.ts",
|
|
105
|
+
"implement/args.ts",
|
|
106
|
+
"implement/prompt.ts",
|
|
107
|
+
"implement/retry.ts",
|
|
108
|
+
"implement/routing.ts",
|
|
109
|
+
"index.ts",
|
|
110
|
+
"mode-profile.ts",
|
|
111
|
+
"phase-state.ts",
|
|
112
|
+
"plan-tools/helpers.ts",
|
|
113
|
+
"plan-tools/jira-branch-tool.ts",
|
|
114
|
+
"plan-tools/jira-branch.ts",
|
|
115
|
+
"plan-tools/jira-issue.ts",
|
|
116
|
+
"plan-tools/resolve-feature-path.ts",
|
|
117
|
+
"plan-tools/resolve-notes-path.ts",
|
|
118
|
+
"plan-tools/resolve-spec-path.ts",
|
|
119
|
+
"plan/args.ts",
|
|
120
|
+
"plan/prompt.ts",
|
|
121
|
+
"plan/size-check.ts",
|
|
122
|
+
"pr-quality/index.ts",
|
|
123
|
+
"brainstorm/args.ts",
|
|
124
|
+
"brainstorm/artifact.ts",
|
|
125
|
+
"brainstorm/paths.ts",
|
|
126
|
+
"brainstorm/prompt.ts",
|
|
127
|
+
"brainstorm/refs.ts",
|
|
128
|
+
"slugify.ts",
|
|
129
|
+
"review/LICENSE",
|
|
130
|
+
"review/deviation.ts",
|
|
131
|
+
"review/review.ts",
|
|
132
|
+
"review/sem-guidance.d.mts",
|
|
133
|
+
"review/sem-guidance.mjs",
|
|
134
|
+
"review/verdict.ts",
|
|
135
|
+
"run-state.ts",
|
|
136
|
+
"run-title.ts",
|
|
137
|
+
"server/consumer.ts",
|
|
138
|
+
"server/daemon.ts",
|
|
139
|
+
"server/lifecycle.ts",
|
|
140
|
+
"server/pending.ts",
|
|
141
|
+
"server/staleness.ts",
|
|
142
|
+
"server/writer.ts",
|
|
143
|
+
"shared/diff-base.ts",
|
|
144
|
+
"shared/flow-base.ts",
|
|
145
|
+
"shared/sonarqube-utils.ts",
|
|
146
|
+
"shared/stable-range.ts",
|
|
147
|
+
"sonarqube/sonarqube.ts",
|
|
148
|
+
"spec-review/approve.ts",
|
|
149
|
+
"spec-review/args.ts",
|
|
150
|
+
"spec-review/aven-spec.ts",
|
|
151
|
+
"spec-review/commands.ts",
|
|
152
|
+
"spec-review/escape-regexp.ts",
|
|
153
|
+
"spec-review/open-in-pane.ts",
|
|
154
|
+
"spec-review/picker.ts",
|
|
155
|
+
"spec-review/prompt.ts",
|
|
156
|
+
"spec-review/publish-args.ts",
|
|
157
|
+
"spec-review/publish.ts",
|
|
158
|
+
"tools/code-review-parse.ts",
|
|
159
|
+
"tools/code-review.ts",
|
|
160
|
+
"tools/deviation.ts",
|
|
161
|
+
"tools/flow-submit.ts",
|
|
162
|
+
"tools/land.ts",
|
|
163
|
+
"tools/phase-complete.ts",
|
|
164
|
+
"tools/result.ts",
|
|
165
|
+
"tools/review-deps.ts",
|
|
166
|
+
"tools/run-attempt.ts",
|
|
167
|
+
"tools/spec-approve.ts",
|
|
168
|
+
"validate/args.ts",
|
|
169
|
+
"validate/deviation-gate.ts",
|
|
170
|
+
"validate/gate-target.ts",
|
|
171
|
+
"validate/gate.ts",
|
|
172
|
+
"validate/paths.ts",
|
|
173
|
+
"validate/personal.ts",
|
|
174
|
+
"validate/prompt.ts",
|
|
175
|
+
"validate/review-gate.ts",
|
|
176
|
+
"validate/subtask-range.ts",
|
|
177
|
+
"work-mode.ts",
|
|
178
|
+
"worktree/bootstrap.ts",
|
|
179
|
+
"worktree/branch.ts",
|
|
180
|
+
"worktree/herdr.ts",
|
|
181
|
+
"worktree/index.ts",
|
|
182
|
+
"worktree/orphan.ts",
|
|
183
|
+
"worktree/remove-guards.ts",
|
|
184
|
+
"worktree/residue.ts",
|
|
185
|
+
"worktree/sweep.ts"
|
|
186
|
+
],
|
|
187
|
+
"pi": {
|
|
188
|
+
"extensions": [
|
|
189
|
+
"./index.ts"
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
"peerDependencies": {
|
|
193
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
194
|
+
"@earendil-works/pi-tui": "*",
|
|
195
|
+
"@mariozechner/pi-tui": "*",
|
|
196
|
+
"typebox": "*"
|
|
197
|
+
},
|
|
198
|
+
"devDependencies": {
|
|
199
|
+
"@mariozechner/pi-tui": "npm:@earendil-works/pi-tui@^1.7.0"
|
|
200
|
+
},
|
|
201
|
+
"dependencies": {
|
|
202
|
+
"@gtheys/pi-interactive-subagents": "0.2.0"
|
|
203
|
+
},
|
|
204
|
+
"optionalDependencies": {
|
|
205
|
+
"@gtheys/rifle-batteries": "0.2.0"
|
|
206
|
+
}
|
|
207
|
+
}
|
package/phase-state.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// AIDEV-NOTE: Shared phase-state vocabulary for the PIV flow (PMR-Z2K7:
|
|
2
|
+
// research left the lifecycle — 'researched' and 'research-skipped' were
|
|
3
|
+
// removed). Labels must exist in aven before first use — ensure-labels in
|
|
4
|
+
// index.ts creates them best-effort on session_start.
|
|
5
|
+
|
|
6
|
+
export const LIFECYCLE_LABELS = [
|
|
7
|
+
'planned',
|
|
8
|
+
'active',
|
|
9
|
+
'review-passed',
|
|
10
|
+
'done',
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
export const TYPE_LABELS = ['bug', 'oneshot', 'plan'] as const
|
|
14
|
+
|
|
15
|
+
export const ALL_LABELS: readonly string[] = [
|
|
16
|
+
...LIFECYCLE_LABELS,
|
|
17
|
+
...TYPE_LABELS,
|
|
18
|
+
]
|
package/plan/args.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// AIDEV-NOTE: Pure /plan arg parsing — unit-testable without pi. A Jira-style
|
|
2
|
+
// ref (PROJECT-123) routes to the existing feature-plan-aven skill in work
|
|
3
|
+
// mode; anything else is treated as an aven ref (personal mode).
|
|
4
|
+
|
|
5
|
+
import { parseRefKind } from '../flow/ref-kind.ts'
|
|
6
|
+
|
|
7
|
+
export type PlanArgs =
|
|
8
|
+
| { kind: 'jira'; jiraId: string }
|
|
9
|
+
| { kind: 'aven'; ref: string }
|
|
10
|
+
| { kind: 'help' }
|
|
11
|
+
|
|
12
|
+
export function parsePlanArgs(raw: string): PlanArgs {
|
|
13
|
+
const trimmed = raw.trim()
|
|
14
|
+
if (trimmed === '') return { kind: 'help' }
|
|
15
|
+
const parsed = parseRefKind(trimmed)
|
|
16
|
+
if (parsed.kind === 'jira') {
|
|
17
|
+
return { kind: 'jira', jiraId: parsed.jiraId }
|
|
18
|
+
}
|
|
19
|
+
return { kind: 'aven', ref: parsed.ref }
|
|
20
|
+
}
|
package/plan/prompt.ts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// AIDEV-NOTE: Prompt handed to the pi agent via sendUserMessage after /plan
|
|
2
|
+
// resolves args/mode/path. BOTH modes delegate planning to the user's
|
|
3
|
+
// existing feature-plan-aven skill BY NAME — its logic is never
|
|
4
|
+
// reimplemented here (regression-guarded by test). Personal mode keeps only
|
|
5
|
+
// the size check + ONESHOT escape inline (PMR-3HMZ); on a 'plan' verdict it
|
|
6
|
+
// delegates to the skill exactly like work mode (PMR-T6KF). The plan route
|
|
7
|
+
// ends in plan-state=review; flow_phase_complete (and the "planned" label)
|
|
8
|
+
// runs only after spec approval (PMR-QRJA) — the skill's resume ladder owns
|
|
9
|
+
// all resume states, so there is no tree-refresh or plan-state parsing here.
|
|
10
|
+
// PMR-C0YV — the prompt must describe the loop's post-label behavior: once
|
|
11
|
+
// the "planned" label lands, flow/loop.ts injects the implement prompt
|
|
12
|
+
// itself ("advancement is code, not model"), so the session's closing
|
|
13
|
+
// message must say the implement phase starts automatically and needs no
|
|
14
|
+
// action — never a halt claim or a manual next-phase instruction. The
|
|
15
|
+
// unapproved plan route is a graceful pause (loop-settle.ts pauses at plan), not a
|
|
16
|
+
// halt. Review P1 — the prompt ALSO reaches the standalone /plan command
|
|
17
|
+
// (phase-command.ts), which arms no loop: there nothing advances after the
|
|
18
|
+
// label lands. The advancement wording therefore covers BOTH delivery paths
|
|
19
|
+
// inline (prompt-only: no delivery-path input — the session knows which
|
|
20
|
+
// command started it and picks the matching branch).
|
|
21
|
+
|
|
22
|
+
export interface PlanPromptInput {
|
|
23
|
+
mode: 'work' | 'personal'
|
|
24
|
+
ref: string
|
|
25
|
+
/** /flow --yolo run: gates are skipped and the agent acts autonomously. */
|
|
26
|
+
yolo?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// AIDEV-NOTE: PMR-R5VB — approval is a HUMAN action (/flow answer <ref>
|
|
30
|
+
// approve, human-only; starts no model turn) that writes a durable receipt;
|
|
31
|
+
// the agent's spec_approve tool is receipt-gated and refuses without it.
|
|
32
|
+
// Raw aven plan-state edits are forbidden in flow context. flow_phase_complete
|
|
33
|
+
// instructions and the planned-label consequences are unchanged.
|
|
34
|
+
// AIDEV-NOTE: PMR-DMHH 4.1 — the receipt is the approval signal, and the
|
|
35
|
+
// auto-wake is the learning path: recording the answer wakes this session
|
|
36
|
+
// (in a flow run the loop re-arms and re-prompts), so the suffix tells the
|
|
37
|
+
// agent to proceed when re-prompted instead of waiting for a spoken
|
|
38
|
+
// "approve". A spoken word alone only means "go check" — spec_approve
|
|
39
|
+
// succeeds when the receipt exists and refuses fail-closed otherwise. The
|
|
40
|
+
// manual fallback when the wake misses is /flow <ref>.
|
|
41
|
+
// PMR-C0YV — the suffix also carries the auto-advance/closing-message
|
|
42
|
+
// contract below, and the unapproved route says "pauses" (not "halts"),
|
|
43
|
+
// matching loop-settle.ts's graceful-pause notify. Review P1 — the advancement
|
|
44
|
+
// paragraph covers both delivery paths: the /flow loop advances by itself;
|
|
45
|
+
// a standalone /plan command arms no loop, so there the human must run
|
|
46
|
+
// /flow <ref> to continue.
|
|
47
|
+
// AIDEV-NOTE: PMR-ZV9Y 1.2 step registry — the spec-approval wait below is
|
|
48
|
+
// the registered plan step, bound 1:1: approval wait = plan.spec-approval
|
|
49
|
+
// (flow/steps.ts STEP_REGISTRY.plan). The loop's spec-approval pause journals
|
|
50
|
+
// step-start{plan.spec-approval} (flow/loop-settle.ts emitStep in the pause
|
|
51
|
+
// branch), and the matching step-stop{plan.spec-approval} is journaled by the
|
|
52
|
+
// LOOP RESTART path — closeSpecApprovalStepIfOpen in flow/loop-settle.ts,
|
|
53
|
+
// called from start() in flow/loop.ts at the earliest faithful restart site,
|
|
54
|
+
// before the running snapshot (PMR-ZV9Y 2.1, fix round d4c8111; PMR-F79K
|
|
55
|
+
// removed the old advanceAfter fallback — start() is the ONLY close). The
|
|
56
|
+
// /flow answer command
|
|
57
|
+
// itself does not journal it; it writes the approval receipt and restarts the
|
|
58
|
+
// loop, and that restart emits the stop. So this prompt wait and those events
|
|
59
|
+
// name the same step; rename in flow/steps.ts must be reflected here, and the
|
|
60
|
+
// start() emission site must keep the pairing.
|
|
61
|
+
// AIDEV-NOTE: PMR-S7FQ — the route gate in step 3 below is the OTHER
|
|
62
|
+
// journalable plan boundary and it binds 1:1 to the evidence-only registry
|
|
63
|
+
// name
|
|
64
|
+
// route confirmation = plan.route-confirmed (flow/steps.ts STEP_REGISTRY.plan)
|
|
65
|
+
// EVIDENCE-ONLY means no machine emits step-start/step-stop for it (unlike
|
|
66
|
+
// plan.spec-approval above): flow_submit's step-output row is the whole record.
|
|
67
|
+
// Name it in the prompt because flow/step-output.ts:301-308 hints on any
|
|
68
|
+
// unregistered label once the phase registry is non-empty — before PMR-S7FQ an
|
|
69
|
+
// honest route-gate submission could only ever warn. Rename in flow/steps.ts
|
|
70
|
+
// must be reflected here and in docs/pi-flow-observability.md §5.
|
|
71
|
+
// PMR-AYMZ — the journaled ok=true row is now ALSO the evidence half of the
|
|
72
|
+
// mid-run oneshot plan-gate exemption in tools/phase-complete.ts (the live
|
|
73
|
+
// `oneshot` label is the other half); step 3/4 below name that gate role
|
|
74
|
+
// while the row itself stays advisory — it never replaces the
|
|
75
|
+
// ask_user_question confirmation or the phase-completion label.
|
|
76
|
+
const APPROVAL_SUFFIX = `
|
|
77
|
+
Approval is recorded by the HUMAN, not the agent: the human runs
|
|
78
|
+
"/flow answer <ticket ref> approve" (a human-only slash command that writes
|
|
79
|
+
the durable approval receipt). The receipt is the
|
|
80
|
+
approval signal — no spoken "approve" is required or expected. Your
|
|
81
|
+
spec_approve tool is receipt-gated: it refuses until that receipt exists.
|
|
82
|
+
Never run raw
|
|
83
|
+
"aven edit --metadata plan-state=approved" in flow context.
|
|
84
|
+
You learn the answer automatically: when the human records it, this
|
|
85
|
+
session is woken — in a flow run the loop re-arms and you are re-prompted;
|
|
86
|
+
proceed immediately when re-prompted (do not wait for a spoken "approve").
|
|
87
|
+
If you are not re-prompted, the wake missed — tell the human to run
|
|
88
|
+
"/flow <ticket ref>" to resume the flow.
|
|
89
|
+
When the receipt exists and the skill workflow is FULLY complete — including
|
|
90
|
+
the aven phase/subtask hierarchy — set the ticket status to
|
|
91
|
+
"todo" and call the flow_phase_complete tool with ref=<ticket ref> and
|
|
92
|
+
phase="plan" — it applies the "planned" label after re-checking the gates,
|
|
93
|
+
and its result confirms the label landed.
|
|
94
|
+
When the label lands: if this phase was started by the /flow loop, the loop
|
|
95
|
+
advances <ticket ref> into the implement phase automatically (advancement is
|
|
96
|
+
code, not model) — it injects the implement prompt into this session, and
|
|
97
|
+
your closing message must say the implement phase starts automatically and
|
|
98
|
+
that no action is needed. If instead this phase was started by the
|
|
99
|
+
standalone /plan command, no flow loop is armed and nothing advances by
|
|
100
|
+
itself — your closing message must tell the human to run /flow <ticket ref>
|
|
101
|
+
to continue into the implement phase — never claim the flow halts. The "planned" label lands
|
|
102
|
+
ONLY after approval: /implement routes oneshot vs plan from the type labels,
|
|
103
|
+
and a premature "planned" would misroute the run. Direct aven label edits on
|
|
104
|
+
lifecycle labels are blocked. If the user does not
|
|
105
|
+
approve during this phase, leave the ticket at plan-state "review" WITHOUT
|
|
106
|
+
the "planned" label and end the phase — the flow pauses at plan and
|
|
107
|
+
resumes automatically once the tree exists and the human records the
|
|
108
|
+
answer; if the auto-resume does not land, the human reruns "/flow
|
|
109
|
+
<ticket ref>" manually.`
|
|
110
|
+
|
|
111
|
+
// AIDEV-NOTE: raw Aven CLI commands use the main checkout's project path
|
|
112
|
+
// mappings; implementation remains isolated in the flow worktree.
|
|
113
|
+
const AVEN_CWD_RULE =
|
|
114
|
+
'Run every raw `aven` command from the main checkout (for example, `cd <main checkout> && aven ...`); keep implementation in the flow worktree.'
|
|
115
|
+
|
|
116
|
+
export function buildPlanPrompt(input: PlanPromptInput): string {
|
|
117
|
+
const header = `Plan phase (PIV flow). Mode: ${input.mode}. Ref: ${input.ref}.`
|
|
118
|
+
if (input.mode === 'personal' && input.yolo === true) {
|
|
119
|
+
return yoloPersonalPrompt(input.ref)
|
|
120
|
+
}
|
|
121
|
+
// PMR-C0YV review P1 — the closing-message contract covers both delivery
|
|
122
|
+
// paths: the loop injects implement itself; standalone /plan arms no loop,
|
|
123
|
+
// so there the human must be told to run /flow <ref> instead.
|
|
124
|
+
const oneshotClosing = `right away — its result confirms the "planned" label landed. Closing
|
|
125
|
+
message: when this phase runs under the /flow loop, tell the human the
|
|
126
|
+
loop advances ${input.ref} into the implement phase automatically and
|
|
127
|
+
that no action is needed; when this phase was started by the standalone
|
|
128
|
+
/plan command, no loop is armed — tell the human to run /flow
|
|
129
|
+
${input.ref} to start the implement phase — never claim the flow halts.
|
|
130
|
+
Skip step 5.`
|
|
131
|
+
if (input.mode === 'work') {
|
|
132
|
+
return `${header}
|
|
133
|
+
${AVEN_CWD_RULE}
|
|
134
|
+
Invoke the user's existing feature-plan-aven skill (engineering:feature-plan-aven)
|
|
135
|
+
for the Jira ticket ${input.ref}. Follow its workflow exactly — pickup,
|
|
136
|
+
interview, scout, planner, plan.md, aven phase/subtask hierarchy — unchanged.
|
|
137
|
+
${APPROVAL_SUFFIX}`
|
|
138
|
+
}
|
|
139
|
+
return `${header}
|
|
140
|
+
${AVEN_CWD_RULE}
|
|
141
|
+
Personal aven flow. Steps:
|
|
142
|
+
|
|
143
|
+
1. Fetch ticket ${input.ref} and any aven notes on it (extra info) with
|
|
144
|
+
"aven show ${input.ref}" and "aven context ${input.ref} --full" (there is no
|
|
145
|
+
"aven notes" subcommand; "aven note" only appends).
|
|
146
|
+
2. Run the size check (classifySize heuristic):
|
|
147
|
+
- single-file / one-module change with one test surface → 'oneshot'
|
|
148
|
+
- anything touching the data model, cross-package, or with multi-step
|
|
149
|
+
test implications → 'plan'
|
|
150
|
+
3. Use ask_user_question to present the verdict with its reasons and let the
|
|
151
|
+
human CONFIRM the route. Never proceed past this gate without explicit
|
|
152
|
+
confirmation.
|
|
153
|
+
Advisory: journal this route gate with the flow_submit tool using
|
|
154
|
+
step="plan.route-confirmed" and output.phase="plan" AND ok=true — the
|
|
155
|
+
registered evidence-only name, and ok=true is REQUIRED (a row without
|
|
156
|
+
it does not count, PMR-4ANM). The journaled ok=true event is the
|
|
157
|
+
evidence half of the mid-run oneshot plan-gate exemption (PMR-AYMZ):
|
|
158
|
+
together with the live "oneshot" label set in step 4 it satisfies the
|
|
159
|
+
plan gate. It still never replaces this human confirmation or the
|
|
160
|
+
phase-completion label.
|
|
161
|
+
4. If confirmed as oneshot:
|
|
162
|
+
- set the type label "oneshot" on the ticket (no epic),
|
|
163
|
+
- enrich the description with any useful aven-note context,
|
|
164
|
+
- the plan for this ticket IS its description; skip writing a plan file,
|
|
165
|
+
- set the ticket status to "todo",
|
|
166
|
+
- skip spec approval ENTIRELY: do NOT send the ticket into spec review
|
|
167
|
+
(no plan-state metadata, no spec_approve or /spec-review wait). The
|
|
168
|
+
step-3 route journal plus the label set here satisfy the plan gate
|
|
169
|
+
(PMR-AYMZ), so flow_phase_complete completes receipt-free. Call
|
|
170
|
+
the flow_phase_complete tool with ref=${input.ref} and phase="plan"
|
|
171
|
+
${oneshotClosing}
|
|
172
|
+
5. If confirmed as plan:
|
|
173
|
+
Invoke the user's existing feature-plan-aven skill
|
|
174
|
+
(engineering:feature-plan-aven) for the personal aven ticket ${input.ref}.
|
|
175
|
+
Follow its workflow exactly — pickup, interview, scout, planner, plan.md,
|
|
176
|
+
approval, aven phase/subtask hierarchy — unchanged.
|
|
177
|
+
The skill's resume ladder owns ALL resume states (no plan.md yet, draft,
|
|
178
|
+
review, approved, existing children) — do NOT re-check the epic tree or
|
|
179
|
+
parse plan-state here.
|
|
180
|
+
Approval is receipt-gated in flow context: the human runs
|
|
181
|
+
"/flow answer ${input.ref} approve" (human-only; writes the durable
|
|
182
|
+
receipt). Recording it wakes this session automatically — when you are
|
|
183
|
+
re-prompted, proceed and call the spec_approve tool. A spoken "approve"
|
|
184
|
+
alone means "go check": call spec_approve — it succeeds when the receipt
|
|
185
|
+
exists and refuses fail-closed without the receipt; on refusal tell the
|
|
186
|
+
human to record the answer with "/flow answer ${input.ref} approve". Do
|
|
187
|
+
NOT run raw "aven edit --metadata plan-state=approved" in flow context
|
|
188
|
+
(the feature-plan-aven skill's standalone approval outside a flow is
|
|
189
|
+
unchanged). The flow_phase_complete gate checks only lifecycle-label
|
|
190
|
+
order — it never reads plan-state — so call flow_phase_complete only
|
|
191
|
+
after the receipt-gated spec_approve has succeeded.
|
|
192
|
+
${APPROVAL_SUFFIX}`
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// AIDEV-NOTE: yolo plan 4.1 — yolo variant of the personal plan prompt. The
|
|
196
|
+
// size-check verdict is applied AUTOMATICALLY (no ask_user_question step),
|
|
197
|
+
// the verdict + reasons go into an aven note, and on a 'plan' verdict the
|
|
198
|
+
// agent writes the plan and calls spec_approve ITSELF (the yolo exemption in
|
|
199
|
+
// tools/spec-approve.ts makes it receipt-free) before flow_phase_complete in
|
|
200
|
+
// the SAME turn — so the loop pause at plan-state=review (flow/loop-settle.ts) is
|
|
201
|
+
// never reached. Oneshot keeps today's flow_phase_complete(plan) behavior.
|
|
202
|
+
function yoloPersonalPrompt(ref: string): string {
|
|
203
|
+
return `Plan phase (PIV flow). Mode: personal. Ref: ${ref}. YOLO run: gates are skipped — act autonomously, no human confirmation steps.
|
|
204
|
+
${AVEN_CWD_RULE}
|
|
205
|
+
Personal aven flow (yolo variant). Steps:
|
|
206
|
+
|
|
207
|
+
1. Fetch ticket ${ref} and any aven notes on it (extra info) with
|
|
208
|
+
"aven show ${ref}" and "aven context ${ref} --full" (there is no
|
|
209
|
+
"aven notes" subcommand; "aven note" only appends).
|
|
210
|
+
2. Run the size check (classifySize heuristic) on the ticket title and
|
|
211
|
+
description:
|
|
212
|
+
- single-file / one-module change with one test surface → 'oneshot'
|
|
213
|
+
- anything touching the data model, cross-package, or with multi-step
|
|
214
|
+
test implications → 'plan'
|
|
215
|
+
Apply the verdict AUTOMATICALLY — NO ask_user_question, NO human
|
|
216
|
+
confirmation. Immediately append an aven note recording the verdict and
|
|
217
|
+
the reasons (or "no signals" for oneshot), e.g.
|
|
218
|
+
"aven note ${ref} "size-check: <verdict> — <reasons>"".
|
|
219
|
+
Journal the same route boundary with the flow_submit tool using
|
|
220
|
+
step="plan.route-confirmed" and output.phase="plan" AND ok=true
|
|
221
|
+
(registered evidence-only name; ok=true is required for the row to
|
|
222
|
+
count, PMR-4ANM; advisory only, it never replaces flow_phase_complete).
|
|
223
|
+
3. If the verdict is oneshot:
|
|
224
|
+
- set the type label "oneshot" on the ticket (no epic),
|
|
225
|
+
- enrich the description with any useful aven-note context,
|
|
226
|
+
- the plan for this ticket IS its description; skip writing a plan file,
|
|
227
|
+
- set the ticket status to "todo",
|
|
228
|
+
- skip spec approval ENTIRELY. Call the flow_phase_complete tool with
|
|
229
|
+
ref=${ref} and phase="plan" right away — its result confirms the
|
|
230
|
+
"planned" label landed. Skip the rest.
|
|
231
|
+
4. If the verdict is plan:
|
|
232
|
+
- invoke the user's existing feature-plan-aven skill
|
|
233
|
+
(engineering:feature-plan-aven) for ${ref} and follow its workflow
|
|
234
|
+
(pickup, interview, scout, planner, plan.md, aven phase/subtask
|
|
235
|
+
hierarchy). Where the skill would pause for human plan review, DO NOT
|
|
236
|
+
wait: this is a yolo run — spec approval is self-serve.
|
|
237
|
+
- write the plan, then call the spec_approve tool YOURSELF — in a yolo
|
|
238
|
+
run it is receipt-exempt and succeeds without a human
|
|
239
|
+
"/flow answer" receipt. Do NOT wait for the human to approve.
|
|
240
|
+
- then, in the SAME turn, set the ticket status to "todo" and call the
|
|
241
|
+
flow_phase_complete tool with ref=${ref} and phase="plan" — its
|
|
242
|
+
result confirms the "planned" label landed. Completing all of this in
|
|
243
|
+
one turn means the flow never pauses at plan-state "review".
|
|
244
|
+
When the label lands: the /flow loop advances ${ref} into the implement
|
|
245
|
+
phase automatically (advancement is code, not model) — it injects the
|
|
246
|
+
implement prompt into this session, and your closing message must say the
|
|
247
|
+
implement phase starts automatically and that no action is needed. If this
|
|
248
|
+
phase was started by the standalone /plan command, no loop is armed — tell
|
|
249
|
+
the human to run /flow ${ref} to start the implement phase.
|
|
250
|
+
Direct aven label edits on lifecycle labels are blocked.`
|
|
251
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// AIDEV-NOTE: Size-check heuristic for the personal /plan flow. PURE so it is
|
|
2
|
+
// unit-testable; the agent asks the human to confirm the split before acting
|
|
3
|
+
// on the verdict (never auto-decompose). Heuristic: keyword signals for
|
|
4
|
+
// data-model, cross-package, and multi-step test implications → 'plan';
|
|
5
|
+
// no signals → 'oneshot' (single-file / one-module change assumption).
|
|
6
|
+
|
|
7
|
+
export interface TicketInfo {
|
|
8
|
+
title: string
|
|
9
|
+
description: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SizeVerdict {
|
|
13
|
+
size: 'oneshot' | 'plan'
|
|
14
|
+
reasons: readonly string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const SIGNALS: readonly { pattern: RegExp; reason: string }[] = [
|
|
18
|
+
{
|
|
19
|
+
pattern: /\bmigration|schema|data[ -]?model|database|table\b/i,
|
|
20
|
+
reason: 'touches the data model (migration/schema implications)',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pattern:
|
|
24
|
+
/\bcross[ -]?package|across packages|multiple packages|several packages\b/i,
|
|
25
|
+
reason: 'cross-package change (more than one package affected)',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pattern:
|
|
29
|
+
/\bintegration tests?|e2e tests?|several suites|multiple suites\b/i,
|
|
30
|
+
reason: 'multi-step test implications (integration/E2E or several suites)',
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
export function classifySize(info: TicketInfo): SizeVerdict {
|
|
35
|
+
const text = `${info.title}\n${info.description}`
|
|
36
|
+
const reasons: string[] = []
|
|
37
|
+
for (const signal of SIGNALS) {
|
|
38
|
+
if (signal.pattern.test(text)) {
|
|
39
|
+
reasons.push(signal.reason)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (reasons.length > 0) {
|
|
43
|
+
return { size: 'plan', reasons }
|
|
44
|
+
}
|
|
45
|
+
return { size: 'oneshot', reasons: [] }
|
|
46
|
+
}
|