pi-usereq 0.10.0 → 0.12.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/CHANGELOG.md +66 -0
- package/README.md +6 -6
- package/package.json +1 -1
- package/pi-usereq/docs/REFERENCES.md +861 -704
- package/pi-usereq/docs/REQUIREMENTS.md +152 -95
- package/pi-usereq/docs/WORKFLOW.md +228 -65
- package/scripts/lib/extension-debug-harness.ts +2 -2
- package/scripts/tool-args-to-params.ts +2 -2
- package/src/cli.ts +12 -12
- package/src/core/debug-runtime.ts +2 -2
- package/src/core/extension-status.ts +98 -36
- package/src/core/pi-notify.ts +5 -5
- package/src/core/pi-usereq-tools.ts +4 -2
- package/src/core/prompt-command-catalog.ts +4 -5
- package/src/core/prompt-command-runtime.ts +347 -42
- package/src/core/prompts.ts +0 -2
- package/src/core/req-references-command.ts +175 -0
- package/src/core/req-reset-command.ts +323 -0
- package/src/core/resources.ts +6 -23
- package/src/core/runtime-project-paths.ts +21 -1
- package/src/core/settings-menu.ts +85 -28
- package/src/core/tool-runner.ts +26 -6
- package/src/index.ts +530 -104
- package/tests/attended-results-scenarios.ts +5 -5
- package/tests/cli-command-option-parity.test.ts +25 -25
- package/tests/debug-extension-harness.test.ts +8 -2
- package/tests/extension-registration.test.ts +1109 -76
- package/tests/oracle-project.test.ts +4 -4
- package/tests/oracle-standalone.test.ts +5 -5
- package/src/core/reference-payload.ts +0 -752
- package/src/resources/prompts/references.md +0 -64
- /package/tests/fixtures_attended_results/project/{references.json → summarize.json} +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_c.c.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_cpp.cpp.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_csharp.cs.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_elixir.ex.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_go.go.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_haskell.hs.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_java.java.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_javascript.js.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_kotlin.kt.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_lua.lua.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_perl.pl.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_php.php.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_python.py.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_ruby.rb.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_rust.rs.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_scala.scala.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_shell.sh.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_swift.swift.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_typescript.ts.json +0 -0
- /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_zig.zig.json +0 -0
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
│ ├── prompt-command-runtime.ts
|
|
24
24
|
│ ├── prompt-command-state.ts
|
|
25
25
|
│ ├── prompts.ts
|
|
26
|
-
│ ├──
|
|
26
|
+
│ ├── req-references-command.ts
|
|
27
|
+
│ ├── req-reset-command.ts
|
|
27
28
|
│ ├── resources.ts
|
|
28
29
|
│ ├── runtime-project-paths.ts
|
|
29
30
|
│ ├── settings-menu.ts
|
|
@@ -1127,140 +1128,140 @@ import {
|
|
|
1127
1128
|
|
|
1128
1129
|
---
|
|
1129
1130
|
|
|
1130
|
-
# extension-status.ts | TypeScript |
|
|
1131
|
+
# extension-status.ts | TypeScript | 880L | 46 symbols | 6 imports | 48 comments
|
|
1131
1132
|
> Path: `src/core/extension-status.ts`
|
|
1132
1133
|
- @brief Tracks pi-usereq extension status state and renders status-bar telemetry.
|
|
1133
|
-
- @details Centralizes hook interception, context-usage snapshots, run timing,
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
rendering. Side effects are limited to in-memory state mutation and interval
|
|
1134
|
+
- @details Centralizes hook interception, context-usage snapshots, active-branch lookup, run timing, and deterministic status-bar formatting for the pi-usereq extension. Runtime
|
|
1135
|
+
is O(1) per event plus interval-driven re-renders while a prompt remains
|
|
1136
|
+
active. Side effects are limited to in-memory state mutation and interval
|
|
1137
1137
|
scheduling through exported controller helpers.
|
|
1138
1138
|
|
|
1139
1139
|
## Imports
|
|
1140
1140
|
```
|
|
1141
1141
|
import type {
|
|
1142
1142
|
import type { UseReqConfig } from "./config.js";
|
|
1143
|
+
import type { PiNotifySoundLevel } from "./pi-notify.js";
|
|
1143
1144
|
import type { PromptCommandExecutionPlan } from "./prompt-command-runtime.js";
|
|
1144
1145
|
import {
|
|
1145
|
-
import {
|
|
1146
|
+
import { resolveRuntimeGitBranchName } from "./runtime-project-paths.js";
|
|
1146
1147
|
```
|
|
1147
1148
|
|
|
1148
1149
|
## Definitions
|
|
1149
1150
|
|
|
1150
|
-
- type `type StatusForegroundColor = Extract<` (
|
|
1151
|
+
- type `type StatusForegroundColor = Extract<` (L31)
|
|
1151
1152
|
- @brief Enumerates the CLI-supported theme tokens consumed by status rendering.
|
|
1152
1153
|
- @details Restricts the status formatter to documented pi theme tokens so the
|
|
1153
1154
|
status bar remains compatible with the active CLI theme schema. Compile-time
|
|
1154
1155
|
only and introduces no runtime cost.
|
|
1155
|
-
### iface `interface RawStatusTheme` (
|
|
1156
|
+
### iface `interface RawStatusTheme` (L41-43)
|
|
1156
1157
|
- @brief Describes the raw theme capabilities required for status rendering.
|
|
1157
1158
|
- @details Accepts the `ctx.ui.theme` foreground renderer used by the
|
|
1158
1159
|
single-line footer. Compile-time only and introduces no runtime cost.
|
|
1159
1160
|
|
|
1160
|
-
### iface `interface StatusThemeAdapter` (
|
|
1161
|
+
### iface `interface StatusThemeAdapter` (L51-56)
|
|
1161
1162
|
- @brief Describes the normalized theme adapter used by status formatters.
|
|
1162
1163
|
- @details Exposes deterministic label, value, foreground, and separator
|
|
1163
1164
|
renderers so status text generation stays independent from the raw theme API.
|
|
1164
1165
|
Compile-time only and introduces no runtime cost.
|
|
1165
1166
|
|
|
1166
|
-
- type `export type PiUsereqStatusHookName = (typeof PI_USEREQ_STATUS_HOOK_NAMES)[number];` (
|
|
1167
|
+
- type `export type PiUsereqStatusHookName = (typeof PI_USEREQ_STATUS_HOOK_NAMES)[number];` (L99)
|
|
1167
1168
|
- @brief Represents one hook name handled by the pi-usereq status controller.
|
|
1168
1169
|
- @details Narrows hook registration and event-update calls to the canonical
|
|
1169
1170
|
intercepted-hook set. Compile-time only and introduces no runtime cost.
|
|
1170
|
-
- type `export type PiUsereqPromptRequest = PromptCommandExecutionPlan;` (
|
|
1171
|
+
- type `export type PiUsereqPromptRequest = PromptCommandExecutionPlan;` (L105)
|
|
1171
1172
|
- @brief Describes one prompt request tracked across extension command delivery and runtime execution.
|
|
1172
1173
|
- @details Reuses the prepared prompt-command execution plan so status rendering and prompt-end side effects can recover the original project base, active execution base, and optional worktree metadata for the current prompt run. The alias is compile-time only and introduces no runtime cost.
|
|
1173
|
-
- type `export type PiUsereqWorkflowState = "idle" | "checking" | "running" | "merging" | "error";` (
|
|
1174
|
+
- type `export type PiUsereqWorkflowState = "idle" | "checking" | "running" | "merging" | "error";` (L111)
|
|
1174
1175
|
- @brief Represents one prompt-orchestration workflow state displayed in the status bar.
|
|
1175
1176
|
- @details Narrows workflow tracking to the documented `idle`, `checking`, `running`, `merging`, and `error` states reused by prompt-command gating, prompt-end orchestration, and status rendering. Compile-time only and introduces no runtime cost.
|
|
1176
|
-
### iface `export interface PiUsereqStatusState` (
|
|
1177
|
+
### iface `export interface PiUsereqStatusState` (L117-126)
|
|
1177
1178
|
- @brief Stores the mutable runtime facts displayed by the status bar.
|
|
1178
|
-
- @details Persists the prompt-orchestration workflow state, the latest context-usage snapshot, the active run start timestamp, the most recent normally completed run duration, the accumulated duration of all normally completed runs, and prompt-request metadata carried from command dispatch into the next runtime execution. Runtime state is mutated in-place by controller helpers. Compile-time only and introduces no runtime cost.
|
|
1179
|
+
- @details Persists the prompt-orchestration workflow state, the latest context-usage snapshot, the active run start timestamp, the most recent normally completed run duration, the accumulated duration of all normally completed runs, the in-memory runtime sound level, and prompt-request metadata carried from command dispatch into the next runtime execution. Runtime state is mutated in-place by controller helpers. Compile-time only and introduces no runtime cost.
|
|
1179
1180
|
|
|
1180
|
-
### iface `export interface PiUsereqStatusController` (
|
|
1181
|
+
### iface `export interface PiUsereqStatusController` (L135-140)
|
|
1181
1182
|
- @brief Stores the controller state required for event-driven status updates.
|
|
1182
1183
|
- @details Keeps the mutable status snapshot, the current configuration, the
|
|
1183
1184
|
latest extension context used for rendering, and the interval handle used
|
|
1184
1185
|
for live elapsed-time refreshes. Compile-time only and introduces no runtime
|
|
1185
1186
|
cost.
|
|
1186
1187
|
|
|
1187
|
-
### iface `interface PiUsereqStatusPersistenceStore` (
|
|
1188
|
+
### iface `interface PiUsereqStatusPersistenceStore` (L146-149)
|
|
1188
1189
|
- @brief Stores the process-scoped elapsed-timer snapshot reused across session replacement.
|
|
1189
1190
|
- @details Preserves only the latest completed duration and accumulated completed runtime so `/new`, `/resume`, and `/fork` can restore elapsed counters after the extension runtime is rebound. Compile-time only and introduces no runtime cost.
|
|
1190
1191
|
|
|
1191
|
-
### fn `function getPiUsereqStatusPersistenceStore(): PiUsereqStatusPersistenceStore` (
|
|
1192
|
+
### fn `function getPiUsereqStatusPersistenceStore(): PiUsereqStatusPersistenceStore` (L163-172)
|
|
1192
1193
|
- @brief Returns the process-scoped elapsed-timer persistence store.
|
|
1193
1194
|
- @details Lazily initializes one internal `globalThis` record because pi rebinds extension modules for `/new`, `/resume`, `/fork`, and `/reload`, but the hosting process persists across those operations. Runtime is O(1). Side effect: initializes internal process-scoped state on first access.
|
|
1194
1195
|
- @return {PiUsereqStatusPersistenceStore} Mutable persistence record.
|
|
1195
1196
|
- @note Design rationale: required to preserve elapsed counters across session replacement without writing session-global menu state into project configuration.
|
|
1196
1197
|
|
|
1197
|
-
### fn `function restorePersistedElapsedState(state: PiUsereqStatusState): void` (
|
|
1198
|
+
### fn `function restorePersistedElapsedState(state: PiUsereqStatusState): void` (L180-184)
|
|
1198
1199
|
- @brief Restores persisted elapsed counters into one mutable status snapshot.
|
|
1199
1200
|
- @details Copies the process-scoped last-run and accumulated completed durations into the supplied controller state so rebinding events can continue showing prior counters. Runtime is O(1). Side effect: mutates `state`.
|
|
1200
1201
|
- @param[in,out] state {PiUsereqStatusState} Mutable status state.
|
|
1201
1202
|
- @return {void} No return value.
|
|
1202
1203
|
|
|
1203
|
-
### fn `function persistElapsedState(state: PiUsereqStatusState): void` (
|
|
1204
|
+
### fn `function persistElapsedState(state: PiUsereqStatusState): void` (L192-196)
|
|
1204
1205
|
- @brief Persists elapsed counters from one mutable status snapshot.
|
|
1205
1206
|
- @details Copies the current last-run and accumulated completed durations into the process-scoped store so later extension instances can restore them after session replacement. Runtime is O(1). Side effect: mutates internal process-scoped state.
|
|
1206
1207
|
- @param[in] state {PiUsereqStatusState} Mutable status state snapshot.
|
|
1207
1208
|
- @return {void} No return value.
|
|
1208
1209
|
|
|
1209
|
-
### fn `function persistPromptCommandState(state: PiUsereqStatusState): void` (
|
|
1210
|
+
### fn `function persistPromptCommandState(state: PiUsereqStatusState): void` (L204-210)
|
|
1210
1211
|
- @brief Mirrors one controller prompt state into the process-scoped persistence store.
|
|
1211
1212
|
- @details Persists the current workflow state plus the pending and active prompt execution plans so prompt orchestration can survive session replacement. Runtime is O(1). Side effect: mutates process-scoped prompt-command persistence state.
|
|
1212
1213
|
- @param[in] state {PiUsereqStatusState} Current controller state snapshot.
|
|
1213
1214
|
- @return {void} No return value.
|
|
1214
1215
|
|
|
1215
|
-
### fn `export function shouldPreservePromptCommandStateOnShutdown(state: PiUsereqStatusState): boolean` (
|
|
1216
|
+
### fn `export function shouldPreservePromptCommandStateOnShutdown(state: PiUsereqStatusState): boolean` (L219-222)
|
|
1216
1217
|
- @brief Detects whether `session_shutdown` must preserve prompt-command state.
|
|
1217
1218
|
- @details Keeps both the in-memory controller prompt state and the process-scoped prompt execution plan intact while pi switches from the original session into the forked execution session, because the old extension instance can keep running the initiating command handler after `session_shutdown` fires and before the replacement session fully takes over. Runtime is O(1). No external state is mutated.
|
|
1218
1219
|
- @param[in] state {PiUsereqStatusState} Controller state before shutdown mutation.
|
|
1219
1220
|
- @return {boolean} `true` when prompt-command state must survive the shutdown event.
|
|
1220
1221
|
- @satisfies REQ-278
|
|
1221
1222
|
|
|
1222
|
-
### fn `function restorePersistedPromptCommandState(` (
|
|
1223
|
+
### fn `function restorePersistedPromptCommandState(` (L231-242)
|
|
1223
1224
|
- @brief Restores prompt-command persistence into one fresh controller when the active session matches.
|
|
1224
1225
|
- @details Rehydrates workflow state plus pending or active prompt execution plans only when the current session file targets the persisted execution session created for prompt orchestration. Runtime is O(1). Side effect: mutates `state` when persisted prompt state is available.
|
|
1225
1226
|
- @param[in] sessionFile {string | undefined} Current active session file.
|
|
1226
1227
|
- @param[in,out] state {PiUsereqStatusState} Mutable controller state.
|
|
1227
1228
|
- @return {void} No return value.
|
|
1228
1229
|
|
|
1229
|
-
### fn `function getContextSessionFile(ctx: ExtensionContext): string | undefined` (
|
|
1230
|
+
### fn `function getContextSessionFile(ctx: ExtensionContext): string | undefined` (L250-254)
|
|
1230
1231
|
- @brief Resolves the active session file exposed by one extension context.
|
|
1231
1232
|
- @details Reads the session-manager session-file getter when available so prompt-command persistence can be resynchronized on every lifecycle hook after session replacement. Runtime is O(1). No external state is mutated.
|
|
1232
1233
|
- @param[in] ctx {ExtensionContext} Active extension context.
|
|
1233
1234
|
- @return {string | undefined} Current session file when available.
|
|
1234
1235
|
|
|
1235
|
-
### fn `export function isStaleExtensionContextError(error: unknown): boolean` (
|
|
1236
|
+
### fn `export function isStaleExtensionContextError(error: unknown): boolean` (L263-266)
|
|
1236
1237
|
- @brief Detects stale extension-context access after session replacement.
|
|
1237
1238
|
- @details Matches the guarded pi runtime error emitted when one invalidated extension context, command context, or replacement-session context is accessed after session replacement or reload. Runtime is O(n) in message length only when an error is supplied. No external state is mutated.
|
|
1238
1239
|
- @param[in] error {unknown} Candidate thrown value.
|
|
1239
1240
|
- @return {boolean} `true` when the value matches the stale-extension-context runtime error.
|
|
1240
1241
|
- @satisfies REQ-280
|
|
1241
1242
|
|
|
1242
|
-
### fn `function resetElapsedState(state: PiUsereqStatusState): void` (
|
|
1243
|
+
### fn `function resetElapsedState(state: PiUsereqStatusState): void` (L275-279)
|
|
1243
1244
|
- @brief Resets the in-memory and persisted elapsed counters.
|
|
1244
1245
|
- @details Clears both completed-duration fields in the supplied state and mirrors that cleared snapshot into the process-scoped store. Runtime is O(1). Side effects include mutable state reset and process-scoped persistence update.
|
|
1245
1246
|
- @param[in,out] state {PiUsereqStatusState} Mutable status state.
|
|
1246
1247
|
- @return {void} No return value.
|
|
1247
1248
|
- @satisfies REQ-217
|
|
1248
1249
|
|
|
1249
|
-
### fn `function shouldResetElapsedStateOnSessionStart(event: unknown): boolean` (
|
|
1250
|
+
### fn `function shouldResetElapsedStateOnSessionStart(event: unknown): boolean` (L288-291)
|
|
1250
1251
|
- @brief Detects whether a `session_start` event must reset elapsed counters.
|
|
1251
1252
|
- @details Treats `startup` and `reload` as hard-reset boundaries while preserving counters for `new`, `resume`, and `fork`. Runtime is O(1). No external state is mutated.
|
|
1252
1253
|
- @param[in] event {unknown} Session-start payload.
|
|
1253
1254
|
- @return {boolean} `true` when elapsed counters must reset.
|
|
1254
1255
|
- @satisfies REQ-217
|
|
1255
1256
|
|
|
1256
|
-
### fn `function shouldResetWorkflowStateOnSessionStart(event: unknown): boolean` (
|
|
1257
|
+
### fn `function shouldResetWorkflowStateOnSessionStart(event: unknown): boolean` (L300-303)
|
|
1257
1258
|
- @brief Detects whether a `session_start` event must reset the workflow state to `idle`.
|
|
1258
1259
|
- @details Treats `startup`, `new`, and `reload` as workflow-reset boundaries so prompt-orchestration state never leaks across boot, explicit session replacement, or extension reload. Runtime is O(1). No external state is mutated.
|
|
1259
1260
|
- @param[in] event {unknown} Session-start payload.
|
|
1260
1261
|
- @return {boolean} `true` when workflow state must reset to `idle`.
|
|
1261
1262
|
- @satisfies REQ-009, REQ-221
|
|
1262
1263
|
|
|
1263
|
-
### fn `function createStatusThemeAdapter(theme: RawStatusTheme): StatusThemeAdapter` (
|
|
1264
|
+
### fn `function createStatusThemeAdapter(theme: RawStatusTheme): StatusThemeAdapter` (L313-322)
|
|
1264
1265
|
- @brief Builds the normalized theme adapter used by pi-usereq status formatters.
|
|
1265
1266
|
- @details Precomputes label, value, foreground, and separator renderers so
|
|
1266
1267
|
status formatting remains stable across real TUI themes and deterministic
|
|
@@ -1268,9 +1269,16 @@ test doubles. Runtime is O(1). No external state is mutated.
|
|
|
1268
1269
|
- @param[in] theme {RawStatusTheme} Raw theme implementation from `ctx.ui.theme`.
|
|
1269
1270
|
- @return {StatusThemeAdapter} Normalized status-theme adapter.
|
|
1270
1271
|
|
|
1271
|
-
### fn `const colorize = (color: StatusForegroundColor, text: string): string =>` (
|
|
1272
|
+
### fn `const colorize = (color: StatusForegroundColor, text: string): string =>` (L314-321)
|
|
1273
|
+
|
|
1274
|
+
### fn `function resolveStatusBranchValue(ctx: ExtensionContext): string` (L331-333)
|
|
1275
|
+
- @brief Resolves the active git branch value rendered in the status bar.
|
|
1276
|
+
- @details Reads the current branch from the active context working directory on every status render so worktree switches and restored base-session renders expose the latest branch immediately. Runtime is dominated by git execution when the working directory belongs to a repository. Side effects include subprocess creation.
|
|
1277
|
+
- @param[in] ctx {ExtensionContext} Active extension context.
|
|
1278
|
+
- @return {string} Active branch name or `unknown` when unavailable.
|
|
1279
|
+
- @satisfies REQ-121, REQ-283
|
|
1272
1280
|
|
|
1273
|
-
### fn `function normalizeContextUsage(` (
|
|
1281
|
+
### fn `function normalizeContextUsage(` (L344-361)
|
|
1274
1282
|
- @brief Normalizes one raw context-usage snapshot.
|
|
1275
1283
|
- @details Preserves the runtime token and context-window counts, derives a
|
|
1276
1284
|
percentage when the runtime omits it, clamps negative percentages to `0`,
|
|
@@ -1279,7 +1287,7 @@ external state is mutated.
|
|
|
1279
1287
|
- @param[in] contextUsage {ContextUsage | undefined} Raw runtime snapshot.
|
|
1280
1288
|
- @return {ContextUsage | undefined} Normalized snapshot.
|
|
1281
1289
|
|
|
1282
|
-
### fn `function refreshContextUsage(` (
|
|
1290
|
+
### fn `function refreshContextUsage(` (L373-378)
|
|
1283
1291
|
- @brief Refreshes the stored context-usage snapshot from the active extension context.
|
|
1284
1292
|
- @details Calls `ctx.getContextUsage()` on every intercepted event so the
|
|
1285
1293
|
controller retains the newest context-usage facts available from the pi
|
|
@@ -1289,24 +1297,22 @@ runtime. Runtime is O(1). Side effect: mutates `state.contextUsage`.
|
|
|
1289
1297
|
- @return {void} No return value.
|
|
1290
1298
|
- @satisfies REQ-118, REQ-119
|
|
1291
1299
|
|
|
1292
|
-
### fn `function resolveContextUsageIconText(` (
|
|
1300
|
+
### fn `function resolveContextUsageIconText(` (L387-404)
|
|
1293
1301
|
- @brief Resolves the icon text for one normalized context-usage snapshot.
|
|
1294
|
-
- @details Maps context usage to one fixed-width icon band so footer rendering
|
|
1295
|
-
remains compact and deterministic. Unavailable usage degrades to the `0%`
|
|
1296
|
-
icon. Runtime is O(1). No external state is mutated.
|
|
1302
|
+
- @details Maps context usage to one fixed-width icon band so footer rendering remains compact and deterministic across the documented `0`, `>0-<25`, `>=25-<50`, `>=50-<75`, and `>=75` percent bands. Unavailable usage degrades to the `0%` icon. Runtime is O(1). No external state is mutated.
|
|
1297
1303
|
- @param[in] contextUsage {ContextUsage | undefined} Normalized context snapshot.
|
|
1298
1304
|
- @return {string} Fixed-width gauge icon text.
|
|
1299
|
-
- @satisfies REQ-
|
|
1305
|
+
- @satisfies REQ-122, REQ-284
|
|
1300
1306
|
|
|
1301
|
-
### fn `function formatContextUsageBar(` (
|
|
1307
|
+
### fn `function formatContextUsageBar(` (L414-426)
|
|
1302
1308
|
- @brief Formats one icon-based context-usage gauge.
|
|
1303
|
-
- @details Renders the documented
|
|
1309
|
+
- @details Renders the documented gauge icon with the same non-error status-value theme token used by `status` below `90%`, switches to theme `error` for `>=90%`, and enables terminal blink only for `>=100%`. Runtime is O(1). No external state is mutated.
|
|
1304
1310
|
- @param[in] theme {StatusThemeAdapter} Normalized status theme.
|
|
1305
1311
|
- @param[in] contextUsage {ContextUsage | undefined} Normalized context snapshot.
|
|
1306
1312
|
- @return {string} Rendered fixed-width gauge icon.
|
|
1307
|
-
- @satisfies REQ-
|
|
1313
|
+
- @satisfies REQ-122, REQ-126, REQ-127, REQ-128, REQ-233, REQ-284
|
|
1308
1314
|
|
|
1309
|
-
### fn `function formatStatusDuration(durationMs: number): string` (
|
|
1315
|
+
### fn `function formatStatusDuration(durationMs: number): string` (L437-442)
|
|
1310
1316
|
- @brief Formats one elapsed-duration value as `M:SS`.
|
|
1311
1317
|
- @details Floors the input to whole seconds, keeps minutes unbounded above 59,
|
|
1312
1318
|
and zero-pads seconds to two digits. Runtime is O(1). No external state is
|
|
@@ -1315,7 +1321,7 @@ mutated.
|
|
|
1315
1321
|
- @return {string} Duration rendered as `M:SS`.
|
|
1316
1322
|
- @satisfies REQ-125
|
|
1317
1323
|
|
|
1318
|
-
### fn `function formatCompletedStatusDuration(` (
|
|
1324
|
+
### fn `function formatCompletedStatusDuration(` (L453-457)
|
|
1319
1325
|
- @brief Formats one optional completed-duration value.
|
|
1320
1326
|
- @details Returns the canonical unset placeholder `--:--` until the supplied
|
|
1321
1327
|
timer receives a normally completed prompt duration, then delegates to
|
|
@@ -1324,7 +1330,7 @@ timer receives a normally completed prompt duration, then delegates to
|
|
|
1324
1330
|
- @return {string} Rendered duration or unset placeholder.
|
|
1325
1331
|
- @satisfies REQ-124
|
|
1326
1332
|
|
|
1327
|
-
### fn `function formatElapsedStatusValue(` (
|
|
1333
|
+
### fn `function formatElapsedStatusValue(` (L470-480)
|
|
1328
1334
|
- @brief Formats the consolidated `elapsed` status-bar value.
|
|
1329
1335
|
- @details Emits the active prompt segment `⏱︎ <active>`, the latest normally
|
|
1330
1336
|
completed segment `⚑ <last>`, and the accumulated successful-runtime segment
|
|
@@ -1335,7 +1341,7 @@ mutated.
|
|
|
1335
1341
|
- @return {string} Consolidated `elapsed` field value.
|
|
1336
1342
|
- @satisfies REQ-123, REQ-124, REQ-125, REQ-159
|
|
1337
1343
|
|
|
1338
|
-
### fn `function formatStatusField(` (
|
|
1344
|
+
### fn `function formatStatusField(` (L491-497)
|
|
1339
1345
|
- @brief Formats one standard status-bar field.
|
|
1340
1346
|
- @details Renders the field label in accent color and the value in warning
|
|
1341
1347
|
color. Runtime is O(n) in combined text length. No external state is mutated.
|
|
@@ -1344,7 +1350,7 @@ color. Runtime is O(n) in combined text length. No external state is mutated.
|
|
|
1344
1350
|
- @param[in] value {string} Unstyled field value.
|
|
1345
1351
|
- @return {string} Rendered status-field fragment.
|
|
1346
1352
|
|
|
1347
|
-
### fn `function formatRenderedStatusField(` (
|
|
1353
|
+
### fn `function formatRenderedStatusField(` (L509-515)
|
|
1348
1354
|
- @brief Formats one pre-rendered status-bar field value.
|
|
1349
1355
|
- @details Preserves the accent-colored field label while allowing callers to
|
|
1350
1356
|
provide a custom styled value such as the context-usage bar. Runtime is O(n)
|
|
@@ -1354,7 +1360,7 @@ in combined text length. No external state is mutated.
|
|
|
1354
1360
|
- @param[in] renderedValue {string} Pre-rendered field value.
|
|
1355
1361
|
- @return {string} Rendered status-field fragment.
|
|
1356
1362
|
|
|
1357
|
-
### fn `function formatWorkflowStateValue(` (
|
|
1363
|
+
### fn `function formatWorkflowStateValue(` (L525-533)
|
|
1358
1364
|
- @brief Formats the rendered workflow-state value for the `status` field.
|
|
1359
1365
|
- @details Uses the standard warning-colored value renderer for non-error states and emits a blinking `error`-colored value for `status:error` so the footer highlights orchestration failures immediately. Runtime is O(n) in text length. No external state is mutated.
|
|
1360
1366
|
- @param[in] theme {StatusThemeAdapter} Normalized status theme.
|
|
@@ -1362,7 +1368,7 @@ in combined text length. No external state is mutated.
|
|
|
1362
1368
|
- @return {string} Rendered workflow-state value.
|
|
1363
1369
|
- @satisfies REQ-112, REQ-223
|
|
1364
1370
|
|
|
1365
|
-
### fn `function didAgentEndAbort(messages: AgentEndEvent["messages"]): boolean` (
|
|
1371
|
+
### fn `function didAgentEndAbort(messages: AgentEndEvent["messages"]): boolean` (L544-551)
|
|
1366
1372
|
- @brief Detects whether an agent run ended through abort semantics.
|
|
1367
1373
|
- @details Treats any assistant message whose `stopReason` equals `aborted` as
|
|
1368
1374
|
an escape-triggered termination that must not overwrite the `last` timer.
|
|
@@ -1371,18 +1377,26 @@ Runtime is O(n) in message count. No external state is mutated.
|
|
|
1371
1377
|
- @return {boolean} `true` when the run ended in aborted state.
|
|
1372
1378
|
- @satisfies REQ-125
|
|
1373
1379
|
|
|
1374
|
-
### fn `function
|
|
1380
|
+
### fn `function resolvePiUsereqRuntimeSoundLevel(` (L561-566)
|
|
1381
|
+
- @brief Resolves the active runtime sound level used by status and notify flows.
|
|
1382
|
+
- @details Prefers the mutable runtime sound state, then falls back to the cached persisted boot value, and finally defaults to `none` before `session_start` loads configuration. Runtime is O(1). No external state is mutated.
|
|
1383
|
+
- @param[in] state {PiUsereqStatusState} Mutable status state snapshot.
|
|
1384
|
+
- @param[in] config {UseReqConfig | undefined} Cached project configuration.
|
|
1385
|
+
- @return {PiNotifySoundLevel} Active runtime sound level.
|
|
1386
|
+
- @satisfies REQ-180, REQ-285
|
|
1387
|
+
|
|
1388
|
+
### fn `function buildPiUsereqStatusText(` (L579-603)
|
|
1375
1389
|
- @brief Builds the full single-line pi-usereq status-bar payload.
|
|
1376
|
-
- @details Renders status,
|
|
1377
|
-
- @param[in] cwd {string} Runtime working directory used for context-path derivation.
|
|
1390
|
+
- @details Renders status, branch, context, elapsed, and sound fields in the canonical order with dim bullet separators, workflow-state highlighting, the documented icon-based context gauge, and the active runtime sound level instead of the persisted boot value. Runtime is O(1). No external state is mutated.
|
|
1378
1391
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
1379
1392
|
- @param[in] theme {StatusThemeAdapter} Normalized status theme.
|
|
1380
1393
|
- @param[in] state {PiUsereqStatusState} Mutable status state snapshot.
|
|
1394
|
+
- @param[in] branchName {string} Active git branch name shown in the footer.
|
|
1381
1395
|
- @param[in] nowMs {number} Current wall-clock time in milliseconds.
|
|
1382
1396
|
- @return {string} Single-line status-bar text.
|
|
1383
|
-
- @satisfies REQ-109, REQ-112, REQ-120, REQ-121, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-
|
|
1397
|
+
- @satisfies REQ-109, REQ-112, REQ-120, REQ-121, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-156, REQ-159, REQ-180, REQ-222, REQ-223, REQ-233, REQ-283, REQ-284
|
|
1384
1398
|
|
|
1385
|
-
### fn `function stopStatusTicker(controller: PiUsereqStatusController): void` (
|
|
1399
|
+
### fn `function stopStatusTicker(controller: PiUsereqStatusController): void` (L613-618)
|
|
1386
1400
|
- @brief Stops the live elapsed-time ticker when it is active.
|
|
1387
1401
|
- @details Clears the interval handle and resets the stored timer reference so
|
|
1388
1402
|
subsequent runs can reinitialize live status refreshes deterministically.
|
|
@@ -1390,7 +1404,7 @@ Runtime is O(1). Side effect: mutates `controller.tickHandle`.
|
|
|
1390
1404
|
- @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
1391
1405
|
- @return {void} No return value.
|
|
1392
1406
|
|
|
1393
|
-
### fn `function syncPiUsereqStatusTicker(` (
|
|
1407
|
+
### fn `function syncPiUsereqStatusTicker(` (L630-646)
|
|
1394
1408
|
- @brief Synchronizes the live elapsed-time ticker with the current run state.
|
|
1395
1409
|
- @details Starts a 1-second render ticker while a run is active and stops the
|
|
1396
1410
|
ticker when the run returns to idle. Runtime is O(1). Side effects include
|
|
@@ -1400,31 +1414,48 @@ ticks.
|
|
|
1400
1414
|
- @return {void} No return value.
|
|
1401
1415
|
- @satisfies REQ-123
|
|
1402
1416
|
|
|
1403
|
-
### fn `export function createPiUsereqStatusController(): PiUsereqStatusController` (
|
|
1417
|
+
### fn `export function createPiUsereqStatusController(): PiUsereqStatusController` (L654-670)
|
|
1404
1418
|
- @brief Creates an empty pi-usereq status controller.
|
|
1405
|
-
- @details Initializes the mutable status snapshot, including empty prompt-request tracking
|
|
1419
|
+
- @details Initializes the mutable status snapshot, including empty prompt-request tracking and an unset runtime sound level that later loads from persisted config during `session_start`, and starts with no config, no context, and no live ticker. Runtime is O(1). No external state is mutated.
|
|
1406
1420
|
- @return {PiUsereqStatusController} New status controller.
|
|
1407
1421
|
- @satisfies DES-010
|
|
1408
1422
|
|
|
1409
|
-
### fn `export function setPiUsereqStatusConfig(` (
|
|
1423
|
+
### fn `export function setPiUsereqStatusConfig(` (L683-688)
|
|
1410
1424
|
- @brief Stores the effective project configuration used by status rendering.
|
|
1411
1425
|
- @details Replaces the controller's cached configuration so later status
|
|
1412
|
-
renders reuse the latest docs, tests, source-path, and pi-notify
|
|
1413
|
-
without reading from disk on every event
|
|
1426
|
+
renders reuse the latest docs, tests, source-path, and persisted pi-notify
|
|
1427
|
+
values without reading from disk on every event, while leaving the active
|
|
1428
|
+
runtime sound level in `controller.state`. Runtime is O(1). Side effect:
|
|
1414
1429
|
mutates `controller.config`.
|
|
1415
1430
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
1416
1431
|
- @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
1417
1432
|
- @return {void} No return value.
|
|
1418
1433
|
|
|
1419
|
-
### fn `export function
|
|
1434
|
+
### fn `export function getPiUsereqRuntimeSoundLevel(` (L697-701)
|
|
1435
|
+
- @brief Returns the active runtime sound level tracked by the status controller.
|
|
1436
|
+
- @details Exposes the in-memory runtime sound state so shortcut handlers and prompt-end notification dispatch can stay decoupled from the persisted boot value stored in `.pi-usereq.json`. Runtime is O(1). No external state is mutated.
|
|
1437
|
+
- @param[in] controller {PiUsereqStatusController} Mutable status controller.
|
|
1438
|
+
- @return {PiNotifySoundLevel} Active runtime sound level.
|
|
1439
|
+
- @satisfies REQ-180, REQ-285
|
|
1440
|
+
|
|
1441
|
+
### fn `export function setPiUsereqRuntimeSoundLevel(` (L712-722)
|
|
1442
|
+
- @brief Stores one new runtime sound level and refreshes the status bar.
|
|
1443
|
+
- @details Mutates only the in-memory runtime sound state so shortcut-driven sound changes do not update `.pi-usereq.json`, then re-renders the footer when an active extension context is available. Runtime is O(1). Side effect: mutates `controller.state.runtimeSoundLevel` and may update `ctx.ui` status.
|
|
1444
|
+
- @param[in] runtimeSoundLevel {PiNotifySoundLevel} Next active runtime sound level.
|
|
1445
|
+
- @param[in] ctx {ExtensionContext | undefined} Optional active extension context.
|
|
1446
|
+
- @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
1447
|
+
- @return {void} No return value.
|
|
1448
|
+
- @satisfies REQ-180, REQ-286, REQ-287
|
|
1449
|
+
|
|
1450
|
+
### fn `export function renderPiUsereqStatus(` (L732-763)
|
|
1420
1451
|
- @brief Renders the current pi-usereq status bar into the active UI context.
|
|
1421
|
-
- @details Updates the controller's latest context pointer and writes the single-line status text only when configuration is available,
|
|
1452
|
+
- @details Updates the controller's latest context pointer, refreshes the live `getContextUsage()` snapshot for direct render call sites that do not pass through `updateExtensionStatus(...)`, and writes the single-line status text only when configuration is available, including the active branch field, documented icon-based context gauge, and active runtime sound level. When pi has already invalidated the supplied context after session replacement or reload, the helper clears the stale cached context and returns without surfacing the stale-instance exception. Runtime is O(1) plus git execution for branch refresh. Side effect: mutates `controller.state.contextUsage` and `ctx.ui` status when the context is still active.
|
|
1422
1453
|
- @param[in] ctx {ExtensionContext} Active extension context.
|
|
1423
1454
|
- @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
1424
1455
|
- @return {void} No return value.
|
|
1425
|
-
- @satisfies REQ-120, REQ-121, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-
|
|
1456
|
+
- @satisfies REQ-118, REQ-119, REQ-120, REQ-121, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-159, REQ-180, REQ-233, REQ-280, REQ-283, REQ-284
|
|
1426
1457
|
|
|
1427
|
-
### fn `export function setPiUsereqWorkflowState(` (
|
|
1458
|
+
### fn `export function setPiUsereqWorkflowState(` (L774-785)
|
|
1428
1459
|
- @brief Transitions the prompt-orchestration workflow state and refreshes the status bar.
|
|
1429
1460
|
- @details Mutates the tracked workflow state, preserves the latest extension context when available, and re-renders the single-line footer immediately so internal command transitions and pi lifecycle transitions stay visible to the user. Runtime is O(1). Side effect: mutates workflow state and may update `ctx.ui` status.
|
|
1430
1461
|
- @param[in] workflowState {PiUsereqWorkflowState} Next workflow state.
|
|
@@ -1433,17 +1464,17 @@ mutates `controller.config`.
|
|
|
1433
1464
|
- @return {void} No return value.
|
|
1434
1465
|
- @satisfies REQ-221, REQ-222, REQ-223
|
|
1435
1466
|
|
|
1436
|
-
### fn `export function updateExtensionStatus(` (
|
|
1467
|
+
### fn `export function updateExtensionStatus(` (L797-864)
|
|
1437
1468
|
- @brief Updates mutable status state for one intercepted lifecycle hook.
|
|
1438
|
-
- @details Refreshes stored context usage on every hook, resets or restores persisted elapsed counters during `session_start`, restores persisted prompt-command metadata when the active session matches a forked execution session, resynchronizes that metadata on later lifecycle hooks so post-switch workflow transitions performed by the initiating command handler become visible to the replacement-session runtime, resets workflow state to `idle` for documented session-start reasons, starts run timing on `agent_start`, promotes pending prompt-request metadata into the active run, captures non-aborted run duration on `agent_end`, accumulates successful runtime into `Σ`, preserves in-memory prompt-command state plus process-scoped persistence across switch-triggered `session_shutdown`, tolerates stale post-replacement render contexts, synchronizes the live ticker, and re-renders the status bar when configuration is available. Runtime is O(n) in `agent_end` message count and otherwise O(1). Side effects include in-memory state mutation, interval scheduling, process-scoped persistence mutation, and footer-status updates.
|
|
1469
|
+
- @details Refreshes stored context usage on every hook, resets or restores persisted elapsed counters during `session_start`, loads the active runtime sound level from persisted config during `session_start`, restores persisted prompt-command metadata when the active session matches a forked execution session, resynchronizes that metadata on later lifecycle hooks so post-switch workflow transitions performed by the initiating command handler become visible to the replacement-session runtime, resets workflow state to `idle` for documented session-start reasons, starts run timing on `agent_start`, promotes pending prompt-request metadata into the active run, captures non-aborted run duration on `agent_end`, accumulates successful runtime into `Σ`, preserves in-memory prompt-command state plus process-scoped persistence across switch-triggered `session_shutdown`, tolerates stale post-replacement render contexts, synchronizes the live ticker, and re-renders the status bar when configuration is available. Runtime is O(n) in `agent_end` message count and otherwise O(1). Side effects include in-memory state mutation, interval scheduling, process-scoped persistence mutation, and footer-status updates.
|
|
1439
1470
|
- @param[in] hookName {PiUsereqStatusHookName} Intercepted hook name.
|
|
1440
1471
|
- @param[in] event {unknown} Hook payload forwarded from the wrapper.
|
|
1441
1472
|
- @param[in] ctx {ExtensionContext} Active extension context.
|
|
1442
1473
|
- @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
1443
1474
|
- @return {void} No return value.
|
|
1444
|
-
- @satisfies REQ-009, REQ-117, REQ-118, REQ-119, REQ-123, REQ-124, REQ-125, REQ-159, REQ-169, REQ-217, REQ-221, REQ-278, REQ-279, REQ-280
|
|
1475
|
+
- @satisfies REQ-009, REQ-117, REQ-118, REQ-119, REQ-123, REQ-124, REQ-125, REQ-159, REQ-169, REQ-217, REQ-221, REQ-278, REQ-279, REQ-280, REQ-285
|
|
1445
1476
|
|
|
1446
|
-
### fn `export function disposePiUsereqStatusController(` (
|
|
1477
|
+
### fn `export function disposePiUsereqStatusController(` (L875-880)
|
|
1447
1478
|
- @brief Disposes the pi-usereq status controller.
|
|
1448
1479
|
- @details Stops the live ticker, clears the cached context pointer, and leaves
|
|
1449
1480
|
the last captured status snapshot available for inspection until the
|
|
@@ -1455,48 +1486,52 @@ limited to interval disposal and in-memory state mutation.
|
|
|
1455
1486
|
## Symbol Index
|
|
1456
1487
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
1457
1488
|
|---|---|---|---|---|
|
|
1458
|
-
|`StatusForegroundColor`|type||
|
|
1459
|
-
|`RawStatusTheme`|iface||
|
|
1460
|
-
|`StatusThemeAdapter`|iface||
|
|
1461
|
-
|`PiUsereqStatusHookName`|type||
|
|
1462
|
-
|`PiUsereqPromptRequest`|type||
|
|
1463
|
-
|`PiUsereqWorkflowState`|type||
|
|
1464
|
-
|`PiUsereqStatusState`|iface||
|
|
1465
|
-
|`PiUsereqStatusController`|iface||
|
|
1466
|
-
|`PiUsereqStatusPersistenceStore`|iface||
|
|
1467
|
-
|`getPiUsereqStatusPersistenceStore`|fn||
|
|
1468
|
-
|`restorePersistedElapsedState`|fn||
|
|
1469
|
-
|`persistElapsedState`|fn||
|
|
1470
|
-
|`persistPromptCommandState`|fn||
|
|
1471
|
-
|`shouldPreservePromptCommandStateOnShutdown`|fn||
|
|
1472
|
-
|`restorePersistedPromptCommandState`|fn||
|
|
1473
|
-
|`getContextSessionFile`|fn||
|
|
1474
|
-
|`isStaleExtensionContextError`|fn||
|
|
1475
|
-
|`resetElapsedState`|fn||
|
|
1476
|
-
|`shouldResetElapsedStateOnSessionStart`|fn||
|
|
1477
|
-
|`shouldResetWorkflowStateOnSessionStart`|fn||
|
|
1478
|
-
|`createStatusThemeAdapter`|fn||
|
|
1479
|
-
|`colorize`|fn||
|
|
1480
|
-
|`
|
|
1481
|
-
|`
|
|
1482
|
-
|`
|
|
1483
|
-
|`
|
|
1484
|
-
|`
|
|
1485
|
-
|`
|
|
1486
|
-
|`
|
|
1487
|
-
|`
|
|
1488
|
-
|`
|
|
1489
|
-
|`
|
|
1490
|
-
|`
|
|
1491
|
-
|`
|
|
1492
|
-
|`
|
|
1493
|
-
|`
|
|
1494
|
-
|`
|
|
1495
|
-
|`
|
|
1496
|
-
|`
|
|
1497
|
-
|`
|
|
1498
|
-
|`
|
|
1499
|
-
|`
|
|
1489
|
+
|`StatusForegroundColor`|type||31||
|
|
1490
|
+
|`RawStatusTheme`|iface||41-43|interface RawStatusTheme|
|
|
1491
|
+
|`StatusThemeAdapter`|iface||51-56|interface StatusThemeAdapter|
|
|
1492
|
+
|`PiUsereqStatusHookName`|type||99||
|
|
1493
|
+
|`PiUsereqPromptRequest`|type||105||
|
|
1494
|
+
|`PiUsereqWorkflowState`|type||111||
|
|
1495
|
+
|`PiUsereqStatusState`|iface||117-126|export interface PiUsereqStatusState|
|
|
1496
|
+
|`PiUsereqStatusController`|iface||135-140|export interface PiUsereqStatusController|
|
|
1497
|
+
|`PiUsereqStatusPersistenceStore`|iface||146-149|interface PiUsereqStatusPersistenceStore|
|
|
1498
|
+
|`getPiUsereqStatusPersistenceStore`|fn||163-172|function getPiUsereqStatusPersistenceStore(): PiUsereqSta...|
|
|
1499
|
+
|`restorePersistedElapsedState`|fn||180-184|function restorePersistedElapsedState(state: PiUsereqStat...|
|
|
1500
|
+
|`persistElapsedState`|fn||192-196|function persistElapsedState(state: PiUsereqStatusState):...|
|
|
1501
|
+
|`persistPromptCommandState`|fn||204-210|function persistPromptCommandState(state: PiUsereqStatusS...|
|
|
1502
|
+
|`shouldPreservePromptCommandStateOnShutdown`|fn||219-222|export function shouldPreservePromptCommandStateOnShutdow...|
|
|
1503
|
+
|`restorePersistedPromptCommandState`|fn||231-242|function restorePersistedPromptCommandState(|
|
|
1504
|
+
|`getContextSessionFile`|fn||250-254|function getContextSessionFile(ctx: ExtensionContext): st...|
|
|
1505
|
+
|`isStaleExtensionContextError`|fn||263-266|export function isStaleExtensionContextError(error: unkno...|
|
|
1506
|
+
|`resetElapsedState`|fn||275-279|function resetElapsedState(state: PiUsereqStatusState): void|
|
|
1507
|
+
|`shouldResetElapsedStateOnSessionStart`|fn||288-291|function shouldResetElapsedStateOnSessionStart(event: unk...|
|
|
1508
|
+
|`shouldResetWorkflowStateOnSessionStart`|fn||300-303|function shouldResetWorkflowStateOnSessionStart(event: un...|
|
|
1509
|
+
|`createStatusThemeAdapter`|fn||313-322|function createStatusThemeAdapter(theme: RawStatusTheme):...|
|
|
1510
|
+
|`colorize`|fn||314-321|const colorize = (color: StatusForegroundColor, text: str...|
|
|
1511
|
+
|`resolveStatusBranchValue`|fn||331-333|function resolveStatusBranchValue(ctx: ExtensionContext):...|
|
|
1512
|
+
|`normalizeContextUsage`|fn||344-361|function normalizeContextUsage(|
|
|
1513
|
+
|`refreshContextUsage`|fn||373-378|function refreshContextUsage(|
|
|
1514
|
+
|`resolveContextUsageIconText`|fn||387-404|function resolveContextUsageIconText(|
|
|
1515
|
+
|`formatContextUsageBar`|fn||414-426|function formatContextUsageBar(|
|
|
1516
|
+
|`formatStatusDuration`|fn||437-442|function formatStatusDuration(durationMs: number): string|
|
|
1517
|
+
|`formatCompletedStatusDuration`|fn||453-457|function formatCompletedStatusDuration(|
|
|
1518
|
+
|`formatElapsedStatusValue`|fn||470-480|function formatElapsedStatusValue(|
|
|
1519
|
+
|`formatStatusField`|fn||491-497|function formatStatusField(|
|
|
1520
|
+
|`formatRenderedStatusField`|fn||509-515|function formatRenderedStatusField(|
|
|
1521
|
+
|`formatWorkflowStateValue`|fn||525-533|function formatWorkflowStateValue(|
|
|
1522
|
+
|`didAgentEndAbort`|fn||544-551|function didAgentEndAbort(messages: AgentEndEvent["messag...|
|
|
1523
|
+
|`resolvePiUsereqRuntimeSoundLevel`|fn||561-566|function resolvePiUsereqRuntimeSoundLevel(|
|
|
1524
|
+
|`buildPiUsereqStatusText`|fn||579-603|function buildPiUsereqStatusText(|
|
|
1525
|
+
|`stopStatusTicker`|fn||613-618|function stopStatusTicker(controller: PiUsereqStatusContr...|
|
|
1526
|
+
|`syncPiUsereqStatusTicker`|fn||630-646|function syncPiUsereqStatusTicker(|
|
|
1527
|
+
|`createPiUsereqStatusController`|fn||654-670|export function createPiUsereqStatusController(): PiUsere...|
|
|
1528
|
+
|`setPiUsereqStatusConfig`|fn||683-688|export function setPiUsereqStatusConfig(|
|
|
1529
|
+
|`getPiUsereqRuntimeSoundLevel`|fn||697-701|export function getPiUsereqRuntimeSoundLevel(|
|
|
1530
|
+
|`setPiUsereqRuntimeSoundLevel`|fn||712-722|export function setPiUsereqRuntimeSoundLevel(|
|
|
1531
|
+
|`renderPiUsereqStatus`|fn||732-763|export function renderPiUsereqStatus(|
|
|
1532
|
+
|`setPiUsereqWorkflowState`|fn||774-785|export function setPiUsereqWorkflowState(|
|
|
1533
|
+
|`updateExtensionStatus`|fn||797-864|export function updateExtensionStatus(|
|
|
1534
|
+
|`disposePiUsereqStatusController`|fn||875-880|export function disposePiUsereqStatusController(|
|
|
1500
1535
|
|
|
1501
1536
|
|
|
1502
1537
|
---
|
|
@@ -2097,7 +2132,7 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2097
2132
|
|
|
2098
2133
|
- type `export type PiNotifyConfigFields = Pick<` (L115)
|
|
2099
2134
|
- @brief Describes the configuration fields consumed by pi-notify helpers.
|
|
2100
|
-
- @details Narrows the full project config to the
|
|
2135
|
+
- @details Narrows the full project config to the notify, sound, and Pushover fields used by status rendering and prompt-end routing. Callers may override `notify-sound` with the active runtime sound level before dispatch. Compile-time only and introduces no runtime cost.
|
|
2101
2136
|
- type `type PiNotifySpawn = typeof spawn;` (L145)
|
|
2102
2137
|
- @brief Describes the shell-spawn callback used by prompt-end command dispatch.
|
|
2103
2138
|
- @details Narrows the injected spawn surface so deterministic tests can capture detached shell invocations without patching global module state externally. Compile-time only and introduces no runtime cost.
|
|
@@ -2182,10 +2217,10 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2182
2217
|
|
|
2183
2218
|
### fn `export function cyclePiNotifySoundLevel(currentLevel: PiNotifySoundLevel): PiNotifySoundLevel` (L371-377)
|
|
2184
2219
|
- @brief Cycles one sound level through the canonical shortcut order.
|
|
2185
|
-
- @details Advances
|
|
2186
|
-
- @param[in] currentLevel {PiNotifySoundLevel} Current
|
|
2187
|
-
- @return {PiNotifySoundLevel} Next sound level in the cycle.
|
|
2188
|
-
- @satisfies REQ-
|
|
2220
|
+
- @details Advances the active runtime sound state in the exact order `none -> low -> mid -> high -> none`, enabling deterministic shortcut toggling without mutating persisted boot configuration. Runtime is O(1). No external state is mutated.
|
|
2221
|
+
- @param[in] currentLevel {PiNotifySoundLevel} Current active runtime sound level.
|
|
2222
|
+
- @return {PiNotifySoundLevel} Next runtime sound level in the cycle.
|
|
2223
|
+
- @satisfies REQ-286
|
|
2189
2224
|
|
|
2190
2225
|
### fn `function isPiNotifyOutcomeEnabled(` (L388-402)
|
|
2191
2226
|
- @brief Tests whether one outcome-specific toggle is enabled.
|
|
@@ -2440,29 +2475,29 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2440
2475
|
|
|
2441
2476
|
---
|
|
2442
2477
|
|
|
2443
|
-
# pi-usereq-tools.ts | TypeScript |
|
|
2478
|
+
# pi-usereq-tools.ts | TypeScript | 180L | 7 symbols | 0 imports | 17 comments
|
|
2444
2479
|
> Path: `src/core/pi-usereq-tools.ts`
|
|
2445
2480
|
- @brief Declares the configurable pi-usereq active-tool inventory.
|
|
2446
2481
|
- @details Provides canonical custom-tool names, supported embedded-tool names, default enablement subsets, and normalization helpers shared by configuration loading, extension startup, and test doubles. The module is side-effect free. Lookup and normalization costs are linear in configured tool count.
|
|
2447
2482
|
|
|
2448
2483
|
## Definitions
|
|
2449
2484
|
|
|
2450
|
-
- type `export type PiUsereqCustomToolName = (typeof PI_USEREQ_CUSTOM_TOOL_NAMES)[number];` (
|
|
2485
|
+
- type `export type PiUsereqCustomToolName = (typeof PI_USEREQ_CUSTOM_TOOL_NAMES)[number];` (L81)
|
|
2451
2486
|
- @brief Represents one valid extension-owned configurable tool identifier.
|
|
2452
2487
|
- @details Narrows arbitrary strings to the literal union derived from `PI_USEREQ_CUSTOM_TOOL_NAMES`. The alias is compile-time only and introduces no runtime cost.
|
|
2453
|
-
- type `export type PiUsereqEmbeddedToolName = (typeof PI_USEREQ_EMBEDDED_TOOL_NAMES)[number];` (
|
|
2488
|
+
- type `export type PiUsereqEmbeddedToolName = (typeof PI_USEREQ_EMBEDDED_TOOL_NAMES)[number];` (L87)
|
|
2454
2489
|
- @brief Represents one valid embedded configurable tool identifier.
|
|
2455
2490
|
- @details Narrows arbitrary strings to the literal union derived from `PI_USEREQ_EMBEDDED_TOOL_NAMES`. The alias is compile-time only and introduces no runtime cost.
|
|
2456
|
-
- type `export type PiUsereqStartupToolName = (typeof PI_USEREQ_STARTUP_TOOL_NAMES)[number];` (
|
|
2491
|
+
- type `export type PiUsereqStartupToolName = (typeof PI_USEREQ_STARTUP_TOOL_NAMES)[number];` (L93)
|
|
2457
2492
|
- @brief Represents one valid configurable active-tool identifier.
|
|
2458
2493
|
- @details Narrows arbitrary strings to the literal union derived from `PI_USEREQ_STARTUP_TOOL_NAMES`. The alias is compile-time only and introduces no runtime cost.
|
|
2459
|
-
### fn `export function isPiUsereqEmbeddedToolName(name: string): name is PiUsereqEmbeddedToolName` (
|
|
2494
|
+
### fn `export function isPiUsereqEmbeddedToolName(name: string): name is PiUsereqEmbeddedToolName` (L119-121)
|
|
2460
2495
|
- @brief Tests whether one tool name belongs to the supported embedded-tool subset.
|
|
2461
2496
|
- @details Performs one set-membership probe against `PI_USEREQ_EMBEDDED_TOOL_SET`. Runtime is O(1). No external state is mutated.
|
|
2462
2497
|
- @param[in] name {string} Candidate tool name.
|
|
2463
2498
|
- @return {boolean} `true` when the name belongs to the embedded configurable-tool subset.
|
|
2464
2499
|
|
|
2465
|
-
### fn `export function normalizeEnabledPiUsereqTools(value: unknown): PiUsereqStartupToolName[]` (
|
|
2500
|
+
### fn `export function normalizeEnabledPiUsereqTools(value: unknown): PiUsereqStartupToolName[]` (L131-138)
|
|
2466
2501
|
- @brief Normalizes a user-configured active-tool list.
|
|
2467
2502
|
- @details Returns the default enabled-tool tuple when the input is not an array. Otherwise filters to string entries, removes names outside the configurable tool set, and deduplicates while preserving first-seen order. Time complexity is O(n). No external state is mutated.
|
|
2468
2503
|
- @param[in] value {unknown} Raw configuration payload for `enabled-tools`.
|
|
@@ -2470,14 +2505,14 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2470
2505
|
- @satisfies REQ-064
|
|
2471
2506
|
- @post Returned values are members of `PI_USEREQ_STARTUP_TOOL_NAMES` only.
|
|
2472
2507
|
|
|
2473
|
-
### fn `function buildPiUsereqStartupToolSortKey(` (
|
|
2508
|
+
### fn `function buildPiUsereqStartupToolSortKey(` (L147-155)
|
|
2474
2509
|
- @brief Builds the menu-order partition key for one configurable tool name.
|
|
2475
2510
|
- @details Encodes the documented `Enable tools` ordering by grouping custom tools before embedded tools, placing non-`files-*` custom tools before `files-*` custom tools, and moving default-disabled names to the tail of each resolved partition. Runtime is O(1). No external state is mutated.
|
|
2476
2511
|
- @param[in] name {PiUsereqStartupToolName} Canonical configurable tool name.
|
|
2477
2512
|
- @return {[number, number, number, string]} Stable tuple `{group, subgroup, default_state, name}` used for lexicographic ordering.
|
|
2478
2513
|
- @satisfies REQ-007, REQ-231, REQ-232
|
|
2479
2514
|
|
|
2480
|
-
### fn `export function comparePiUsereqStartupToolNames(` (
|
|
2515
|
+
### fn `export function comparePiUsereqStartupToolNames(` (L165-180)
|
|
2481
2516
|
- @brief Compares two configurable tool names using the documented menu order.
|
|
2482
2517
|
- @details Applies the partition key emitted by `buildPiUsereqStartupToolSortKey(...)` and falls back to lexical comparison inside the final key slot so the `Enable tools` submenu stays deterministic across runtimes. Runtime is O(1). No external state is mutated.
|
|
2483
2518
|
- @param[in] left {PiUsereqStartupToolName} Left configurable tool name.
|
|
@@ -2488,28 +2523,28 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2488
2523
|
## Symbol Index
|
|
2489
2524
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
2490
2525
|
|---|---|---|---|---|
|
|
2491
|
-
|`PiUsereqCustomToolName`|type||
|
|
2492
|
-
|`PiUsereqEmbeddedToolName`|type||
|
|
2493
|
-
|`PiUsereqStartupToolName`|type||
|
|
2494
|
-
|`isPiUsereqEmbeddedToolName`|fn||
|
|
2495
|
-
|`normalizeEnabledPiUsereqTools`|fn||
|
|
2496
|
-
|`buildPiUsereqStartupToolSortKey`|fn||
|
|
2497
|
-
|`comparePiUsereqStartupToolNames`|fn||
|
|
2526
|
+
|`PiUsereqCustomToolName`|type||81||
|
|
2527
|
+
|`PiUsereqEmbeddedToolName`|type||87||
|
|
2528
|
+
|`PiUsereqStartupToolName`|type||93||
|
|
2529
|
+
|`isPiUsereqEmbeddedToolName`|fn||119-121|export function isPiUsereqEmbeddedToolName(name: string):...|
|
|
2530
|
+
|`normalizeEnabledPiUsereqTools`|fn||131-138|export function normalizeEnabledPiUsereqTools(value: unkn...|
|
|
2531
|
+
|`buildPiUsereqStartupToolSortKey`|fn||147-155|function buildPiUsereqStartupToolSortKey(|
|
|
2532
|
+
|`comparePiUsereqStartupToolNames`|fn||165-180|export function comparePiUsereqStartupToolNames(|
|
|
2498
2533
|
|
|
2499
2534
|
|
|
2500
2535
|
---
|
|
2501
2536
|
|
|
2502
|
-
# prompt-command-catalog.ts | TypeScript |
|
|
2537
|
+
# prompt-command-catalog.ts | TypeScript | 45L | 2 symbols | 0 imports | 4 comments
|
|
2503
2538
|
> Path: `src/core/prompt-command-catalog.ts`
|
|
2504
|
-
- @brief Declares the canonical bundled `req-*`
|
|
2505
|
-
- @details Centralizes prompt-command names shared by extension registration, configuration normalization, debug-menu rendering, and prompt-runtime orchestration. The module is side-effect free. Lookup cost is O(1) per exported constant access.
|
|
2539
|
+
- @brief Declares the canonical bundled prompt-backed `req-*` command inventory.
|
|
2540
|
+
- @details Centralizes only prompt-template-backed command names shared by extension registration, configuration normalization, debug-menu rendering, and prompt-runtime orchestration. Specialized slash commands such as `req-references` and `req-reset` are registered outside this inventory. The module is side-effect free. Lookup cost is O(1) per exported constant access.
|
|
2506
2541
|
|
|
2507
2542
|
## Definitions
|
|
2508
2543
|
|
|
2509
|
-
- type `export type PromptCommandName = (typeof PROMPT_COMMAND_NAMES)[number];` (
|
|
2544
|
+
- type `export type PromptCommandName = (typeof PROMPT_COMMAND_NAMES)[number];` (L33)
|
|
2510
2545
|
- @brief Narrows prompt-command identifiers to the bundled command set.
|
|
2511
2546
|
- @details Compile-time alias reused by orchestration helpers, debug inventory normalization, and command registration. The alias introduces no runtime cost.
|
|
2512
|
-
### fn `export function formatPromptCommandName(` (
|
|
2547
|
+
### fn `export function formatPromptCommandName(` (L41-45)
|
|
2513
2548
|
- @brief Formats one bundled prompt-command identifier as its slash-command name.
|
|
2514
2549
|
- @details Prefixes the canonical prompt name with `req-` so debug menus and log filters can use the invokable slash-command form without duplicating the underlying inventory. Runtime is O(n) in prompt-name length. No external state is mutated.
|
|
2515
2550
|
- @param[in] promptName {PromptCommandName} Canonical bundled prompt name.
|
|
@@ -2518,16 +2553,16 @@ import type { UseReqConfig } from "./config.js";
|
|
|
2518
2553
|
## Symbol Index
|
|
2519
2554
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
2520
2555
|
|---|---|---|---|---|
|
|
2521
|
-
|`PromptCommandName`|type||
|
|
2522
|
-
|`formatPromptCommandName`|fn||
|
|
2556
|
+
|`PromptCommandName`|type||33||
|
|
2557
|
+
|`formatPromptCommandName`|fn||41-45|export function formatPromptCommandName(|
|
|
2523
2558
|
|
|
2524
2559
|
|
|
2525
2560
|
---
|
|
2526
2561
|
|
|
2527
|
-
# prompt-command-runtime.ts | TypeScript |
|
|
2562
|
+
# prompt-command-runtime.ts | TypeScript | 1955L | 56 symbols | 12 imports | 60 comments
|
|
2528
2563
|
> Path: `src/core/prompt-command-runtime.ts`
|
|
2529
|
-
- @brief Implements prompt-command preflight and worktree orchestration.
|
|
2530
|
-
- @details Centralizes `req-<prompt>` repository validation, prompt-specific required-document checks, slash-command-owned worktree naming and lifecycle handling,
|
|
2564
|
+
- @brief Implements bundled prompt-command preflight and worktree orchestration.
|
|
2565
|
+
- @details Centralizes prompt-template-backed `req-<prompt>` repository validation, prompt-specific required-document checks, slash-command-owned worktree naming and lifecycle handling, reusable transcript-preservation plus session-restoration helpers, persisted replacement-session context reuse for non-command lifecycle handlers, matched-success stash-assisted fast-forward merge finalization, and command-side abort cleanup. Runtime is dominated by git subprocess execution plus bounded filesystem and session-file metadata checks. Side effects include active-session replacement, worktree creation and deletion, branch merges, stash-stack mutation, and filesystem reads and writes.
|
|
2531
2566
|
|
|
2532
2567
|
## Imports
|
|
2533
2568
|
```
|
|
@@ -2538,7 +2573,7 @@ import { ReqError } from "./errors.js";
|
|
|
2538
2573
|
import { classifyPiNotifyOutcome, type PiNotifyOutcome } from "./pi-notify.js";
|
|
2539
2574
|
import {
|
|
2540
2575
|
import {
|
|
2541
|
-
import {
|
|
2576
|
+
import { type PromptCommandName } from "./prompt-command-catalog.js";
|
|
2542
2577
|
import {
|
|
2543
2578
|
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
|
2544
2579
|
import { resolveRuntimeGitPath } from "./runtime-project-paths.js";
|
|
@@ -2547,57 +2582,57 @@ import {
|
|
|
2547
2582
|
|
|
2548
2583
|
## Definitions
|
|
2549
2584
|
|
|
2550
|
-
### iface `export interface PromptRequiredDocSpec` (
|
|
2585
|
+
### iface `export interface PromptRequiredDocSpec` (L42-45)
|
|
2551
2586
|
- @brief Describes one canonical required-document probe.
|
|
2552
2587
|
- @details Binds a canonical doc filename to the remediation prompt command surfaced on failure so prompt-specific doc validation can stay deterministic. The interface is compile-time only and introduces no runtime cost.
|
|
2553
2588
|
|
|
2554
|
-
### iface `export interface PromptCommandExecutionPlan` (
|
|
2589
|
+
### iface `export interface PromptCommandExecutionPlan` (L51-65)
|
|
2555
2590
|
- @brief Describes one prompt-command execution plan tracked across lifecycle hooks.
|
|
2556
2591
|
- @details Stores the prompt identity, runtime git root, associated branch name, original project base, execution context path, persisted origin and execution session files, and optional worktree metadata so the extension can switch all cwd surfaces before prompt dispatch and finalize worktree lifecycle after agent end. The interface is compile-time only and introduces no runtime cost.
|
|
2557
2592
|
|
|
2558
|
-
### iface `interface PromptCommandPostCreateHookContext` (
|
|
2593
|
+
### iface `interface PromptCommandPostCreateHookContext` (L71-76)
|
|
2559
2594
|
- @brief Describes one post-create test hook payload for prompt-command worktrees.
|
|
2560
2595
|
- @details Exposes the git root, generated worktree name, sibling worktree path, and effective execution base so tests can simulate post-create verification failures deterministically. The interface is compile-time only and introduces no runtime cost.
|
|
2561
2596
|
|
|
2562
|
-
- type `type PromptCommandPostCreateHook = (context: PromptCommandPostCreateHookContext) => void;` (
|
|
2597
|
+
- type `type PromptCommandPostCreateHook = (context: PromptCommandPostCreateHookContext) => void;` (L82)
|
|
2563
2598
|
- @brief Represents one synchronous test hook invoked after prompt worktree creation.
|
|
2564
2599
|
- @details Allows tests to mutate or remove newly created worktree artifacts before verification executes. The alias is compile-time only and introduces no runtime cost.
|
|
2565
|
-
### iface `interface PromptCommandDebugOptions` (
|
|
2600
|
+
### iface `interface PromptCommandDebugOptions` (L88-91)
|
|
2566
2601
|
- @brief Describes optional debug logging context for prompt orchestration helpers.
|
|
2567
2602
|
- @details Carries the effective project configuration and current workflow state so prompt-runtime helpers can append selected debug entries without depending on extension UI types. The interface is compile-time only and introduces no runtime cost.
|
|
2568
2603
|
|
|
2569
|
-
### iface `interface PromptCommandSessionMessageOptions` (
|
|
2604
|
+
### iface `interface PromptCommandSessionMessageOptions` (L97-99)
|
|
2570
2605
|
- @brief Describes prompt-delivery options supported by replacement-session callbacks.
|
|
2571
2606
|
- @details Mirrors the documented `sendUserMessage(...)` delivery modes needed when prompt orchestration targets a replacement session after a slash-command-owned session switch. The interface is compile-time only and introduces no runtime cost.
|
|
2572
2607
|
|
|
2573
|
-
### iface `interface PromptCommandSessionSwitchOptions` (
|
|
2608
|
+
### iface `interface PromptCommandSessionSwitchOptions` (L105-107)
|
|
2574
2609
|
- @brief Describes the replacement-session callback options accepted by session switching.
|
|
2575
2610
|
- @details Mirrors the documented pi runtime `withSession(...)` hook so prompt-command orchestration can continue work against the replacement session after the old command context becomes stale. The interface is compile-time only and introduces no runtime cost.
|
|
2576
2611
|
|
|
2577
|
-
### iface `interface PromptCommandActiveContext extends PromptCommandSessionContext` : PromptCommandSessionContext (
|
|
2612
|
+
### iface `interface PromptCommandActiveContext extends PromptCommandSessionContext` : PromptCommandSessionContext (L113-118)
|
|
2578
2613
|
- @brief Describes the minimal session-bound surface available after session replacement.
|
|
2579
2614
|
- @details Extends the shared prompt-command context with `sendUserMessage(...)` so prompt dispatch can target the replacement session without reusing stale pre-switch runtime objects. The interface is compile-time only and introduces no runtime cost.
|
|
2580
2615
|
|
|
2581
|
-
### iface `interface PromptCommandSessionEntry` (
|
|
2616
|
+
### iface `interface PromptCommandSessionEntry` (L124-130)
|
|
2582
2617
|
- @brief Describes one serializable session entry copied into a materialized execution-session file.
|
|
2583
2618
|
- @details Captures the stable tree-entry fields needed to write a JSONL session snapshot for cross-cwd session replacement when the origin session file has not been flushed yet. The interface is compile-time only and introduces no runtime cost.
|
|
2584
2619
|
|
|
2585
|
-
### iface `interface PromptCommandSessionContext` (
|
|
2620
|
+
### iface `interface PromptCommandSessionContext` (L136-148)
|
|
2586
2621
|
- @brief Describes the minimal command-context session surface used by prompt orchestration.
|
|
2587
2622
|
- @details Narrows extension command contexts to the `switchSession(...)` hook, the mutable `cwd` mirror, and the session metadata probes required for cwd verification and session snapshot materialization. The interface is compile-time only and introduces no runtime cost.
|
|
2588
2623
|
|
|
2589
|
-
### iface `interface PromptCommandContextError extends Error` : Error (
|
|
2624
|
+
### iface `interface PromptCommandContextError extends Error` : Error (L154-156)
|
|
2590
2625
|
- @brief Describes one error object enriched with a replacement-session context.
|
|
2591
2626
|
- @details Allows prompt orchestration helpers to preserve the last valid session-bound context across replacement boundaries so callers can continue notifications and status updates after switch-triggered failures. The interface is compile-time only and introduces no runtime cost.
|
|
2592
2627
|
|
|
2593
|
-
### fn `function isUsablePromptSessionFile(` (
|
|
2628
|
+
### fn `function isUsablePromptSessionFile(` (L171-189)
|
|
2594
2629
|
- @brief Tests whether the current session file remains reusable for prompt-command bootstrap.
|
|
2595
2630
|
- @details Accepts only persisted session files whose header cwd is readable, still exists on disk, and remains inside the active project base. This rejects stale execution-session files that still point at deleted or sibling worktrees from earlier prompt runs. Runtime is O(p) plus one session-header read. No external state is mutated.
|
|
2596
2631
|
- @param[in] sessionFile {string | undefined} Candidate current session file.
|
|
2597
2632
|
- @param[in] projectBase {string} Active project base path.
|
|
2598
2633
|
- @return {sessionFile is string} `true` when the session file remains reusable for prompt bootstrap.
|
|
2599
2634
|
|
|
2600
|
-
### fn `function resolvePromptSessionFile(sessionFile: string | undefined, cwd: string): string` (
|
|
2635
|
+
### fn `function resolvePromptSessionFile(sessionFile: string | undefined, cwd: string): string` (L199-209)
|
|
2601
2636
|
- @brief Resolves the session file path used as the origin for prompt-command session switching.
|
|
2602
2637
|
- @details Reuses the current session file only when its persisted header cwd is still readable, exists on disk, and remains inside the active project base. Otherwise allocates a fresh session file path rooted at the supplied cwd so later worktree switching and restoration never inherit stale deleted-worktree session metadata. Runtime is dominated by one optional session-header read plus optional session-file allocation. Side effects include session-file path allocation when the active session metadata is stale or ephemeral.
|
|
2603
2638
|
- @param[in] sessionFile {string | undefined} Current active session file when available.
|
|
@@ -2605,7 +2640,7 @@ import {
|
|
|
2605
2640
|
- @return {string} Session file path reserved for prompt orchestration.
|
|
2606
2641
|
- @throws {ReqError} Throws when a session file path cannot be resolved.
|
|
2607
2642
|
|
|
2608
|
-
### fn `function writePromptExecutionSessionSnapshot(` (
|
|
2643
|
+
### fn `function writePromptExecutionSessionSnapshot(` (L223-249)
|
|
2609
2644
|
- @brief Writes one execution-session snapshot file with the target worktree cwd.
|
|
2610
2645
|
- @details Persists a version-3 JSONL session header whose `cwd` equals the supplied target worktree path, then appends the supplied current-session branch entries unchanged so pi can reopen the replacement session in the correct cwd even when the origin session file has not been flushed yet. Runtime is O(n) in branch-entry count plus serialized byte size. Side effects include directory creation and file overwrite.
|
|
2611
2646
|
- @param[in] sessionFile {string} Target execution-session file path.
|
|
@@ -2617,7 +2652,7 @@ import {
|
|
|
2617
2652
|
- @throws {ReqError} Throws when the execution-session snapshot cannot be written.
|
|
2618
2653
|
- @satisfies REQ-271
|
|
2619
2654
|
|
|
2620
|
-
### fn `function createPromptExecutionSessionFile(` (
|
|
2655
|
+
### fn `function createPromptExecutionSessionFile(` (L262-285)
|
|
2621
2656
|
- @brief Creates the persisted session file used for worktree-backed prompt execution.
|
|
2622
2657
|
- @details Forks the resolved origin session into the target cwd when the origin session file is already persisted. Otherwise allocates a new execution-session path, materializes a JSONL header whose `cwd` equals the target worktree path, and copies the current in-memory session branch so pi can switch into the worktree session with the correct runtime cwd. Runtime is dominated by session-file copy or snapshot-write cost. Side effects include session-file creation under the target cwd session directory.
|
|
2623
2658
|
- @param[in] sourceSessionFile {string} Origin session file path.
|
|
@@ -2628,25 +2663,25 @@ import {
|
|
|
2628
2663
|
- @throws {ReqError} Throws when the execution-session file cannot be created.
|
|
2629
2664
|
- @satisfies REQ-271
|
|
2630
2665
|
|
|
2631
|
-
### fn `function getPromptSessionCwd(ctx?: PromptCommandSessionContext): string | undefined` (
|
|
2666
|
+
### fn `function getPromptSessionCwd(ctx?: PromptCommandSessionContext): string | undefined` (L293-301)
|
|
2632
2667
|
- @brief Reads the current active session cwd from a prompt-command context.
|
|
2633
2668
|
- @details Returns the session-manager cwd only when the supplied context exposes the documented `getCwd()` probe and the probe remains valid after any prior session replacement. Stale or missing probes degrade to `undefined` so verification paths never reuse invalidated pre-switch session objects. Runtime is O(1). No external state is mutated.
|
|
2634
2669
|
- @param[in] ctx {PromptCommandSessionContext | undefined} Candidate prompt-command context.
|
|
2635
2670
|
- @return {string | undefined} Active session cwd when available.
|
|
2636
2671
|
|
|
2637
|
-
### fn `function getPromptSessionFile(ctx?: PromptCommandSessionContext): string | undefined` (
|
|
2672
|
+
### fn `function getPromptSessionFile(ctx?: PromptCommandSessionContext): string | undefined` (L309-317)
|
|
2638
2673
|
- @brief Reads the current active session file from a prompt-command context.
|
|
2639
2674
|
- @details Returns the session-manager file path only when the supplied context exposes the documented `getSessionFile()` probe and the probe remains valid after any prior session replacement. Stale or missing probes degrade to `undefined` so verification paths never reuse invalidated pre-switch session objects. Runtime is O(1). No external state is mutated.
|
|
2640
2675
|
- @param[in] ctx {PromptCommandSessionContext | undefined} Candidate prompt-command context.
|
|
2641
2676
|
- @return {string | undefined} Active session file when available.
|
|
2642
2677
|
|
|
2643
|
-
### fn `function getPromptContextCwd(ctx?: PromptCommandSessionContext): string | undefined` (
|
|
2678
|
+
### fn `function getPromptContextCwd(ctx?: PromptCommandSessionContext): string | undefined` (L325-331)
|
|
2644
2679
|
- @brief Reads the current context cwd from a prompt-command context.
|
|
2645
2680
|
- @details Returns the context `cwd` only when the supplied getter remains valid after any prior session replacement. Stale getters degrade to `undefined` so verification paths never depend on invalidated pre-switch command objects. Runtime is O(1). No external state is mutated.
|
|
2646
2681
|
- @param[in] ctx {PromptCommandSessionContext | undefined} Candidate prompt-command context.
|
|
2647
2682
|
- @return {string | undefined} Context cwd when available.
|
|
2648
2683
|
|
|
2649
|
-
### fn `function resolvePromptCommandSwitchContext(` (
|
|
2684
|
+
### fn `function resolvePromptCommandSwitchContext(` (L341-356)
|
|
2650
2685
|
- @brief Resolves the best available command-capable context for prompt session switching.
|
|
2651
2686
|
- @details Prefers the caller-supplied context when it still exposes `switchSession(...)`, otherwise falls back to the persisted replacement-session context associated with the execution-session file so lifecycle handlers can complete closure when pi emits non-command event contexts. Runtime is O(1). No external state is mutated.
|
|
2652
2687
|
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan whose execution-session file keys the persisted context.
|
|
@@ -2654,7 +2689,7 @@ import {
|
|
|
2654
2689
|
- @return {{ context: PromptCommandSessionContext | undefined; source: "provided" | "persisted" | "missing" }} Preferred switch context plus its provenance.
|
|
2655
2690
|
- @satisfies REQ-272, REQ-276
|
|
2656
2691
|
|
|
2657
|
-
### fn `function syncPromptCommandProcessCwd(expectedPath: string, stageLabel: string): void` (
|
|
2692
|
+
### fn `function syncPromptCommandProcessCwd(expectedPath: string, stageLabel: string): void` (L367-387)
|
|
2658
2693
|
- @brief Aligns the host process cwd to one expected prompt-orchestration path.
|
|
2659
2694
|
- @details Applies `process.chdir(...)` only when the host process is still anchored to a different directory than the active prompt session, then re-reads `process.cwd()` and throws a deterministic error when the mutation fails or does not take effect. Runtime is O(p) in path length plus one optional cwd mutation. Side effect: mutates the host process cwd.
|
|
2660
2695
|
- @param[in] expectedPath {string} Path that `process.cwd()` must match.
|
|
@@ -2663,13 +2698,28 @@ import {
|
|
|
2663
2698
|
- @throws {ReqError} Throws when `process.chdir(...)` fails or leaves `process.cwd()` misaligned.
|
|
2664
2699
|
- @satisfies REQ-257, REQ-272
|
|
2665
2700
|
|
|
2666
|
-
### fn `function readPromptSessionFileCwd(sessionFile: string): string | undefined` (
|
|
2701
|
+
### fn `function readPromptSessionFileCwd(sessionFile: string): string | undefined` (L395-419)
|
|
2667
2702
|
- @brief Reads the persisted working directory recorded in one prompt-command session file header.
|
|
2668
2703
|
- @details Opens the JSONL session file, parses the first non-empty line as JSON, and returns the `cwd` field when present as a string so session-target verification can rely on live on-disk session state instead of stale handler-scoped `ctx` references. Runtime is O(n) in header size. No external state is mutated.
|
|
2669
2704
|
- @param[in] sessionFile {string} Absolute session-file path.
|
|
2670
2705
|
- @return {string | undefined} Persisted session cwd when readable; otherwise undefined.
|
|
2671
2706
|
|
|
2672
|
-
### fn `function
|
|
2707
|
+
### fn `function readPromptSessionJsonLines(` (L428-475)
|
|
2708
|
+
- @brief Reads one persisted session file as ordered parsed JSONL records.
|
|
2709
|
+
- @details Loads the raw session file, preserves every non-empty serialized line verbatim, parses each line as one JSON object, and rejects unreadable or structurally invalid files so prompt-closure helpers can replay exact execution-session transcript records into the restored base session without reserialization drift. Runtime is O(n) in session-file size. No external state is mutated.
|
|
2710
|
+
- @param[in] sessionFile {string} Absolute session-file path.
|
|
2711
|
+
- @return {Array<{ rawLine: string; parsed: Record<string, unknown> }>} Parsed non-empty JSONL lines in file order.
|
|
2712
|
+
- @throws {ReqError} Throws when the file cannot be read, when it contains no JSONL records, when any record is not a JSON object, or when the header record is missing.
|
|
2713
|
+
|
|
2714
|
+
### fn `export function preservePromptCommandExecutionTranscript(plan: PromptCommandExecutionPlan): void` (L485-582)
|
|
2715
|
+
- @brief Copies successful execution-session transcript records into the restored base session file.
|
|
2716
|
+
- @details Reads the execution session JSONL file, preserves the original base-session header when it already exists, materializes a restored base-session header when the reserved original session file is still pending persistence, appends any execution-session records missing from the original session in original execution order, and re-reads the restored file to verify both `base-path` cwd and copied entry identifiers. Runtime is O(n) in combined session-file size. Side effects include session-file creation or append operations for the restored base session.
|
|
2717
|
+
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan whose original and execution session files must be synchronized.
|
|
2718
|
+
- @return {void} No return value.
|
|
2719
|
+
- @throws {ReqError} Throws when either session file is unreadable or when appended execution records are not persisted to the original session file.
|
|
2720
|
+
- @satisfies REQ-208, REQ-307
|
|
2721
|
+
|
|
2722
|
+
### fn `function verifyPromptCommandSessionTarget(` (L595-639)
|
|
2673
2723
|
- @brief Verifies that the active session file and cwd surfaces match one expected prompt-orchestration target.
|
|
2674
2724
|
- @details Re-reads the persisted session-file header when present plus the host `process.cwd()` and throws on the first mismatch so prompt commands abort before prompt dispatch or prompt-end handling whenever session switching leaves execution attached to the wrong cwd. A missing persisted session file is treated as a non-fatal lazy-persistence state because pi's `SessionManager` writes session files on first assistant flush rather than eagerly during `ctx.switchSession(sessionPath)`; when the file is absent, pi aligns its internal session cwd to the live `process.cwd()`, so verifying `process.cwd()` alone is authoritative in that state. Reads of `ctx.cwd`, `ctx.sessionManager.getCwd()`, and `ctx.sessionManager.getSessionFile()` are advisory only because the pi `ctx.switchSession(sessionPath)` SDK contract does not mutate the handler-scoped `ctx` object, so those probes stay bound to the pre-switch session and a divergent value alone never triggers abort; they only surface a mismatch when they disagree with both the persisted header cwd and the live `process.cwd()`. Runtime is O(p) in aggregate path length plus one session-file header read. No external state is mutated.
|
|
2675
2725
|
- @param[in] expectedSessionFile {string} Session file that must remain active.
|
|
@@ -2680,7 +2730,7 @@ import {
|
|
|
2680
2730
|
- @throws {ReqError} Throws when the persisted session-file header cwd diverges from the expected target or when `process.cwd()` diverges from the expected target.
|
|
2681
2731
|
- @satisfies REQ-257, REQ-272
|
|
2682
2732
|
|
|
2683
|
-
### fn `function verifyPromptCommandClosureArtifacts(` (
|
|
2733
|
+
### fn `function verifyPromptCommandClosureArtifacts(` (L649-684)
|
|
2684
2734
|
- @brief Verifies persisted prompt execution artifacts before successful closure merge.
|
|
2685
2735
|
- @details Re-reads the persisted execution-session header, verifies the worktree path still exists, confirms the sibling worktree remains registered, and confirms the linked branch is still present before prompt-end closure attempts to restore `base-path` and merge from the original repository. Unlike prompt-start activation checks, this helper intentionally does not require the live process cwd or current session-bound context to remain on `worktree-path`, because pi CLI may already have started end-of-session session replacement or other post-run housekeeping before the extension finishes closure handling. Runtime is dominated by one session-file read, two git subprocess checks, and bounded filesystem probes. No external state is mutated.
|
|
2686
2736
|
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan.
|
|
@@ -2688,7 +2738,7 @@ import {
|
|
|
2688
2738
|
- @throws {ReqError} Throws when persisted execution-session metadata or worktree artifacts no longer match the expected worktree target.
|
|
2689
2739
|
- @satisfies REQ-208, REQ-219, REQ-258, REQ-282
|
|
2690
2740
|
|
|
2691
|
-
### fn `async function switchPromptCommandSession(` (
|
|
2741
|
+
### fn `async function switchPromptCommandSession(` (L695-724)
|
|
2692
2742
|
- @brief Switches the active prompt session to one persisted session file when required.
|
|
2693
2743
|
- @details Calls `ctx.switchSession(sessionPath, { withSession })` so current pi runtimes can expose a fresh replacement-session context for every post-switch session-bound operation. When a runtime ignores the callback, the helper falls back to the caller-supplied context and downstream verification continues to rely on the persisted session-file header plus `process.cwd()`. If pi surfaces only the documented stale-extension-context error while invalidating the old execution-session closure, the helper treats that side effect as non-fatal and lets downstream verification confirm whether the target session actually became active. Runtime is dominated by the session switch. Side effects include active-session replacement and cwd mutation by the host runtime.
|
|
2694
2744
|
- @param[in] sessionFile {string} Target persisted session file.
|
|
@@ -2697,47 +2747,63 @@ import {
|
|
|
2697
2747
|
- @throws {ReqError} Throws when the context cannot switch sessions, when the host cancels the switch, or when later verification proves the target session never became active.
|
|
2698
2748
|
- @satisfies REQ-068, REQ-271, REQ-272
|
|
2699
2749
|
|
|
2700
|
-
### fn `function isPromptCommandStaleContextError(error: unknown): boolean` (
|
|
2750
|
+
### fn `function isPromptCommandStaleContextError(error: unknown): boolean` (L733-736)
|
|
2701
2751
|
- @brief Detects the documented stale-extension-context runtime error during prompt-command session switching.
|
|
2702
2752
|
- @details Matches the guarded pi runtime error emitted when the old execution-session closure is invalidated during a session replacement or reload. Prompt-command session-switch helpers use this detector to distinguish a late stale-context side effect from genuine switch failures, then rely on post-switch verification to confirm whether the target session actually became active. Runtime is O(n) in message length only when an error is supplied. No external state is mutated.
|
|
2703
2753
|
- @param[in] error {unknown} Candidate thrown value.
|
|
2704
2754
|
- @return {boolean} `true` when the value matches the stale-extension-context runtime error.
|
|
2705
2755
|
- @satisfies REQ-280
|
|
2706
2756
|
|
|
2707
|
-
### fn `function attachPromptCommandErrorContext(` (
|
|
2757
|
+
### fn `function attachPromptCommandErrorContext(` (L745-753)
|
|
2708
2758
|
- @brief Attaches the last valid prompt-command context to one thrown error.
|
|
2709
2759
|
- @details Preserves the replacement-session context discovered after `ctx.switchSession(...)` so outer callers can continue UI notifications and cleanup without reusing stale pre-switch command objects. Runtime is O(1). Side effect: mutates the error object when it is an `Error` instance.
|
|
2710
2760
|
- @param[in] error {unknown} Thrown value.
|
|
2711
2761
|
- @param[in] ctx {PromptCommandSessionContext | undefined} Last valid prompt-command context.
|
|
2712
2762
|
- @return {unknown} Original thrown value with optional attached prompt context.
|
|
2713
2763
|
|
|
2714
|
-
### fn `export function getPromptCommandErrorContext(` (
|
|
2764
|
+
### fn `export function getPromptCommandErrorContext(` (L761-767)
|
|
2715
2765
|
- @brief Reads an attached prompt-command context from one thrown error.
|
|
2716
2766
|
- @details Returns the replacement-session context captured by prompt orchestration helpers when a switch-triggered failure occurs after the original command context became stale. Runtime is O(1). No external state is mutated.
|
|
2717
2767
|
- @param[in] error {unknown} Thrown value.
|
|
2718
2768
|
- @return {PromptCommandSessionContext | undefined} Attached prompt-command context when available.
|
|
2719
2769
|
|
|
2720
|
-
### fn `function runCapture(command: string[], cwd: string): ReturnType<typeof spawnSync>` (
|
|
2770
|
+
### fn `function runCapture(command: string[], cwd: string): ReturnType<typeof spawnSync>` (L845-850)
|
|
2721
2771
|
- @brief Executes one git subprocess synchronously and captures UTF-8 output.
|
|
2722
2772
|
- @details Delegates to `spawnSync`, preserves the supplied working directory, and returns the raw subprocess result used by prompt-command orchestration. Runtime is dominated by external process execution. Side effects include process spawning.
|
|
2723
2773
|
- @param[in] command {string[]} Executable plus argument vector.
|
|
2724
2774
|
- @param[in] cwd {string} Working directory for the subprocess.
|
|
2725
2775
|
- @return {ReturnType<typeof spawnSync>} Captured subprocess result.
|
|
2726
2776
|
|
|
2727
|
-
### fn `
|
|
2777
|
+
### fn `function listPromptTrackedBasePathChanges(basePath: string): string[]` (L860-878)
|
|
2778
|
+
- @brief Lists tracked `base-path` status rows that require stash-assisted merge handling.
|
|
2779
|
+
- @details Executes `git status --porcelain`, retains only tracked rows whose index or worktree slot reports a change, and excludes untracked or ignored rows because the required `git stash` command does not preserve them. Runtime is dominated by one git subprocess plus O(n) parsing in status-line count. Side effects include process spawning.
|
|
2780
|
+
- @param[in] basePath {string} Restored project base path.
|
|
2781
|
+
- @return {string[]} Tracked status rows requiring stash-assisted merge handling.
|
|
2782
|
+
- @throws {ReqError} Throws when git status cannot be read from `basePath`.
|
|
2783
|
+
- @satisfies REQ-291
|
|
2784
|
+
|
|
2785
|
+
### fn `function finalizePromptCommandMerge(` (L888-1010)
|
|
2786
|
+
- @brief Executes the successful-closure merge sequence from restored `base-path`.
|
|
2787
|
+
- @details Detects tracked staged or unstaged `base-path` changes, wraps the existing fast-forward merge in `git stash` and `git stash pop` when required, preserves the direct merge path when no tracked changes exist, emits a warning-only result after successful local-change restoration, and writes one merge-finalization debug entry when enabled. Runtime is dominated by up to four git subprocesses plus O(n) status parsing. Side effects include stash-stack mutation, branch merge attempts, and optional debug-log writes.
|
|
2788
|
+
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan whose branch should be merged.
|
|
2789
|
+
- @param[in] debugOptions {PromptCommandDebugOptions | undefined} Optional prompt debug logging context.
|
|
2790
|
+
- @return {{ mergeAttempted: boolean; mergeSucceeded: boolean; errorMessage?: string; warningMessage?: string }} Merge-attempt facts plus optional warning text.
|
|
2791
|
+
- @satisfies REQ-208, REQ-245, REQ-291, REQ-292
|
|
2792
|
+
|
|
2793
|
+
### fn `export function setPromptCommandPostCreateHookForTests(` (L1018-1022)
|
|
2728
2794
|
- @brief Stores or clears the prompt-command post-create test hook.
|
|
2729
2795
|
- @details Enables deterministic simulation of post-create worktree verification failures without altering production control flow. Runtime is O(1). Side effect: mutates module-local test state.
|
|
2730
2796
|
- @param[in] hook {PromptCommandPostCreateHook | undefined} Optional replacement hook.
|
|
2731
2797
|
- @return {void} No return value.
|
|
2732
2798
|
|
|
2733
|
-
### fn `function resolvePromptDocsRoot(projectBase: string, config: UseReqConfig): string` (
|
|
2799
|
+
### fn `function resolvePromptDocsRoot(projectBase: string, config: UseReqConfig): string` (L1031-1034)
|
|
2734
2800
|
- @brief Resolves the configured docs root for one project base.
|
|
2735
2801
|
- @details Joins the project base with the normalized `docs-dir` value while stripping trailing separators from the persisted config field. Runtime is O(p) in path length. No external state is mutated.
|
|
2736
2802
|
- @param[in] projectBase {string} Absolute project root.
|
|
2737
2803
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
2738
2804
|
- @return {string} Absolute canonical docs root path.
|
|
2739
2805
|
|
|
2740
|
-
### fn `function resolveWorktreePaths(` (
|
|
2806
|
+
### fn `function resolveWorktreePaths(` (L1044-1071)
|
|
2741
2807
|
- @brief Resolves the effective worktree project base relative to the git root.
|
|
2742
2808
|
- @details Reuses the original project-base location relative to the git root so nested repository subdirectories remain aligned inside the sibling worktree. Runtime is O(p) in path length. No external state is mutated.
|
|
2743
2809
|
- @param[in] projectBase {string} Original absolute project base path.
|
|
@@ -2745,51 +2811,51 @@ import {
|
|
|
2745
2811
|
- @param[in] worktreeName {string} Created worktree name.
|
|
2746
2812
|
- @return {{ worktreePath: string; worktreeBasePath: string }} Derived worktree paths.
|
|
2747
2813
|
|
|
2748
|
-
### fn `function sanitizePromptWorktreeBranchName(branch: string): string` (
|
|
2814
|
+
### fn `function sanitizePromptWorktreeBranchName(branch: string): string` (L1079-1081)
|
|
2749
2815
|
- @brief Rewrites a branch name into a filesystem-safe token for prompt worktrees.
|
|
2750
2816
|
- @details Replaces characters invalid for worktree directory and branch-name generation with `-`. Runtime is O(n). No external state is mutated.
|
|
2751
2817
|
- @param[in] branch {string} Raw branch name.
|
|
2752
2818
|
- @return {string} Sanitized token.
|
|
2753
2819
|
|
|
2754
|
-
### fn `function validatePromptWorktreeName(wtName: string): boolean` (
|
|
2820
|
+
### fn `function validatePromptWorktreeName(wtName: string): boolean` (L1089-1094)
|
|
2755
2821
|
- @brief Validates a prompt-command-generated worktree or branch name.
|
|
2756
2822
|
- @details Rejects empty names, dot-path markers, whitespace, and filesystem-invalid characters. Runtime is O(n). No external state is mutated.
|
|
2757
2823
|
- @param[in] wtName {string} Candidate worktree name.
|
|
2758
2824
|
- @return {boolean} `true` when the name is acceptable for worktree creation.
|
|
2759
2825
|
|
|
2760
|
-
### fn `function throwPromptGitStatusError(): never` (
|
|
2826
|
+
### fn `function throwPromptGitStatusError(): never` (L1102-1104)
|
|
2761
2827
|
- @brief Throws the canonical prompt-command git-preflight failure.
|
|
2762
2828
|
- @details Normalizes all repository-validation failures to the contractually stable prompt-command error string consumed by tests and downstream prompt workflows. Runtime is O(1). No external state is mutated.
|
|
2763
2829
|
- @return {never} Always throws.
|
|
2764
2830
|
- @throws {ReqError} Always throws with exit code `1`.
|
|
2765
2831
|
|
|
2766
|
-
### fn `function validatePromptGitState(projectBase: string, config?: UseReqConfig): string` (
|
|
2767
|
-
- @brief Runs
|
|
2768
|
-
- @details Validates work-tree membership, porcelain cleanliness, and symbolic or detached `HEAD` presence without invoking extension custom-tool executors. Runtime is dominated by git subprocess execution. Side effects include process spawning.
|
|
2832
|
+
### fn `export function validatePromptGitState(projectBase: string, config?: UseReqConfig): string` (L1115-1159)
|
|
2833
|
+
- @brief Runs slash-command-owned git validation and returns the runtime git root.
|
|
2834
|
+
- @details Validates work-tree membership, porcelain cleanliness, and symbolic or detached `HEAD` presence for bundled prompt commands and `req-references` without invoking extension custom-tool executors. Runtime is dominated by git subprocess execution. Side effects include process spawning.
|
|
2769
2835
|
- @param[in] projectBase {string} Absolute current project base.
|
|
2770
2836
|
- @param[in] config {UseReqConfig | undefined} Optional effective project configuration used to ignore extension-owned debug-log artifacts.
|
|
2771
2837
|
- @return {string} Absolute runtime git root.
|
|
2772
2838
|
- @throws {ReqError} Throws the canonical prompt-command git-preflight error on any validation failure.
|
|
2773
2839
|
- @satisfies REQ-200, REQ-220
|
|
2774
2840
|
|
|
2775
|
-
### fn `function resolveCurrentPromptBranchName(gitRoot: string): string` (
|
|
2841
|
+
### fn `function resolveCurrentPromptBranchName(gitRoot: string): string` (L1167-1172)
|
|
2776
2842
|
- @brief Resolves the current local branch name used by prompt-command orchestration.
|
|
2777
2843
|
- @details Reads `git branch --show-current`, falls back to `unknown` when git cannot provide a branch name, and preserves the raw branch token for later worktree-name generation and state tracking. Runtime is dominated by one git subprocess. Side effects include process spawning.
|
|
2778
2844
|
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
2779
2845
|
- @return {string} Current branch name or `unknown` when unavailable.
|
|
2780
2846
|
|
|
2781
|
-
### fn `function formatPromptWorktreeExecutionId(timestamp: Date): string` (
|
|
2847
|
+
### fn `function formatPromptWorktreeExecutionId(timestamp: Date): string` (L1186-1188)
|
|
2782
2848
|
- @brief Formats one prompt-worktree execution identifier.
|
|
2783
2849
|
- @details Serializes the supplied timestamp as `YYYYMMDDHHMMSS` with zero-padded calendar and clock fields so generated worktree names remain stable, lexicographically sortable, and requirement-compatible. Runtime is O(1). No external state is mutated.
|
|
2784
2850
|
- @param[in] timestamp {Date} Timestamp to encode.
|
|
2785
2851
|
- @return {string} Formatted execution identifier.
|
|
2786
2852
|
|
|
2787
|
-
### fn `function getNextPromptWorktreeExecutionId(): string` (
|
|
2853
|
+
### fn `function getNextPromptWorktreeExecutionId(): string` (L1195-1208)
|
|
2788
2854
|
- @brief Resolves the next unique prompt-worktree execution identifier.
|
|
2789
2855
|
- @details Formats the current wall-clock second as `YYYYMMDDHHMMSS`, then monotonically advances by one-second steps until the identifier is strictly greater than the last value emitted in the current host process. This preserves the documented timestamp-only name shape while preventing immediate same-process worktree-name reuse after fast back-to-back prompt starts. Runtime is O(1) in the common case and O(k) in repeated same-second collisions. Side effect: mutates process-scoped execution-id persistence.
|
|
2790
2856
|
- @return {string} Unique execution identifier for worktree naming.
|
|
2791
2857
|
|
|
2792
|
-
### fn `function buildPromptWorktreeName(gitRoot: string, config: UseReqConfig): string` (
|
|
2858
|
+
### fn `function buildPromptWorktreeName(gitRoot: string, config: UseReqConfig): string` (L1219-1230)
|
|
2793
2859
|
- @brief Builds the prompt-command worktree name without invoking agent-tool executors.
|
|
2794
2860
|
- @details Combines the normalized persisted worktree prefix, repository basename, sanitized current branch, and timestamp execution identifier into the dedicated prompt-command worktree name. Runtime is O(1) plus git execution cost. Side effects include process spawning.
|
|
2795
2861
|
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
@@ -2798,21 +2864,21 @@ import {
|
|
|
2798
2864
|
- @throws {ReqError} Throws when the generated name is invalid.
|
|
2799
2865
|
- @satisfies REQ-206, REQ-220
|
|
2800
2866
|
|
|
2801
|
-
### fn `function promptWorktreeBranchExists(gitRoot: string, branchName: string): boolean` (
|
|
2867
|
+
### fn `function promptWorktreeBranchExists(gitRoot: string, branchName: string): boolean` (L1239-1248)
|
|
2802
2868
|
- @brief Tests whether the exact prompt-command branch is present in the local branch list.
|
|
2803
2869
|
- @details Queries `git branch --list --format=%(refname:short)` and returns a boolean without mutating repository state. Runtime is dominated by one git subprocess plus O(n) parsing in listed branch count. Side effects include process spawning.
|
|
2804
2870
|
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
2805
2871
|
- @param[in] branchName {string} Candidate local branch name.
|
|
2806
2872
|
- @return {boolean} `true` when the exact local branch is listed.
|
|
2807
2873
|
|
|
2808
|
-
### fn `function promptWorktreeRegistered(gitRoot: string, worktreePath: string): boolean` (
|
|
2874
|
+
### fn `function promptWorktreeRegistered(gitRoot: string, worktreePath: string): boolean` (L1257-1268)
|
|
2809
2875
|
- @brief Tests whether the exact prompt-command worktree is registered.
|
|
2810
2876
|
- @details Scans `git worktree list --porcelain` for the resolved target path so cleanup and verification can distinguish registered worktrees from unrelated sibling directories. Runtime is dominated by one git subprocess plus O(n) parsing in listed worktree count. Side effects include process spawning.
|
|
2811
2877
|
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
2812
2878
|
- @param[in] worktreePath {string} Absolute sibling worktree path.
|
|
2813
2879
|
- @return {boolean} `true` when the exact path is registered as a git worktree.
|
|
2814
2880
|
|
|
2815
|
-
### fn `function cleanupPromptWorktreeCreation(` (
|
|
2881
|
+
### fn `function cleanupPromptWorktreeCreation(` (L1278-1292)
|
|
2816
2882
|
- @brief Removes partially created prompt-command worktree resources.
|
|
2817
2883
|
- @details Force-removes the registered sibling worktree when present, deletes the matching local branch, and falls back to filesystem removal for leftover directories so failed prompt preflight leaves no reusable worktree residue. Runtime is dominated by git subprocess execution. Side effects include branch deletion and directory removal.
|
|
2818
2884
|
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
@@ -2820,7 +2886,7 @@ import {
|
|
|
2820
2886
|
- @param[in] worktreeName {string} Exact worktree and branch name.
|
|
2821
2887
|
- @return {void} No return value.
|
|
2822
2888
|
|
|
2823
|
-
### fn `function createPromptWorktree(` (
|
|
2889
|
+
### fn `function createPromptWorktree(` (L1306-1426)
|
|
2824
2890
|
- @brief Creates and verifies the prompt-command worktree and branch.
|
|
2825
2891
|
- @details Creates the sibling worktree, mirrors project config when present, runs the optional post-create test hook, verifies git worktree registration, verifies git branch listing, verifies filesystem paths before prompt dispatch, and appends selected debug entries for worktree creation. Failed verification triggers immediate rollback. Runtime is dominated by git subprocess execution and filesystem metadata checks. Side effects include worktree creation, branch creation, directory creation, file copying, optional debug-log writes, and rollback on failure.
|
|
2826
2892
|
- @param[in] projectBase {string} Absolute original project base.
|
|
@@ -2832,7 +2898,7 @@ import {
|
|
|
2832
2898
|
- @throws {ReqError} Throws when worktree creation, verification, or rollback finalization fails.
|
|
2833
2899
|
- @satisfies REQ-206, REQ-219, REQ-220, REQ-245
|
|
2834
2900
|
|
|
2835
|
-
### fn `function deletePromptWorktree(` (
|
|
2901
|
+
### fn `export function deletePromptWorktree(` (L1439-1499)
|
|
2836
2902
|
- @brief Deletes prompt-command worktree resources without invoking custom-tool executors.
|
|
2837
2903
|
- @details Force-removes the sibling worktree and matching branch, verifies both are absent so prompt finalization remains independent from agent-tool implementations, and appends selected debug entries for worktree deletion. Runtime is dominated by git subprocess execution plus filesystem probes. Side effects include worktree deletion, branch deletion, and optional debug-log writes.
|
|
2838
2904
|
- @param[in] projectBase {string} Absolute original project base.
|
|
@@ -2841,16 +2907,16 @@ import {
|
|
|
2841
2907
|
- @param[in] debugOptions {PromptCommandDebugOptions | undefined} Optional prompt debug logging context.
|
|
2842
2908
|
- @return {void} No return value.
|
|
2843
2909
|
- @throws {ReqError} Throws when cleanup cannot remove the worktree and branch fully.
|
|
2844
|
-
- @satisfies REQ-208, REQ-220, REQ-245
|
|
2910
|
+
- @satisfies REQ-208, REQ-220, REQ-245, REQ-309
|
|
2845
2911
|
|
|
2846
|
-
### fn `export function getPromptRequiredDocs(promptName: PromptCommandName): readonly PromptRequiredDocSpec[]` (
|
|
2912
|
+
### fn `export function getPromptRequiredDocs(promptName: PromptCommandName): readonly PromptRequiredDocSpec[]` (L1508-1510)
|
|
2847
2913
|
- @brief Returns the canonical required-document probes for one prompt command.
|
|
2848
2914
|
- @details Performs a constant-time lookup in the prompt-doc matrix used by command preflight validation. No filesystem access occurs.
|
|
2849
2915
|
- @param[in] promptName {PromptCommandName} Bundled prompt identifier.
|
|
2850
2916
|
- @return {readonly PromptRequiredDocSpec[]} Required-doc definitions in probe order.
|
|
2851
2917
|
- @satisfies REQ-201, REQ-202
|
|
2852
2918
|
|
|
2853
|
-
### fn `export function validatePromptRequiredDocs(` (
|
|
2919
|
+
### fn `export function validatePromptRequiredDocs(` (L1523-1574)
|
|
2854
2920
|
- @brief Runs prompt-specific required-document validation.
|
|
2855
2921
|
- @details Resolves the configured docs root, verifies the prompt-mapped canonical docs exist as files, throws a deterministic remediation error for the first missing document, and appends selected debug entries for required-doc checks. Runtime is O(d) in required-doc count plus filesystem metadata cost. Side effects are limited to filesystem reads and optional debug-log writes.
|
|
2856
2922
|
- @param[in] promptName {PromptCommandName} Bundled prompt identifier.
|
|
@@ -2861,7 +2927,7 @@ import {
|
|
|
2861
2927
|
- @throws {ReqError} Throws when a required canonical doc is missing.
|
|
2862
2928
|
- @satisfies REQ-201, REQ-202, REQ-203, REQ-245
|
|
2863
2929
|
|
|
2864
|
-
### fn `export function preparePromptCommandExecution(` (
|
|
2930
|
+
### fn `export function preparePromptCommandExecution(` (L1591-1667)
|
|
2865
2931
|
- @brief Prepares prompt-command execution for one bundled prompt.
|
|
2866
2932
|
- @details Runs slash-command-owned git validation, enforces the prompt-specific required-doc matrix, resolves persisted origin and execution session files, applies the effective worktree policy, generates and verifies a dedicated worktree when enabled, and returns the execution plan consumed by prompt rendering plus lifecycle hooks. Worktree-backed execution reuses the active session directory for the forked session file. Runtime is dominated by git subprocesses, worktree creation, and optional session-file cloning. Side effects include worktree creation, session-file creation, filesystem reads, and optional prompt debug-log writes.
|
|
2867
2933
|
- @param[in] promptName {PromptCommandName} Bundled prompt identifier.
|
|
@@ -2876,7 +2942,7 @@ import {
|
|
|
2876
2942
|
- @throws {ReqError} Throws when repository validation, required-doc validation, worktree creation, or session preparation fails.
|
|
2877
2943
|
- @satisfies REQ-200, REQ-203, REQ-206, REQ-207, REQ-215, REQ-219, REQ-220, REQ-245, REQ-256, REQ-271
|
|
2878
2944
|
|
|
2879
|
-
### fn `export async function activatePromptCommandExecution(` (
|
|
2945
|
+
### fn `export async function activatePromptCommandExecution(` (L1678-1711)
|
|
2880
2946
|
- @brief Activates the prepared prompt execution path before prompt dispatch or agent start.
|
|
2881
2947
|
- @details Switches the active session to the execution-session file when worktree routing changed the cwd, re-aligns `process.cwd()` to the execution path, verifies active-session cwd plus cwd mirrors after the switch completes, and stores the verified command-capable replacement-session context for later closure handling. Runtime is dominated by the optional session switch and one optional cwd mutation. Side effects include active-session replacement, host-process cwd mutation, runtime-path state mutation, and process-scoped command-context persistence.
|
|
2882
2948
|
- @param[in] plan {PromptCommandExecutionPlan} Prepared prompt execution plan.
|
|
@@ -2885,7 +2951,7 @@ import {
|
|
|
2885
2951
|
- @throws {ReqError} Throws when the session switch or cwd verification fails.
|
|
2886
2952
|
- @satisfies REQ-206, REQ-207, REQ-257, REQ-272, REQ-276
|
|
2887
2953
|
|
|
2888
|
-
### fn `export async function restorePromptCommandExecution(` (
|
|
2954
|
+
### fn `export async function restorePromptCommandExecution(` (L1723-1787)
|
|
2889
2955
|
- @brief Restores the original project base path before merge or session-closure return.
|
|
2890
2956
|
- @details Switches the active session back to the original session file when worktree routing changed the cwd, re-aligns `process.cwd()` to `base-path`, verifies the restored session target, reuses the persisted replacement-session context when lifecycle handlers receive non-command contexts, tolerates the documented stale-extension-context error when the old replacement-session closure becomes invalid immediately after a successful restore, emits optional workflow restoration debug entries, and clears active worktree path facts before session closure continues. Runtime is dominated by the optional session switch and one optional cwd mutation. Side effects include active-session replacement, host-process cwd mutation, runtime-path state mutation, and optional workflow-debug writes.
|
|
2891
2957
|
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan whose original base should be restored.
|
|
@@ -2895,7 +2961,7 @@ import {
|
|
|
2895
2961
|
- @throws {ReqError} Throws when the session switch or cwd verification fails.
|
|
2896
2962
|
- @satisfies REQ-208, REQ-209, REQ-245, REQ-257, REQ-272, REQ-276
|
|
2897
2963
|
|
|
2898
|
-
### fn `export async function abortPromptCommandExecution(` (
|
|
2964
|
+
### fn `export async function abortPromptCommandExecution(` (L1798-1844)
|
|
2899
2965
|
- @brief Aborts one prepared prompt-command execution before pi CLI takes ownership.
|
|
2900
2966
|
- @details Restores the original session-backed cwd and deletes any created worktree plus branch when command-side preflight, prompt rendering, or prompt handoff fails before agent completion. Restoration failures are returned as structured cleanup errors so the original preflight failure is not masked. Runtime is dominated by the optional session switch plus git subprocess execution. Side effects include active-session replacement, optional worktree deletion, and optional debug-log writes.
|
|
2901
2967
|
- @param[in] plan {PromptCommandExecutionPlan} Prepared prompt execution plan.
|
|
@@ -2904,16 +2970,16 @@ import {
|
|
|
2904
2970
|
- @return {Promise<{ cleanupSucceeded: boolean; errorMessage?: string; activeContext?: PromptCommandSessionContext }>} Abort-cleanup facts plus the last valid active prompt-command context.
|
|
2905
2971
|
- @satisfies REQ-226, REQ-220, REQ-245
|
|
2906
2972
|
|
|
2907
|
-
### fn `export async function finalizePromptCommandExecution(` (
|
|
2973
|
+
### fn `export async function finalizePromptCommandExecution(` (L1855-1943)
|
|
2908
2974
|
- @brief Finalizes one matched successful worktree-backed prompt execution.
|
|
2909
|
-
- @details Re-verifies persisted execution-session metadata plus worktree artifacts, restores the original session-backed `base-path`, fast-forward
|
|
2975
|
+
- @details Re-verifies persisted execution-session metadata plus worktree artifacts, copies any execution-session transcript records missing from the original session file, restores the original session-backed `base-path`, executes the stash-assisted fast-forward merge sequence from `base-path`, deletes the worktree after merge success, and preserves the restored base session across closure failures. Closure intentionally treats `base-path` restoration as authoritative even when pi CLI has already started end-of-session session replacement or other housekeeping that moved the live runtime away from `worktree-path`. Runtime is dominated by session switching plus git subprocess execution. Side effects include session-file appends, active-session replacement, branch merges, stash-stack mutation, worktree deletion, and optional debug-log writes.
|
|
2910
2976
|
- @param[in] plan {PromptCommandExecutionPlan} Prompt execution plan.
|
|
2911
2977
|
- @param[in] ctx {PromptCommandSessionContext | undefined} Optional prompt-command context.
|
|
2912
2978
|
- @param[in] debugOptions {PromptCommandDebugOptions | undefined} Optional prompt debug logging context.
|
|
2913
|
-
- @return {Promise<{ mergeAttempted: boolean; mergeSucceeded: boolean; cleanupSucceeded: boolean; errorMessage?: string; activeContext?: PromptCommandSessionContext }>} Finalization facts plus the last valid active prompt-command context.
|
|
2914
|
-
- @satisfies REQ-208, REQ-209, REQ-220, REQ-245, REQ-282
|
|
2979
|
+
- @return {Promise<{ mergeAttempted: boolean; mergeSucceeded: boolean; cleanupSucceeded: boolean; errorMessage?: string; warningMessage?: string; activeContext?: PromptCommandSessionContext }>} Finalization facts plus the last valid active prompt-command context.
|
|
2980
|
+
- @satisfies REQ-208, REQ-209, REQ-220, REQ-245, REQ-282, REQ-291, REQ-292
|
|
2915
2981
|
|
|
2916
|
-
### fn `export function classifyPromptCommandOutcome(` (
|
|
2982
|
+
### fn `export function classifyPromptCommandOutcome(` (L1951-1955)
|
|
2917
2983
|
- @brief Maps one `agent_end` payload into the canonical prompt-worktree finalization outcome.
|
|
2918
2984
|
- @details Delegates to the shared notification outcome classifier so worktree merge and fork-session retention decisions stay aligned with prompt-end notification routing. Runtime is O(m) in assistant message count. No external state is mutated.
|
|
2919
2985
|
- @param[in] event {Pick<import("@mariozechner/pi-coding-agent").AgentEndEvent, "messages">} Agent-end payload subset.
|
|
@@ -2922,58 +2988,62 @@ import {
|
|
|
2922
2988
|
## Symbol Index
|
|
2923
2989
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
2924
2990
|
|---|---|---|---|---|
|
|
2925
|
-
|`PromptRequiredDocSpec`|iface||45
|
|
2926
|
-
|`PromptCommandExecutionPlan`|iface||
|
|
2927
|
-
|`PromptCommandPostCreateHookContext`|iface||
|
|
2928
|
-
|`PromptCommandPostCreateHook`|type||
|
|
2929
|
-
|`PromptCommandDebugOptions`|iface||91
|
|
2930
|
-
|`PromptCommandSessionMessageOptions`|iface||
|
|
2931
|
-
|`PromptCommandSessionSwitchOptions`|iface||
|
|
2932
|
-
|`PromptCommandActiveContext`|iface||
|
|
2933
|
-
|`PromptCommandSessionEntry`|iface||
|
|
2934
|
-
|`PromptCommandSessionContext`|iface||
|
|
2935
|
-
|`PromptCommandContextError`|iface||
|
|
2936
|
-
|`isUsablePromptSessionFile`|fn||
|
|
2937
|
-
|`resolvePromptSessionFile`|fn||
|
|
2938
|
-
|`writePromptExecutionSessionSnapshot`|fn||
|
|
2939
|
-
|`createPromptExecutionSessionFile`|fn||
|
|
2940
|
-
|`getPromptSessionCwd`|fn||
|
|
2941
|
-
|`getPromptSessionFile`|fn||
|
|
2942
|
-
|`getPromptContextCwd`|fn||
|
|
2943
|
-
|`resolvePromptCommandSwitchContext`|fn||
|
|
2944
|
-
|`syncPromptCommandProcessCwd`|fn||
|
|
2945
|
-
|`readPromptSessionFileCwd`|fn||
|
|
2946
|
-
|`
|
|
2947
|
-
|`
|
|
2948
|
-
|`
|
|
2949
|
-
|`
|
|
2950
|
-
|`
|
|
2951
|
-
|`
|
|
2952
|
-
|`
|
|
2953
|
-
|`
|
|
2954
|
-
|`
|
|
2955
|
-
|`
|
|
2956
|
-
|`
|
|
2957
|
-
|`
|
|
2958
|
-
|`
|
|
2959
|
-
|`
|
|
2960
|
-
|`
|
|
2961
|
-
|`
|
|
2962
|
-
|`
|
|
2963
|
-
|`
|
|
2964
|
-
|`
|
|
2965
|
-
|`
|
|
2966
|
-
|`
|
|
2967
|
-
|`
|
|
2968
|
-
|`
|
|
2969
|
-
|`
|
|
2970
|
-
|`
|
|
2971
|
-
|`
|
|
2972
|
-
|`
|
|
2973
|
-
|`
|
|
2974
|
-
|`
|
|
2975
|
-
|`
|
|
2976
|
-
|`
|
|
2991
|
+
|`PromptRequiredDocSpec`|iface||42-45|export interface PromptRequiredDocSpec|
|
|
2992
|
+
|`PromptCommandExecutionPlan`|iface||51-65|export interface PromptCommandExecutionPlan|
|
|
2993
|
+
|`PromptCommandPostCreateHookContext`|iface||71-76|interface PromptCommandPostCreateHookContext|
|
|
2994
|
+
|`PromptCommandPostCreateHook`|type||82||
|
|
2995
|
+
|`PromptCommandDebugOptions`|iface||88-91|interface PromptCommandDebugOptions|
|
|
2996
|
+
|`PromptCommandSessionMessageOptions`|iface||97-99|interface PromptCommandSessionMessageOptions|
|
|
2997
|
+
|`PromptCommandSessionSwitchOptions`|iface||105-107|interface PromptCommandSessionSwitchOptions|
|
|
2998
|
+
|`PromptCommandActiveContext`|iface||113-118|interface PromptCommandActiveContext extends PromptComman...|
|
|
2999
|
+
|`PromptCommandSessionEntry`|iface||124-130|interface PromptCommandSessionEntry|
|
|
3000
|
+
|`PromptCommandSessionContext`|iface||136-148|interface PromptCommandSessionContext|
|
|
3001
|
+
|`PromptCommandContextError`|iface||154-156|interface PromptCommandContextError extends Error|
|
|
3002
|
+
|`isUsablePromptSessionFile`|fn||171-189|function isUsablePromptSessionFile(|
|
|
3003
|
+
|`resolvePromptSessionFile`|fn||199-209|function resolvePromptSessionFile(sessionFile: string | u...|
|
|
3004
|
+
|`writePromptExecutionSessionSnapshot`|fn||223-249|function writePromptExecutionSessionSnapshot(|
|
|
3005
|
+
|`createPromptExecutionSessionFile`|fn||262-285|function createPromptExecutionSessionFile(|
|
|
3006
|
+
|`getPromptSessionCwd`|fn||293-301|function getPromptSessionCwd(ctx?: PromptCommandSessionCo...|
|
|
3007
|
+
|`getPromptSessionFile`|fn||309-317|function getPromptSessionFile(ctx?: PromptCommandSessionC...|
|
|
3008
|
+
|`getPromptContextCwd`|fn||325-331|function getPromptContextCwd(ctx?: PromptCommandSessionCo...|
|
|
3009
|
+
|`resolvePromptCommandSwitchContext`|fn||341-356|function resolvePromptCommandSwitchContext(|
|
|
3010
|
+
|`syncPromptCommandProcessCwd`|fn||367-387|function syncPromptCommandProcessCwd(expectedPath: string...|
|
|
3011
|
+
|`readPromptSessionFileCwd`|fn||395-419|function readPromptSessionFileCwd(sessionFile: string): s...|
|
|
3012
|
+
|`readPromptSessionJsonLines`|fn||428-475|function readPromptSessionJsonLines(|
|
|
3013
|
+
|`preservePromptCommandExecutionTranscript`|fn||485-582|export function preservePromptCommandExecutionTranscript(...|
|
|
3014
|
+
|`verifyPromptCommandSessionTarget`|fn||595-639|function verifyPromptCommandSessionTarget(|
|
|
3015
|
+
|`verifyPromptCommandClosureArtifacts`|fn||649-684|function verifyPromptCommandClosureArtifacts(|
|
|
3016
|
+
|`switchPromptCommandSession`|fn||695-724|async function switchPromptCommandSession(|
|
|
3017
|
+
|`isPromptCommandStaleContextError`|fn||733-736|function isPromptCommandStaleContextError(error: unknown)...|
|
|
3018
|
+
|`attachPromptCommandErrorContext`|fn||745-753|function attachPromptCommandErrorContext(|
|
|
3019
|
+
|`getPromptCommandErrorContext`|fn||761-767|export function getPromptCommandErrorContext(|
|
|
3020
|
+
|`runCapture`|fn||845-850|function runCapture(command: string[], cwd: string): Retu...|
|
|
3021
|
+
|`listPromptTrackedBasePathChanges`|fn||860-878|function listPromptTrackedBasePathChanges(basePath: strin...|
|
|
3022
|
+
|`finalizePromptCommandMerge`|fn||888-1010|function finalizePromptCommandMerge(|
|
|
3023
|
+
|`setPromptCommandPostCreateHookForTests`|fn||1018-1022|export function setPromptCommandPostCreateHookForTests(|
|
|
3024
|
+
|`resolvePromptDocsRoot`|fn||1031-1034|function resolvePromptDocsRoot(projectBase: string, confi...|
|
|
3025
|
+
|`resolveWorktreePaths`|fn||1044-1071|function resolveWorktreePaths(|
|
|
3026
|
+
|`sanitizePromptWorktreeBranchName`|fn||1079-1081|function sanitizePromptWorktreeBranchName(branch: string)...|
|
|
3027
|
+
|`validatePromptWorktreeName`|fn||1089-1094|function validatePromptWorktreeName(wtName: string): boolean|
|
|
3028
|
+
|`throwPromptGitStatusError`|fn||1102-1104|function throwPromptGitStatusError(): never|
|
|
3029
|
+
|`validatePromptGitState`|fn||1115-1159|export function validatePromptGitState(projectBase: strin...|
|
|
3030
|
+
|`resolveCurrentPromptBranchName`|fn||1167-1172|function resolveCurrentPromptBranchName(gitRoot: string):...|
|
|
3031
|
+
|`formatPromptWorktreeExecutionId`|fn||1186-1188|function formatPromptWorktreeExecutionId(timestamp: Date)...|
|
|
3032
|
+
|`getNextPromptWorktreeExecutionId`|fn||1195-1208|function getNextPromptWorktreeExecutionId(): string|
|
|
3033
|
+
|`buildPromptWorktreeName`|fn||1219-1230|function buildPromptWorktreeName(gitRoot: string, config:...|
|
|
3034
|
+
|`promptWorktreeBranchExists`|fn||1239-1248|function promptWorktreeBranchExists(gitRoot: string, bran...|
|
|
3035
|
+
|`promptWorktreeRegistered`|fn||1257-1268|function promptWorktreeRegistered(gitRoot: string, worktr...|
|
|
3036
|
+
|`cleanupPromptWorktreeCreation`|fn||1278-1292|function cleanupPromptWorktreeCreation(|
|
|
3037
|
+
|`createPromptWorktree`|fn||1306-1426|function createPromptWorktree(|
|
|
3038
|
+
|`deletePromptWorktree`|fn||1439-1499|export function deletePromptWorktree(|
|
|
3039
|
+
|`getPromptRequiredDocs`|fn||1508-1510|export function getPromptRequiredDocs(promptName: PromptC...|
|
|
3040
|
+
|`validatePromptRequiredDocs`|fn||1523-1574|export function validatePromptRequiredDocs(|
|
|
3041
|
+
|`preparePromptCommandExecution`|fn||1591-1667|export function preparePromptCommandExecution(|
|
|
3042
|
+
|`activatePromptCommandExecution`|fn||1678-1711|export async function activatePromptCommandExecution(|
|
|
3043
|
+
|`restorePromptCommandExecution`|fn||1723-1787|export async function restorePromptCommandExecution(|
|
|
3044
|
+
|`abortPromptCommandExecution`|fn||1798-1844|export async function abortPromptCommandExecution(|
|
|
3045
|
+
|`finalizePromptCommandExecution`|fn||1855-1943|export async function finalizePromptCommandExecution(|
|
|
3046
|
+
|`classifyPromptCommandOutcome`|fn||1951-1955|export function classifyPromptCommandOutcome(|
|
|
2977
3047
|
|
|
2978
3048
|
|
|
2979
3049
|
---
|
|
@@ -3071,7 +3141,7 @@ import type { PromptCommandExecutionPlan } from "./prompt-command-runtime.js";
|
|
|
3071
3141
|
|
|
3072
3142
|
---
|
|
3073
3143
|
|
|
3074
|
-
# prompts.ts | TypeScript |
|
|
3144
|
+
# prompts.ts | TypeScript | 314L | 9 symbols | 7 imports | 17 comments
|
|
3075
3145
|
> Path: `src/core/prompts.ts`
|
|
3076
3146
|
- @brief Renders bundled pi-usereq prompts for the current project context.
|
|
3077
3147
|
- @details Applies placeholder substitution, legacy tool-name rewrites, and conditional pi.dev governance guidance before prompt text is sent to the agent. Runtime is linear in prompt size plus replacement count. Side effects are limited to filesystem reads used for manifest checks and bundled prompt loading.
|
|
@@ -3089,7 +3159,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3089
3159
|
|
|
3090
3160
|
## Definitions
|
|
3091
3161
|
|
|
3092
|
-
### fn `function buildPiDevConformanceBlock(promptName: string, projectBase: string): string` (
|
|
3162
|
+
### fn `function buildPiDevConformanceBlock(promptName: string, projectBase: string): string` (L109-118)
|
|
3093
3163
|
- @brief Builds the conditional pi.dev governance block for one rendered prompt.
|
|
3094
3164
|
- @details Emits the manifest-driven governance rules only when the selected bundled prompt can analyze or mutate source code and the project root contains the pi.dev manifest. Time complexity O(1). No filesystem writes.
|
|
3095
3165
|
- @param[in] promptName {string} Bundled prompt identifier.
|
|
@@ -3097,7 +3167,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3097
3167
|
- @return {string} Markdown bullet block or the empty string when injection is not applicable.
|
|
3098
3168
|
- @satisfies REQ-032, REQ-033, REQ-034, REQ-108, REQ-273, REQ-274, REQ-275
|
|
3099
3169
|
|
|
3100
|
-
### fn `function injectPiDevConformanceBlock(text: string, promptName: string, projectBase: string): string` (
|
|
3170
|
+
### fn `function injectPiDevConformanceBlock(text: string, promptName: string, projectBase: string): string` (L129-136)
|
|
3101
3171
|
- @brief Injects the pi.dev governance block into the prompt behavior section.
|
|
3102
3172
|
- @details Inserts the block immediately after the `## Behavior` heading so downstream agents evaluate the rule before workflow steps. Leaves prompts unchanged when no behavior section exists or the block is already present. Time complexity O(n).
|
|
3103
3173
|
- @param[in] text {string} Prompt markdown after placeholder replacement.
|
|
@@ -3106,14 +3176,14 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3106
3176
|
- @return {string} Prompt markdown with zero or one injected conformance block.
|
|
3107
3177
|
- @satisfies REQ-032, REQ-033, REQ-034, REQ-108, REQ-273, REQ-274, REQ-275
|
|
3108
3178
|
|
|
3109
|
-
### fn `export function adaptPromptForInternalTools(text: string): string` (
|
|
3179
|
+
### fn `export function adaptPromptForInternalTools(text: string): string` (L145-151)
|
|
3110
3180
|
- @brief Rewrites bundled prompt tool references from legacy `req --...` syntax to internal tool names.
|
|
3111
3181
|
- @details Applies deterministic global regex replacements so prompt text matches the extension-registered tool surface instead of the standalone CLI spelling. Time complexity O(p*r) where p is pattern count and r is prompt length.
|
|
3112
3182
|
- @param[in] text {string} Prompt markdown before tool-reference normalization.
|
|
3113
3183
|
- @return {string} Prompt markdown with internal tool names.
|
|
3114
3184
|
- @satisfies REQ-003
|
|
3115
3185
|
|
|
3116
|
-
### fn `export function applyReplacements(text: string, replacements: Record<string, string>): string` (
|
|
3186
|
+
### fn `export function applyReplacements(text: string, replacements: Record<string, string>): string` (L161-167)
|
|
3117
3187
|
- @brief Applies literal placeholder replacements to bundled prompt markdown.
|
|
3118
3188
|
- @details Replaces every placeholder token using split/join semantics so all occurrences are updated without regex escaping. Time complexity O(t*n) where t is replacement count and n is prompt length.
|
|
3119
3189
|
- @param[in] text {string} Prompt markdown containing placeholder tokens.
|
|
@@ -3121,7 +3191,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3121
3191
|
- @return {string} Prompt markdown with all placeholder tokens expanded.
|
|
3122
3192
|
- @satisfies REQ-002
|
|
3123
3193
|
|
|
3124
|
-
### fn `function buildPromptExecutionBlock(` (
|
|
3194
|
+
### fn `function buildPromptExecutionBlock(` (L177-199)
|
|
3125
3195
|
- @brief Builds the prompt-command execution block injected at prompt start.
|
|
3126
3196
|
- @details Serializes the already-completed repository validation, prompt-specific required-doc validation, worktree routing decision, and extension-owned lifecycle responsibilities so downstream agents do not repeat command-side orchestration. Time complexity is O(d) in required-doc count. No external state is mutated.
|
|
3127
3197
|
- @param[in] promptName {PromptCommandName} Bundled prompt identifier.
|
|
@@ -3129,7 +3199,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3129
3199
|
- @return {string} Markdown block or the empty string when runtime execution metadata is unavailable.
|
|
3130
3200
|
- @satisfies REQ-200, REQ-201, REQ-202, REQ-206, REQ-207, REQ-208, REQ-209
|
|
3131
3201
|
|
|
3132
|
-
### fn `function injectPromptExecutionBlock(` (
|
|
3202
|
+
### fn `function injectPromptExecutionBlock(` (L209-220)
|
|
3133
3203
|
- @brief Injects the prompt-command execution block near the start of the rendered prompt.
|
|
3134
3204
|
- @details Inserts the execution block immediately after the first level-1 heading so downstream agents evaluate extension-owned orchestration before workflow steps. Leaves prompts unchanged when no execution block is provided or when the block is already present. Time complexity O(n).
|
|
3135
3205
|
- @param[in] text {string} Prompt markdown after placeholder replacement.
|
|
@@ -3137,7 +3207,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3137
3207
|
- @param[in] executionPlan {PromptCommandExecutionPlan | undefined} Prepared execution plan.
|
|
3138
3208
|
- @return {string} Prompt markdown with zero or one injected execution block.
|
|
3139
3209
|
|
|
3140
|
-
### fn `function buildPromptReplacements(` (
|
|
3210
|
+
### fn `function buildPromptReplacements(` (L232-244)
|
|
3141
3211
|
- @brief Builds prompt-specific runtime placeholder replacements.
|
|
3142
3212
|
- @details Merges shared path substitutions with prompt-scoped runtime values for `%%ARGS%%` and `%%PROMPT%%`. Time complexity is O(g log g + s) due to delegated path replacement building, where g is guideline count and s is source-directory count. Side effects are limited to filesystem reads delegated to shared path-context helpers.
|
|
3143
3213
|
- @param[in] promptName {string} Bundled prompt identifier without the `req-` prefix.
|
|
@@ -3147,7 +3217,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3147
3217
|
- @return {Record<string, string>} Prompt-specific placeholder-to-value map.
|
|
3148
3218
|
- @satisfies REQ-002, REQ-211
|
|
3149
3219
|
|
|
3150
|
-
### fn `function renderBundledCommitInstruction(` (
|
|
3220
|
+
### fn `function renderBundledCommitInstruction(` (L256-270)
|
|
3151
3221
|
- @brief Renders the bundled git instruction injected through `%%COMMIT%%`.
|
|
3152
3222
|
- @details Selects `resources/instructions/git_commit.md` when automatic git commit is enabled and `resources/instructions/git_read-only.md` otherwise, then applies the same runtime placeholder substitutions used by bundled prompts before returning the rendered markdown. Time complexity is O(n + g log g + s) where n is instruction size, g is guideline count, and s is source-directory count. Side effects are limited to filesystem reads.
|
|
3153
3223
|
- @param[in] promptName {string} Bundled prompt identifier without the `req-` prefix.
|
|
@@ -3157,7 +3227,7 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3157
3227
|
- @return {string} Rendered bundled git instruction selected for the current automatic-commit mode.
|
|
3158
3228
|
- @satisfies REQ-211, REQ-213, REQ-214
|
|
3159
3229
|
|
|
3160
|
-
### fn `export function renderPrompt(` (
|
|
3230
|
+
### fn `export function renderPrompt(` (L283-314)
|
|
3161
3231
|
- @brief Renders a bundled prompt for the current project context.
|
|
3162
3232
|
- @details Loads the bundled markdown template, expands configuration-derived placeholders, injects extension-owned execution guidance plus conditional pi.dev governance guidance, expands the optional bundled commit instruction, and rewrites legacy tool references to internal names. Time complexity O(n) relative to prompt size plus delegated commit-instruction rendering. No tracked files are modified.
|
|
3163
3233
|
- @param[in] promptName {string} Bundled prompt identifier.
|
|
@@ -3171,211 +3241,223 @@ import { readBundledInstruction, readBundledPrompt } from "./resources.js";
|
|
|
3171
3241
|
## Symbol Index
|
|
3172
3242
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
3173
3243
|
|---|---|---|---|---|
|
|
3174
|
-
|`buildPiDevConformanceBlock`|fn||
|
|
3175
|
-
|`injectPiDevConformanceBlock`|fn||
|
|
3176
|
-
|`adaptPromptForInternalTools`|fn||
|
|
3177
|
-
|`applyReplacements`|fn||
|
|
3178
|
-
|`buildPromptExecutionBlock`|fn||
|
|
3179
|
-
|`injectPromptExecutionBlock`|fn||
|
|
3180
|
-
|`buildPromptReplacements`|fn||
|
|
3181
|
-
|`renderBundledCommitInstruction`|fn||
|
|
3182
|
-
|`renderPrompt`|fn||
|
|
3244
|
+
|`buildPiDevConformanceBlock`|fn||109-118|function buildPiDevConformanceBlock(promptName: string, p...|
|
|
3245
|
+
|`injectPiDevConformanceBlock`|fn||129-136|function injectPiDevConformanceBlock(text: string, prompt...|
|
|
3246
|
+
|`adaptPromptForInternalTools`|fn||145-151|export function adaptPromptForInternalTools(text: string)...|
|
|
3247
|
+
|`applyReplacements`|fn||161-167|export function applyReplacements(text: string, replaceme...|
|
|
3248
|
+
|`buildPromptExecutionBlock`|fn||177-199|function buildPromptExecutionBlock(|
|
|
3249
|
+
|`injectPromptExecutionBlock`|fn||209-220|function injectPromptExecutionBlock(|
|
|
3250
|
+
|`buildPromptReplacements`|fn||232-244|function buildPromptReplacements(|
|
|
3251
|
+
|`renderBundledCommitInstruction`|fn||256-270|function renderBundledCommitInstruction(|
|
|
3252
|
+
|`renderPrompt`|fn||283-314|export function renderPrompt(|
|
|
3183
3253
|
|
|
3184
3254
|
|
|
3185
3255
|
---
|
|
3186
3256
|
|
|
3187
|
-
#
|
|
3188
|
-
> Path: `src/core/
|
|
3189
|
-
- @brief
|
|
3190
|
-
- @details
|
|
3257
|
+
# req-references-command.ts | TypeScript | 175L | 7 symbols | 6 imports | 10 comments
|
|
3258
|
+
> Path: `src/core/req-references-command.ts`
|
|
3259
|
+
- @brief Implements the specialized `req-references` slash-command workflow.
|
|
3260
|
+
- @details Performs slash-command-owned git validation reuse, reference-file generation, targeted staging, fixed-message commit creation, and post-commit cleanliness verification without creating a worktree or starting an LLM session. Runtime is dominated by git subprocess execution plus source-summary generation and one documentation write. Side effects include filesystem writes and git index/history mutation.
|
|
3191
3261
|
|
|
3192
3262
|
## Imports
|
|
3193
3263
|
```
|
|
3194
|
-
import
|
|
3264
|
+
import { spawnSync } from "node:child_process";
|
|
3195
3265
|
import path from "node:path";
|
|
3196
|
-
import {
|
|
3197
|
-
import {
|
|
3198
|
-
import {
|
|
3266
|
+
import type { UseReqConfig } from "./config.js";
|
|
3267
|
+
import { ReqError } from "./errors.js";
|
|
3268
|
+
import { validatePromptGitState } from "./prompt-command-runtime.js";
|
|
3269
|
+
import { runReferences } from "./tool-runner.js";
|
|
3199
3270
|
```
|
|
3200
3271
|
|
|
3201
3272
|
## Definitions
|
|
3202
3273
|
|
|
3203
|
-
|
|
3204
|
-
- @brief
|
|
3205
|
-
- @details
|
|
3206
|
-
- type `export type ReferenceFileStatus = "analyzed" | "error" | "skipped";` (L33)
|
|
3207
|
-
- @brief Enumerates supported per-file references entry statuses.
|
|
3208
|
-
- @details Separates analyzed files, analysis failures, and skipped inputs so downstream agents can branch without reparsing stderr text. The alias is compile-time only and introduces no runtime cost.
|
|
3209
|
-
### iface `export interface ReferenceLineRange` (L39-43)
|
|
3210
|
-
- @brief Describes one numeric source line range.
|
|
3211
|
-
- @details Exposes start and end line numbers plus the same inclusive range as a numeric tuple for direct agent access. The interface is compile-time only and introduces no runtime cost.
|
|
3212
|
-
|
|
3213
|
-
### iface `export interface ReferenceImportEntry extends ReferenceLineRange` : ReferenceLineRange (L49-52)
|
|
3214
|
-
- @brief Describes one structured import record.
|
|
3215
|
-
- @details Stores the normalized import identity, raw import statement, and declaration line range without requiring agents to parse markdown blocks. The interface is compile-time only and introduces no runtime cost.
|
|
3216
|
-
|
|
3217
|
-
### iface `export interface ReferenceCommentEntry extends ReferenceLineRange` : ReferenceLineRange (L58-61)
|
|
3218
|
-
- @brief Describes one structured standalone or attached comment record.
|
|
3219
|
-
- @details Preserves normalized comment text plus per-line comment fragments so agents can consume comment evidence without reparsing source delimiters. The interface is compile-time only and introduces no runtime cost.
|
|
3220
|
-
|
|
3221
|
-
### iface `export interface ReferenceExitPointEntry` (L67-70)
|
|
3222
|
-
- @brief Describes one structured exit-point annotation.
|
|
3223
|
-
- @details Preserves the normalized exit expression text together with its source line number for downstream reasoning about control flow hints. The interface is compile-time only and introduces no runtime cost.
|
|
3274
|
+
### iface `export interface ReqReferencesCommandPlan` (L30-35)
|
|
3275
|
+
- @brief Describes the prepared execution facts for one `req-references` run.
|
|
3276
|
+
- @details Stores the validated project base, resolved git root, target references path, and fixed commit message needed by the specialized direct-write workflow. The interface is compile-time only and introduces no runtime cost.
|
|
3224
3277
|
|
|
3225
|
-
###
|
|
3226
|
-
- @brief
|
|
3227
|
-
- @details
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
- @
|
|
3231
|
-
- @details Stores canonical identity, line metrics, structured imports, structured symbols, structured comment evidence, and optional file-level Doxygen metadata. Derivable identity and filesystem-probe fields are intentionally omitted to reduce token cost. The interface is compile-time only and introduces no runtime cost.
|
|
3232
|
-
|
|
3233
|
-
### iface `export interface ReferenceToolRequestSection` (L121-130)
|
|
3234
|
-
- @brief Describes the request section of the references payload.
|
|
3235
|
-
- @details Captures tool identity, scope, base directory, requested path inventory, and configured source-directory scope so agents can reason about how the file set was selected. The interface is compile-time only and introduces no runtime cost.
|
|
3236
|
-
|
|
3237
|
-
### iface `export interface ReferenceToolSummarySection` (L136-147)
|
|
3238
|
-
- @brief Describes the summary section of the references payload.
|
|
3239
|
-
- @details Exposes aggregate file, symbol, import, comment, and Doxygen counts as numeric fields plus deterministic symbol-kind totals. The interface is compile-time only and introduces no runtime cost.
|
|
3240
|
-
|
|
3241
|
-
### iface `export interface ReferenceRepositoryTreeNode` (L153-159)
|
|
3242
|
-
- @brief Describes one repository tree node in the references payload.
|
|
3243
|
-
- @details Encodes directory and file hierarchy without ASCII-art decoration so agents can traverse repository structure as structured JSON. The interface is compile-time only and introduces no runtime cost.
|
|
3278
|
+
### fn `function runCapture(command: string[], cwd: string): ReturnType<typeof spawnSync>` (L44-49)
|
|
3279
|
+
- @brief Executes one synchronous subprocess and captures UTF-8 output.
|
|
3280
|
+
- @details Delegates to `spawnSync(...)`, preserves the supplied working directory, and returns the raw result so callers can interpret git exit status plus diagnostics deterministically. Runtime is dominated by external process execution. Side effects include subprocess creation.
|
|
3281
|
+
- @param[in] command {string[]} Executable plus argument vector.
|
|
3282
|
+
- @param[in] cwd {string} Working directory for the subprocess.
|
|
3283
|
+
- @return {ReturnType<typeof spawnSync>} Captured subprocess result.
|
|
3244
3284
|
|
|
3245
|
-
###
|
|
3246
|
-
- @brief
|
|
3247
|
-
- @details
|
|
3285
|
+
### fn `function buildIgnoredGitStatusPaths(` (L59-73)
|
|
3286
|
+
- @brief Builds the set of git-status paths ignored for cleanliness checks.
|
|
3287
|
+
- @details Reuses the configured debug-log path exception already honored by prompt-command git validation so extension-owned debug artifacts do not block `req-references` execution or post-commit cleanliness verification. Runtime is O(p) in path length. No external state is mutated.
|
|
3288
|
+
- @param[in] projectBase {string} Absolute project base path.
|
|
3289
|
+
- @param[in] gitRoot {string} Absolute git root path.
|
|
3290
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3291
|
+
- @return {Set<string>} Slash-normalized relative paths ignored during git-status evaluation.
|
|
3248
3292
|
|
|
3249
|
-
###
|
|
3250
|
-
- @brief
|
|
3251
|
-
- @details
|
|
3293
|
+
### fn `function listResidualGitStatusLines(` (L84-102)
|
|
3294
|
+
- @brief Lists residual git-status rows after ignored extension-owned paths are filtered out.
|
|
3295
|
+
- @details Executes `git status --porcelain`, drops the configured debug-log path when present inside the active repository, and returns all remaining staged or unstaged rows used for post-commit cleanliness verification. Runtime is dominated by one git subprocess plus O(n) parsing in status-line count. Side effects include subprocess creation.
|
|
3296
|
+
- @param[in] projectBase {string} Absolute project base path.
|
|
3297
|
+
- @param[in] gitRoot {string} Absolute git root path.
|
|
3298
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3299
|
+
- @return {string[]} Residual status rows after ignored paths are removed.
|
|
3300
|
+
- @throws {ReqError} Throws when git status cannot be inspected.
|
|
3301
|
+
|
|
3302
|
+
### fn `function getGitAddTargetPath(gitRoot: string, absolutePath: string): string` (L111-117)
|
|
3303
|
+
- @brief Converts one absolute repository path into the preferred git-add target syntax.
|
|
3304
|
+
- @details Emits a slash-normalized relative path when the target is inside the git root and falls back to the absolute path otherwise, preserving deterministic add semantics across nested project-base layouts. Runtime is O(p) in path length. No external state is mutated.
|
|
3305
|
+
- @param[in] gitRoot {string} Absolute git root path.
|
|
3306
|
+
- @param[in] absolutePath {string} Absolute path to stage.
|
|
3307
|
+
- @return {string} Relative or absolute git-add target path.
|
|
3308
|
+
|
|
3309
|
+
### fn `export function prepareReqReferencesCommandExecution(` (L128-141)
|
|
3310
|
+
- @brief Prepares the specialized `req-references` execution plan.
|
|
3311
|
+
- @details Reuses slash-command-owned git validation, resolves the configured references document path, and returns the fixed commit metadata consumed by the direct-write workflow. Runtime is dominated by git validation subprocesses. Side effects include subprocess creation delegated through `validatePromptGitState(...)`.
|
|
3312
|
+
- @param[in] projectBase {string} Absolute project base path.
|
|
3313
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3314
|
+
- @return {ReqReferencesCommandPlan} Prepared execution plan for direct references regeneration.
|
|
3315
|
+
- @throws {ReqError} Throws when git validation fails.
|
|
3316
|
+
- @satisfies REQ-200, REQ-299
|
|
3317
|
+
|
|
3318
|
+
### fn `export function executeReqReferencesCommandExecution(` (L152-175)
|
|
3319
|
+
- @brief Executes the specialized `req-references` direct-write workflow.
|
|
3320
|
+
- @details Regenerates `REFERENCES.md` through the same source-summary path used by the `references` tool, stages only the target file, creates the fixed-message commit, and verifies that no residual git-status rows remain after ignored extension-owned debug artifacts are filtered out. Runtime is dominated by summary generation plus three git subprocesses. Side effects include documentation writes, index mutation, commit creation, and subprocess creation.
|
|
3321
|
+
- @param[in] plan {ReqReferencesCommandPlan} Prepared direct-write execution plan.
|
|
3322
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3323
|
+
- @return {void} No return value.
|
|
3324
|
+
- @throws {ReqError} Throws when reference generation, staging, commit creation, or cleanliness verification fails.
|
|
3325
|
+
- @satisfies REQ-300, REQ-301, REQ-302, REQ-303
|
|
3252
3326
|
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3327
|
+
## Symbol Index
|
|
3328
|
+
|Symbol|Kind|Vis|Lines|Sig|
|
|
3329
|
+
|---|---|---|---|---|
|
|
3330
|
+
|`ReqReferencesCommandPlan`|iface||30-35|export interface ReqReferencesCommandPlan|
|
|
3331
|
+
|`runCapture`|fn||44-49|function runCapture(command: string[], cwd: string): Retu...|
|
|
3332
|
+
|`buildIgnoredGitStatusPaths`|fn||59-73|function buildIgnoredGitStatusPaths(|
|
|
3333
|
+
|`listResidualGitStatusLines`|fn||84-102|function listResidualGitStatusLines(|
|
|
3334
|
+
|`getGitAddTargetPath`|fn||111-117|function getGitAddTargetPath(gitRoot: string, absolutePat...|
|
|
3335
|
+
|`prepareReqReferencesCommandExecution`|fn||128-141|export function prepareReqReferencesCommandExecution(|
|
|
3336
|
+
|`executeReqReferencesCommandExecution`|fn||152-175|export function executeReqReferencesCommandExecution(|
|
|
3256
3337
|
|
|
3257
|
-
### fn `function canonicalizeReferencePath(targetPath: string, baseDir: string): string` (L201-209)
|
|
3258
|
-
- @brief Canonicalizes one filesystem path relative to the payload base directory.
|
|
3259
|
-
- @details Emits a slash-normalized relative path when the target is under the base directory; otherwise emits the normalized absolute path. Runtime is O(p) in path length. No side effects occur.
|
|
3260
|
-
- @param[in] targetPath {string} Absolute or relative filesystem path.
|
|
3261
|
-
- @param[in] baseDir {string} Base directory used for relative canonicalization.
|
|
3262
|
-
- @return {string} Canonicalized path string.
|
|
3263
3338
|
|
|
3264
|
-
|
|
3265
|
-
- @brief Builds one structured line-range record.
|
|
3266
|
-
- @details Duplicates the inclusive range as start, end, and tuple fields so callers can address whichever shape is most convenient. Runtime is O(1). No side effects occur.
|
|
3267
|
-
- @param[in] startLineNumber {number} Inclusive start line number.
|
|
3268
|
-
- @param[in] endLineNumber {number} Inclusive end line number.
|
|
3269
|
-
- @return {ReferenceLineRange} Structured line-range record.
|
|
3339
|
+
---
|
|
3270
3340
|
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
- @
|
|
3274
|
-
- @
|
|
3275
|
-
- @param[in] maxLength {number} Optional maximum output length; `0` disables truncation.
|
|
3276
|
-
- @return {string} Cleaned comment text.
|
|
3341
|
+
# req-reset-command.ts | TypeScript | 323L | 12 symbols | 7 imports | 14 comments
|
|
3342
|
+
> Path: `src/core/req-reset-command.ts`
|
|
3343
|
+
- @brief Implements the specialized `req-reset` slash-command workflow.
|
|
3344
|
+
- @details Performs non-agentic prompt-orchestration recovery by preserving the current execution-session transcript when available, restoring the original session-backed `base-path`, force-removing every generated sibling worktree and matching branch, and returning deterministic cleanup facts to the extension command handler. Runtime is dominated by session switching plus git subprocess execution. Side effects include session-file reads and writes, active-session replacement, host-process cwd mutation, worktree deletion, branch deletion, and filesystem removal.
|
|
3277
3345
|
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3346
|
+
## Imports
|
|
3347
|
+
```
|
|
3348
|
+
import fs from "node:fs";
|
|
3349
|
+
import path from "node:path";
|
|
3350
|
+
import { spawnSync } from "node:child_process";
|
|
3351
|
+
import {
|
|
3352
|
+
import { ReqError } from "./errors.js";
|
|
3353
|
+
import {
|
|
3354
|
+
import { resolveRuntimeGitPath } from "./runtime-project-paths.js";
|
|
3355
|
+
```
|
|
3283
3356
|
|
|
3284
|
-
|
|
3285
|
-
- @brief Associates nearby comment blocks with definitions and standalone comment groups.
|
|
3286
|
-
- @details Reuses the repository comment-attachment heuristic that binds comments within three lines of a definition while preserving early file-description text. Runtime is O(n log n). No side effects occur.
|
|
3287
|
-
- @param[in] elements {SourceElement[]} Analyzed source elements.
|
|
3288
|
-
- @return {[Record<number, SourceElement[]>, SourceElement[], string]} Attached-comment map, standalone comments, and compact file description.
|
|
3357
|
+
## Definitions
|
|
3289
3358
|
|
|
3290
|
-
###
|
|
3291
|
-
- @brief
|
|
3292
|
-
- @details
|
|
3293
|
-
- @param[in] element {SourceElement} Source element.
|
|
3294
|
-
- @return {string} Stable symbol name.
|
|
3359
|
+
### iface `export interface ReqResetCommandPlan` (L34-40)
|
|
3360
|
+
- @brief Describes the prepared execution facts for one `req-reset` run.
|
|
3361
|
+
- @details Stores the validated project base, resolved git root, sibling-worktree parent directory, generated-name matcher, and optional persisted prompt execution plan used for transcript preservation plus base-path restoration. The interface is compile-time only and introduces no runtime cost.
|
|
3295
3362
|
|
|
3296
|
-
###
|
|
3297
|
-
- @brief
|
|
3298
|
-
- @details
|
|
3299
|
-
- @param[in] definitions {SourceElement[]} Sorted definition elements.
|
|
3300
|
-
- @param[in] child {SourceElement} Candidate child symbol.
|
|
3301
|
-
- @return {SourceElement | undefined} Matched parent definition when available.
|
|
3363
|
+
### iface `export interface ReqResetCommandExecutionResult` (L46-53)
|
|
3364
|
+
- @brief Describes the outcome of one `req-reset` execution attempt.
|
|
3365
|
+
- @details Captures the last valid session-bound context, transcript-preservation and base-path-restoration facts, removed generated worktree and branch names, and one aggregated failure string when any recovery step fails. The interface is compile-time only and introduces no runtime cost.
|
|
3302
3366
|
|
|
3303
|
-
|
|
3304
|
-
- @brief
|
|
3305
|
-
- @details
|
|
3306
|
-
|
|
3307
|
-
- @
|
|
3367
|
+
- type `type ReqResetCommandContext = Parameters<typeof restorePromptCommandExecution>[1];` (L59)
|
|
3368
|
+
- @brief Describes the session-bound context surface reused during `req-reset` recovery.
|
|
3369
|
+
- @details Reuses the session-switching contract already accepted by `restorePromptCommandExecution(...)` so the dedicated reset command can restore the original session without depending on concrete pi runtime classes. The alias is compile-time only and introduces no runtime cost.
|
|
3370
|
+
### fn `function runCapture(command: string[], cwd: string): ReturnType<typeof spawnSync>` (L68-73)
|
|
3371
|
+
- @brief Executes one synchronous subprocess and captures UTF-8 output.
|
|
3372
|
+
- @details Delegates to `spawnSync(...)`, preserves the supplied working directory, and returns the raw result so callers can interpret git exit status plus diagnostics deterministically. Runtime is dominated by external process execution. Side effects include subprocess creation.
|
|
3373
|
+
- @param[in] command {string[]} Executable plus argument vector.
|
|
3374
|
+
- @param[in] cwd {string} Working directory for the subprocess.
|
|
3375
|
+
- @return {ReturnType<typeof spawnSync>} Captured subprocess result.
|
|
3308
3376
|
|
|
3309
|
-
### fn `function
|
|
3310
|
-
- @brief
|
|
3311
|
-
- @details
|
|
3312
|
-
- @param[in]
|
|
3313
|
-
- @return {
|
|
3377
|
+
### fn `function escapeReqResetRegExpLiteral(text: string): string` (L81-83)
|
|
3378
|
+
- @brief Escapes one literal string for safe JavaScript regular-expression reuse.
|
|
3379
|
+
- @details Prefixes every regular-expression metacharacter with `\\` so generated worktree-name patterns can embed persisted prefixes and repository basenames without introducing unintended matcher semantics. Runtime is O(n) in string length. No external state is mutated.
|
|
3380
|
+
- @param[in] text {string} Literal text fragment.
|
|
3381
|
+
- @return {string} Regular-expression-safe literal fragment.
|
|
3314
3382
|
|
|
3315
|
-
### fn `
|
|
3383
|
+
### fn `function buildReqResetWorktreeNamePattern(gitRoot: string, config: UseReqConfig): RegExp` (L93-100)
|
|
3384
|
+
- @brief Builds the generated-worktree name matcher used by `req-reset` cleanup.
|
|
3385
|
+
- @details Reuses the configured worktree prefix plus repository basename, accepts any sanitized branch token between those fixed segments and the final execution identifier, and constrains the timestamp suffix to the documented `YYYYMMDDHHMMSS` shape. Runtime is O(p) in combined prefix and project-name length. No external state is mutated.
|
|
3386
|
+
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
3387
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3388
|
+
- @return {RegExp} Matcher for generated prompt-command worktree and branch names.
|
|
3389
|
+
- @satisfies REQ-309, REQ-310, REQ-311
|
|
3316
3390
|
|
|
3317
|
-
### fn `
|
|
3391
|
+
### fn `function listReqResetRegisteredWorktreeRoots(gitRoot: string): string[]` (L109-118)
|
|
3392
|
+
- @brief Lists every registered git worktree root for one repository.
|
|
3393
|
+
- @details Executes `git worktree list --porcelain`, extracts each `worktree <path>` record, resolves every listed path to an absolute form, and returns the ordered list used by generated-worktree cleanup. Runtime is dominated by one git subprocess plus O(n) parsing in listed worktree count. Side effects include subprocess creation.
|
|
3394
|
+
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
3395
|
+
- @return {string[]} Absolute registered worktree-root paths.
|
|
3396
|
+
- @throws {ReqError} Throws when git worktree enumeration fails.
|
|
3397
|
+
|
|
3398
|
+
### fn `function listReqResetSiblingWorktreeRoots(` (L128-146)
|
|
3399
|
+
- @brief Lists sibling directories whose names match the generated-worktree contract.
|
|
3400
|
+
- @details Reads the repository parent directory, keeps only direct child directories whose basenames match the supplied generated-name pattern, and resolves each candidate to an absolute path so `req-reset` can remove unregistered leftover directories as well as registered git worktrees. Runtime is dominated by directory enumeration plus O(n) matcher cost. Side effects are limited to filesystem reads.
|
|
3401
|
+
- @param[in] parentPath {string} Absolute directory containing sibling worktree roots.
|
|
3402
|
+
- @param[in] worktreeNamePattern {RegExp} Generated-worktree name matcher.
|
|
3403
|
+
- @return {string[]} Absolute sibling directory paths whose basenames match the generated-name contract.
|
|
3404
|
+
- @throws {ReqError} Throws when directory enumeration fails.
|
|
3405
|
+
|
|
3406
|
+
### fn `function listReqResetMatchingWorktreeRoots(` (L157-172)
|
|
3407
|
+
- @brief Lists every generated sibling worktree candidate targeted by `req-reset`.
|
|
3408
|
+
- @details Unions registered git-worktree roots with matching sibling directories so cleanup covers both registered worktrees and unregistered leftover directories, then sorts the canonical absolute paths for deterministic deletion order. Runtime is dominated by git worktree enumeration plus sibling-directory scanning. Side effects are limited to subprocess creation and filesystem reads.
|
|
3409
|
+
- @param[in] parentPath {string} Absolute directory containing sibling worktree roots.
|
|
3410
|
+
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
3411
|
+
- @param[in] worktreeNamePattern {RegExp} Generated-worktree name matcher.
|
|
3412
|
+
- @return {string[]} Sorted absolute worktree-root paths targeted for deletion.
|
|
3413
|
+
- @throws {ReqError} Throws when git worktree or sibling-directory enumeration fails.
|
|
3318
3414
|
|
|
3319
|
-
### fn `function
|
|
3320
|
-
- @brief
|
|
3321
|
-
- @details
|
|
3322
|
-
- @param[in]
|
|
3323
|
-
- @param[in]
|
|
3324
|
-
- @
|
|
3325
|
-
- @
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
- @
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
- @
|
|
3332
|
-
- @
|
|
3333
|
-
- @
|
|
3334
|
-
- @
|
|
3335
|
-
- @satisfies REQ-
|
|
3336
|
-
|
|
3337
|
-
### fn `export function
|
|
3338
|
-
- @brief
|
|
3339
|
-
- @details
|
|
3340
|
-
- @param[in]
|
|
3341
|
-
- @
|
|
3415
|
+
### fn `function listReqResetMatchingBranchNames(` (L182-195)
|
|
3416
|
+
- @brief Lists every matching generated branch targeted by `req-reset`.
|
|
3417
|
+
- @details Executes `git branch --list --format=%(refname:short)`, filters the local branch inventory through the generated-name matcher, and returns a sorted list so later forced branch deletion remains deterministic. Runtime is dominated by one git subprocess plus O(n) parsing in listed branch count. Side effects include subprocess creation.
|
|
3418
|
+
- @param[in] gitRoot {string} Absolute runtime git root.
|
|
3419
|
+
- @param[in] worktreeNamePattern {RegExp} Generated-worktree name matcher.
|
|
3420
|
+
- @return {string[]} Sorted local branch names targeted for deletion.
|
|
3421
|
+
- @throws {ReqError} Throws when local branch enumeration fails.
|
|
3422
|
+
|
|
3423
|
+
### fn `export function prepareReqResetCommandExecution(` (L207-230)
|
|
3424
|
+
- @brief Prepares the specialized `req-reset` execution plan.
|
|
3425
|
+
- @details Resolves the active project base into a runtime git root, derives the sibling-worktree parent directory and generated-name matcher from the same prefix plus repository-basename contract used by prompt-command worktree generation, and keeps only worktree-backed persisted prompt execution plans for transcript-preserving base-path restoration. Runtime is O(p) in path length. No external state is mutated.
|
|
3426
|
+
- @param[in] projectBase {string} Absolute project base path.
|
|
3427
|
+
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
3428
|
+
- @param[in] promptRequest {PromptCommandExecutionPlan | undefined} Pending or active prompt execution plan when available.
|
|
3429
|
+
- @return {ReqResetCommandPlan} Prepared recovery and cleanup plan.
|
|
3430
|
+
- @throws {ReqError} Throws when the repository root cannot be resolved.
|
|
3431
|
+
- @satisfies REQ-306, REQ-309, REQ-310, REQ-311
|
|
3432
|
+
|
|
3433
|
+
### fn `export async function executeReqResetCommandExecution(` (L240-323)
|
|
3434
|
+
- @brief Executes the specialized `req-reset` recovery and cleanup workflow.
|
|
3435
|
+
- @details Preserves the execution-session transcript into the original session file when a worktree-backed prompt execution plan is still available, restores the original session-backed `base-path` through the shared prompt-command restoration helper, force-removes every matching sibling worktree directory, force-removes every remaining matching local branch, and aggregates any failure diagnostics without rolling back successful cleanup steps. Runtime is dominated by session switching plus git subprocess execution. Side effects include session-file reads and writes, active-session replacement, host-process cwd mutation, worktree deletion, branch deletion, and filesystem reads.
|
|
3436
|
+
- @param[in] plan {ReqResetCommandPlan} Prepared recovery and cleanup plan.
|
|
3437
|
+
- @param[in] ctx {ReqResetCommandContext | undefined} Optional session-bound command context.
|
|
3438
|
+
- @return {Promise<ReqResetCommandExecutionResult>} Recovery and cleanup outcome facts.
|
|
3439
|
+
- @satisfies REQ-305, REQ-307, REQ-308, REQ-309, REQ-310, REQ-313
|
|
3342
3440
|
|
|
3343
3441
|
## Symbol Index
|
|
3344
3442
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
3345
3443
|
|---|---|---|---|---|
|
|
3346
|
-
|`
|
|
3347
|
-
|`
|
|
3348
|
-
|`
|
|
3349
|
-
|`
|
|
3350
|
-
|`
|
|
3351
|
-
|`
|
|
3352
|
-
|`
|
|
3353
|
-
|`
|
|
3354
|
-
|`
|
|
3355
|
-
|`
|
|
3356
|
-
|`
|
|
3357
|
-
|`
|
|
3358
|
-
|`ReferenceToolPayload`|iface||175-179|export interface ReferenceToolPayload|
|
|
3359
|
-
|`BuildReferenceToolPayloadOptions`|iface||185-192|export interface BuildReferenceToolPayloadOptions|
|
|
3360
|
-
|`canonicalizeReferencePath`|fn||201-209|function canonicalizeReferencePath(targetPath: string, ba...|
|
|
3361
|
-
|`buildLineRange`|fn||218-224|function buildLineRange(startLineNumber: number, endLineN...|
|
|
3362
|
-
|`extractCommentText`|fn||233-253|function extractCommentText(commentElement: SourceElement...|
|
|
3363
|
-
|`extractCommentLines`|fn||261-275|function extractCommentLines(commentElement: SourceElemen...|
|
|
3364
|
-
|`buildCommentMaps`|fn||283-333|function buildCommentMaps(elements: SourceElement[]): [Re...|
|
|
3365
|
-
|`resolveSymbolName`|fn||341-343|function resolveSymbolName(element: SourceElement): string|
|
|
3366
|
-
|`resolveParentElement`|fn||352-361|function resolveParentElement(definitions: SourceElement[...|
|
|
3367
|
-
|`buildCommentEntry`|fn||369-376|function buildCommentEntry(commentElement: SourceElement)...|
|
|
3368
|
-
|`buildRepositoryTree`|fn||384-443|function buildRepositoryTree(canonicalPaths: string[]): R...|
|
|
3369
|
-
|`ensureDirectory`|fn||393-407|const ensureDirectory = (parent: ReferenceRepositoryTreeN...|
|
|
3370
|
-
|`finalizeNode`|fn||429-440|const finalizeNode = (node: ReferenceRepositoryTreeNode):...|
|
|
3371
|
-
|`analyzeReferenceFile`|fn||456-621|function analyzeReferenceFile(|
|
|
3372
|
-
|`buildReferenceToolPayload`|fn||630-730|export function buildReferenceToolPayload(options: BuildR...|
|
|
3373
|
-
|`buildReferenceToolExecutionStderr`|fn||738-752|export function buildReferenceToolExecutionStderr(payload...|
|
|
3444
|
+
|`ReqResetCommandPlan`|iface||34-40|export interface ReqResetCommandPlan|
|
|
3445
|
+
|`ReqResetCommandExecutionResult`|iface||46-53|export interface ReqResetCommandExecutionResult|
|
|
3446
|
+
|`ReqResetCommandContext`|type||59||
|
|
3447
|
+
|`runCapture`|fn||68-73|function runCapture(command: string[], cwd: string): Retu...|
|
|
3448
|
+
|`escapeReqResetRegExpLiteral`|fn||81-83|function escapeReqResetRegExpLiteral(text: string): string|
|
|
3449
|
+
|`buildReqResetWorktreeNamePattern`|fn||93-100|function buildReqResetWorktreeNamePattern(gitRoot: string...|
|
|
3450
|
+
|`listReqResetRegisteredWorktreeRoots`|fn||109-118|function listReqResetRegisteredWorktreeRoots(gitRoot: str...|
|
|
3451
|
+
|`listReqResetSiblingWorktreeRoots`|fn||128-146|function listReqResetSiblingWorktreeRoots(|
|
|
3452
|
+
|`listReqResetMatchingWorktreeRoots`|fn||157-172|function listReqResetMatchingWorktreeRoots(|
|
|
3453
|
+
|`listReqResetMatchingBranchNames`|fn||182-195|function listReqResetMatchingBranchNames(|
|
|
3454
|
+
|`prepareReqResetCommandExecution`|fn||207-230|export function prepareReqResetCommandExecution(|
|
|
3455
|
+
|`executeReqResetCommandExecution`|fn||240-323|export async function executeReqResetCommandExecution(|
|
|
3374
3456
|
|
|
3375
3457
|
|
|
3376
3458
|
---
|
|
3377
3459
|
|
|
3378
|
-
# resources.ts | TypeScript |
|
|
3460
|
+
# resources.ts | TypeScript | 102L | 7 symbols | 3 imports | 8 comments
|
|
3379
3461
|
> Path: `src/core/resources.ts`
|
|
3380
3462
|
- @brief Resolves installation-owned bundled resource locations.
|
|
3381
3463
|
- @details Encapsulates installation-path discovery, bundled-resource validation, prompt enumeration, prompt loading, and bundled instruction loading directly from the installed extension payload. Runtime is proportional to directory-entry enumeration and resource file size. Side effects are limited to filesystem reads.
|
|
@@ -3415,20 +3497,20 @@ import { getInstallationPath, RESOURCE_ROOT_DIRNAME } from "./path-context.js";
|
|
|
3415
3497
|
- @return {string} Raw prompt markdown content.
|
|
3416
3498
|
- @throws {Error} Propagates `fs.readFileSync` errors when the prompt file is missing or unreadable.
|
|
3417
3499
|
|
|
3418
|
-
### fn `export function readBundledPromptDescription(promptName: string): string` (L73-
|
|
3419
|
-
- @brief Extracts the
|
|
3420
|
-
- @details
|
|
3500
|
+
### fn `export function readBundledPromptDescription(promptName: string): string` (L73-78)
|
|
3501
|
+
- @brief Extracts the first Markdown level-one heading from one bundled prompt.
|
|
3502
|
+
- @details Removes one optional leading YAML front-matter block, scans the remaining markdown body for the first line that begins with `# `, and returns the heading payload without the marker or surrounding whitespace. Runtime is O(n) in prompt length. Side effects are limited to filesystem reads delegated through `readBundledPrompt(...)`.
|
|
3421
3503
|
- @param[in] promptName {string} Prompt identifier without the `.md` suffix.
|
|
3422
|
-
- @return {string}
|
|
3504
|
+
- @return {string} First `# ` heading payload, or the empty string when no level-one heading exists.
|
|
3423
3505
|
|
|
3424
|
-
### fn `export function readBundledInstruction(instructionName: string): string` (
|
|
3506
|
+
### fn `export function readBundledInstruction(instructionName: string): string` (L87-89)
|
|
3425
3507
|
- @brief Reads one bundled markdown instruction by logical instruction name.
|
|
3426
3508
|
- @details Resolves the instruction file under the installation-owned `resources/instructions` directory, validates resource accessibility, and loads it as UTF-8 text. Time complexity is O(n) in file size. Side effects are limited to filesystem reads.
|
|
3427
3509
|
- @param[in] instructionName {string} Instruction identifier without the `.md` suffix.
|
|
3428
3510
|
- @return {string} Raw instruction markdown content.
|
|
3429
3511
|
- @throws {Error} Propagates `fs.readFileSync` errors when the instruction file is missing or unreadable.
|
|
3430
3512
|
|
|
3431
|
-
### fn `export function listBundledPromptNames(): string[]` (
|
|
3513
|
+
### fn `export function listBundledPromptNames(): string[]` (L96-102)
|
|
3432
3514
|
- @brief Lists bundled prompt identifiers available in the installed extension payload.
|
|
3433
3515
|
- @details Scans the installation-owned prompt directory, keeps visible markdown files only, strips the `.md` suffix, and returns a lexicographically sorted list. Time complexity is O(n log n). Side effects are limited to filesystem reads.
|
|
3434
3516
|
- @return {string[]} Sorted prompt names without file extensions.
|
|
@@ -3440,17 +3522,17 @@ import { getInstallationPath, RESOURCE_ROOT_DIRNAME } from "./path-context.js";
|
|
|
3440
3522
|
|`ensureBundledResourcesAccessible`|fn||26-38|export function ensureBundledResourcesAccessible(): string|
|
|
3441
3523
|
|`readBundledMarkdownResource`|fn||48-54|function readBundledMarkdownResource(|
|
|
3442
3524
|
|`readBundledPrompt`|fn||63-65|export function readBundledPrompt(promptName: string): st...|
|
|
3443
|
-
|`readBundledPromptDescription`|fn||73-
|
|
3444
|
-
|`readBundledInstruction`|fn||
|
|
3445
|
-
|`listBundledPromptNames`|fn||
|
|
3525
|
+
|`readBundledPromptDescription`|fn||73-78|export function readBundledPromptDescription(promptName: ...|
|
|
3526
|
+
|`readBundledInstruction`|fn||87-89|export function readBundledInstruction(instructionName: s...|
|
|
3527
|
+
|`listBundledPromptNames`|fn||96-102|export function listBundledPromptNames(): string[]|
|
|
3446
3528
|
|
|
3447
3529
|
|
|
3448
3530
|
---
|
|
3449
3531
|
|
|
3450
|
-
# runtime-project-paths.ts | TypeScript |
|
|
3532
|
+
# runtime-project-paths.ts | TypeScript | 90L | 5 symbols | 4 imports | 6 comments
|
|
3451
3533
|
> Path: `src/core/runtime-project-paths.ts`
|
|
3452
3534
|
- @brief Derives runtime-only repository facts.
|
|
3453
|
-
- @details Centralizes git-repository probing
|
|
3535
|
+
- @details Centralizes git-repository probing, repository-root resolution, and active-branch lookup for extension status, tool execution, and CLI flows. Runtime is dominated by git subprocess execution plus path normalization. Side effects are limited to subprocess spawning.
|
|
3454
3536
|
|
|
3455
3537
|
## Imports
|
|
3456
3538
|
```
|
|
@@ -3491,6 +3573,13 @@ import { isSameOrAncestorPath } from "./path-context.js";
|
|
|
3491
3573
|
- @return {string | undefined} Absolute repository-root path or `undefined` when unavailable.
|
|
3492
3574
|
- @satisfies REQ-105, REQ-145
|
|
3493
3575
|
|
|
3576
|
+
### fn `export function resolveRuntimeGitBranchName(executionPath: string): string` (L77-88)
|
|
3577
|
+
- @brief Resolves the active branch name for one runtime execution path.
|
|
3578
|
+
- @details Resolves the enclosing git work tree from the supplied execution path, reads `git branch --show-current`, and falls back to `unknown` when the path is outside git or HEAD has no branch name. Runtime is dominated by git execution. Side effects include subprocess creation.
|
|
3579
|
+
- @param[in] executionPath {string} Runtime execution path.
|
|
3580
|
+
- @return {string} Active branch name or `unknown` when unavailable.
|
|
3581
|
+
- @satisfies REQ-121, REQ-283
|
|
3582
|
+
|
|
3494
3583
|
## Symbol Index
|
|
3495
3584
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
3496
3585
|
|---|---|---|---|---|
|
|
@@ -3498,11 +3587,12 @@ import { isSameOrAncestorPath } from "./path-context.js";
|
|
|
3498
3587
|
|`isInsideGitRepo`|fn||33-36|export function isInsideGitRepo(targetPath: string): boolean|
|
|
3499
3588
|
|`resolveGitRoot`|fn||46-52|export function resolveGitRoot(targetPath: string): string|
|
|
3500
3589
|
|`resolveRuntimeGitPath`|fn||61-68|export function resolveRuntimeGitPath(executionPath: stri...|
|
|
3590
|
+
|`resolveRuntimeGitBranchName`|fn||77-88|export function resolveRuntimeGitBranchName(executionPath...|
|
|
3501
3591
|
|
|
3502
3592
|
|
|
3503
3593
|
---
|
|
3504
3594
|
|
|
3505
|
-
# settings-menu.ts | TypeScript |
|
|
3595
|
+
# settings-menu.ts | TypeScript | 321L | 15 symbols | 2 imports | 15 comments
|
|
3506
3596
|
> Path: `src/core/settings-menu.ts`
|
|
3507
3597
|
- @brief Renders pi-usereq configuration menus with the shared pi.dev settings style.
|
|
3508
3598
|
- @details Wraps `SettingsList` in one extension-command helper that exposes right-aligned current values, built-in circular scrolling, bottom-line descriptions, and a deterministic bridge for offline test harnesses. Runtime is O(n) in visible choice count plus user interaction cost. Side effects are limited to transient custom-UI rendering.
|
|
@@ -3515,37 +3605,35 @@ import { Container, SettingsList, Text, type Component, type SettingItem, type S
|
|
|
3515
3605
|
|
|
3516
3606
|
## Definitions
|
|
3517
3607
|
|
|
3518
|
-
### iface `export interface PiUsereqSettingsMenuChoice` (L14-
|
|
3608
|
+
### iface `export interface PiUsereqSettingsMenuChoice` (L14-23)
|
|
3519
3609
|
- @brief Describes one selectable pi-usereq settings-menu choice.
|
|
3520
|
-
- @details Stores the stable action identifier, left-column label, optional label and value tone overrides, optional disabled state, right-column current value, and bottom-line description consumed by the shared settings-menu renderer. The interface is compile-time only and introduces no runtime cost.
|
|
3610
|
+
- @details Stores the stable action identifier, left-column label, optional label and value tone overrides, optional disabled state, right-column current value, optional inline-cycle values, and bottom-line description consumed by the shared settings-menu renderer. The interface is compile-time only and introduces no runtime cost.
|
|
3521
3611
|
|
|
3522
|
-
### iface `export interface PiUsereqSettingsMenuBridge` (
|
|
3612
|
+
### iface `export interface PiUsereqSettingsMenuBridge` (L29-35)
|
|
3523
3613
|
- @brief Describes the offline bridge exposed by shared settings-menu components.
|
|
3524
3614
|
- @details Lets deterministic harnesses and unit tests drive the same settings-menu choices by label without simulating raw terminal key streams. The interface is runtime-facing but carries no side effects by itself.
|
|
3525
3615
|
|
|
3526
|
-
### iface `export interface PiUsereqSettingsMenuOptions` (
|
|
3616
|
+
### iface `export interface PiUsereqSettingsMenuOptions` (L41-45)
|
|
3527
3617
|
- @brief Describes optional behavior overrides for one settings-menu render.
|
|
3528
|
-
- @details Carries the caller-selected initial focus row
|
|
3529
|
-
preserve selection after an in-place toggle or value edit. The interface is
|
|
3530
|
-
compile-time only and introduces no runtime cost.
|
|
3618
|
+
- @details Carries the caller-selected initial focus row, the optional dynamic choice supplier used to rebuild dependent rows after inline toggles, and the optional inline-change callback used to persist `SettingsList` value cycles without closing the menu. The interface is compile-time only and introduces no runtime cost.
|
|
3531
3619
|
|
|
3532
|
-
### iface `export interface PiUsereqSettingsMenuComponent extends Component` : Component (
|
|
3620
|
+
### iface `export interface PiUsereqSettingsMenuComponent extends Component` : Component (L51-53)
|
|
3533
3621
|
- @brief Represents a custom menu component augmented with the offline bridge.
|
|
3534
3622
|
- @details Extends the generic TUI `Component` contract with one optional bridge field consumed only by deterministic test and debug harness adapters. The interface is compile-time only and introduces no runtime cost.
|
|
3535
3623
|
|
|
3536
|
-
- type `type PiUsereqSettingsThemeColor = Extract<ThemeColor, "accent" | "muted" | "dim">;` (
|
|
3624
|
+
- type `type PiUsereqSettingsThemeColor = Extract<ThemeColor, "accent" | "muted" | "dim">;` (L61)
|
|
3537
3625
|
- @brief Enumerates the CLI-supported theme tokens consumed by settings menus.
|
|
3538
3626
|
- @details Narrows callback-local theme calls to the documented settings-list
|
|
3539
3627
|
semantics used by the pi CLI. Compile-time only and introduces no runtime
|
|
3540
3628
|
cost.
|
|
3541
|
-
### iface `interface PiUsereqSettingsTheme` (
|
|
3629
|
+
### iface `interface PiUsereqSettingsTheme` (L70-73)
|
|
3542
3630
|
- @brief Describes the callback-local theme surface required by settings menus.
|
|
3543
3631
|
- @details Captures the subset of the custom-UI theme API needed to rebuild
|
|
3544
3632
|
title and fallback settings-list styling when the shared global theme is not
|
|
3545
3633
|
available in tests or offline replay. Compile-time only and introduces no
|
|
3546
3634
|
runtime cost.
|
|
3547
3635
|
|
|
3548
|
-
### fn `function buildFallbackPiUsereqSettingsListTheme(` (
|
|
3636
|
+
### fn `function buildFallbackPiUsereqSettingsListTheme(` (L85-97)
|
|
3549
3637
|
- @brief Builds the fallback settings-list theme matching CLI settings semantics.
|
|
3550
3638
|
- @details Mirrors the shared CLI settings theme token mapping for labels,
|
|
3551
3639
|
values, descriptions, cursor, and hints while avoiding the global theme
|
|
@@ -3555,7 +3643,7 @@ mutated.
|
|
|
3555
3643
|
- @return {SettingsListTheme} Fallback settings-list theme.
|
|
3556
3644
|
- @satisfies REQ-151, REQ-156
|
|
3557
3645
|
|
|
3558
|
-
### fn `function buildPiUsereqSettingsListTheme(` (
|
|
3646
|
+
### fn `function buildPiUsereqSettingsListTheme(` (L110-124)
|
|
3559
3647
|
- @brief Resolves the settings-list theme used by pi-usereq configuration menus.
|
|
3560
3648
|
- @details Prefers the shared CLI `getSettingsListTheme()` API so extension
|
|
3561
3649
|
menus inherit active-theme behavior from pi itself, then falls back to an
|
|
@@ -3566,7 +3654,7 @@ external state is mutated.
|
|
|
3566
3654
|
- @return {SettingsListTheme} Settings-list theme used by pi-usereq menus.
|
|
3567
3655
|
- @satisfies REQ-151, REQ-156
|
|
3568
3656
|
|
|
3569
|
-
### fn `function formatPiUsereqSettingsMenuTitle(` (
|
|
3657
|
+
### fn `function formatPiUsereqSettingsMenuTitle(` (L136-141)
|
|
3570
3658
|
- @brief Formats the settings-menu title with active-theme semantics.
|
|
3571
3659
|
- @details Applies the callback-local `accent` token and bold styling on every
|
|
3572
3660
|
rebuild so custom-menu titles stay synchronized with live theme changes.
|
|
@@ -3576,46 +3664,64 @@ Runtime is O(n) in title length. No external state is mutated.
|
|
|
3576
3664
|
- @return {string} Styled title text.
|
|
3577
3665
|
- @satisfies REQ-151, REQ-156
|
|
3578
3666
|
|
|
3579
|
-
### fn `function createImmediateSelectionComponent(choiceId: string, done: (value?: string) => void): Component` (
|
|
3667
|
+
### fn `function createImmediateSelectionComponent(choiceId: string, done: (value?: string) => void): Component` (L150-162)
|
|
3580
3668
|
- @brief Closes a settings menu immediately with one selected action identifier.
|
|
3581
3669
|
- @details Provides the submenu callback used by `SettingsList` so pressing Enter on any menu row resolves the outer custom UI promise with the row identifier. Runtime is O(1). Side effects are limited to one custom-UI completion callback.
|
|
3582
3670
|
- @param[in] choiceId {string} Stable choice identifier to emit.
|
|
3583
3671
|
- @param[in] done {(value?: string) => void} Outer custom-UI completion callback.
|
|
3584
3672
|
- @return {Component} Immediate-completion submenu component.
|
|
3585
3673
|
|
|
3586
|
-
### fn `function buildSettingItems(` (
|
|
3674
|
+
### fn `function buildSettingItems(` (L172-193)
|
|
3587
3675
|
- @brief Builds `SettingsList` items from one menu-choice vector.
|
|
3588
|
-
- @details Copies labels, current values, label-tone overrides, value-tone overrides, disabled-state semantics, and descriptions into `SettingItem` records
|
|
3676
|
+
- @details Copies labels, current values, label-tone overrides, value-tone overrides, disabled-state semantics, inline-cycle values, and descriptions into `SettingItem` records. Non-disabled rows with `values` cycle inline on `Enter` or `Space`, while other non-disabled rows resolve the outer custom UI through the immediate submenu bridge. Runtime is O(n) in choice count. No external state is mutated.
|
|
3589
3677
|
- @param[in] theme {PiUsereqSettingsTheme} Callback-local pi theme adapter.
|
|
3590
3678
|
- @param[in] choices {PiUsereqSettingsMenuChoice[]} Ordered menu-choice vector.
|
|
3591
3679
|
- @param[in] done {(value?: string) => void} Outer custom-UI completion callback.
|
|
3592
3680
|
- @return {SettingItem[]} `SettingsList` item vector.
|
|
3593
3681
|
|
|
3594
|
-
### fn `
|
|
3682
|
+
### fn `function setSettingsListSelectedIndex(` (L202-207)
|
|
3683
|
+
- @brief Writes one best-effort selected row index into a `SettingsList` instance.
|
|
3684
|
+
- @details Uses reflective access so pi-usereq can preserve focus across menu re-renders without depending on the private field at compile time. Runtime is O(1). Side effect: mutates the underlying `SettingsList` selection state when the field exists.
|
|
3685
|
+
- @param[in] selectedIndex {number} Zero-based row index to restore.
|
|
3686
|
+
- @param[in,out] settingsList {SettingsList} Mutable settings-list instance.
|
|
3687
|
+
- @return {void} No return value.
|
|
3688
|
+
|
|
3689
|
+
### fn `function getSettingsListSelectedIndex(` (L215-220)
|
|
3690
|
+
- @brief Reads the current selected row index from a `SettingsList` instance.
|
|
3691
|
+
- @details Uses reflective access so pi-usereq can report the current focused row through the offline bridge without referencing the private field in the static type system. Runtime is O(1). No external state is mutated.
|
|
3692
|
+
- @param[in] settingsList {SettingsList} Settings-list instance.
|
|
3693
|
+
- @return {number | undefined} Zero-based selected row index when available.
|
|
3694
|
+
|
|
3695
|
+
### fn `export async function showPiUsereqSettingsMenu(` (L232-236)
|
|
3595
3696
|
- @brief Renders one shared pi-usereq settings menu and resolves the selected action.
|
|
3596
|
-
- @details Uses `ctx.ui.custom(...)` plus `SettingsList` so every configuration menu shares pi.dev styling, right-aligned current values, circular scrolling, bottom-line descriptions,
|
|
3697
|
+
- @details Uses `ctx.ui.custom(...)` plus `SettingsList` so every configuration menu shares pi.dev styling, right-aligned current values, circular scrolling, bottom-line descriptions, optional disabled rows, and inline toggle cycles that do not close the menu. When callers provide `getChoices(...)`, dependent rows are rebuilt after inline changes while preserving focus on the changed row. The returned custom component also exposes an offline bridge for deterministic tests and debug harnesses. Runtime is O(n) in visible choice count plus user interaction cost. Side effects are limited to transient custom-UI rendering and caller-owned inline-change callbacks.
|
|
3597
3698
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
3598
3699
|
- @param[in] title {string} Menu title displayed in the heading and offline bridge.
|
|
3599
3700
|
- @param[in] choices {PiUsereqSettingsMenuChoice[]} Ordered menu-choice vector.
|
|
3600
|
-
- @param[in] options {PiUsereqSettingsMenuOptions | undefined} Optional initial-focus override.
|
|
3701
|
+
- @param[in] options {PiUsereqSettingsMenuOptions | undefined} Optional initial-focus override plus inline-change behavior.
|
|
3601
3702
|
- @return {Promise<string | undefined>} Selected choice identifier or `undefined` when cancelled.
|
|
3602
3703
|
- @satisfies REQ-151, REQ-152, REQ-153, REQ-154, REQ-156, REQ-192
|
|
3603
3704
|
|
|
3705
|
+
### fn `const rebuildMenu = (selectedChoiceId?: string): void =>` (L272-279)
|
|
3706
|
+
|
|
3604
3707
|
## Symbol Index
|
|
3605
3708
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
3606
3709
|
|---|---|---|---|---|
|
|
3607
|
-
|`PiUsereqSettingsMenuChoice`|iface||14-
|
|
3608
|
-
|`PiUsereqSettingsMenuBridge`|iface||
|
|
3609
|
-
|`PiUsereqSettingsMenuOptions`|iface||
|
|
3610
|
-
|`PiUsereqSettingsMenuComponent`|iface||
|
|
3611
|
-
|`PiUsereqSettingsThemeColor`|type||
|
|
3612
|
-
|`PiUsereqSettingsTheme`|iface||
|
|
3613
|
-
|`buildFallbackPiUsereqSettingsListTheme`|fn||
|
|
3614
|
-
|`buildPiUsereqSettingsListTheme`|fn||
|
|
3615
|
-
|`formatPiUsereqSettingsMenuTitle`|fn||
|
|
3616
|
-
|`createImmediateSelectionComponent`|fn||
|
|
3617
|
-
|`buildSettingItems`|fn||
|
|
3618
|
-
|`
|
|
3710
|
+
|`PiUsereqSettingsMenuChoice`|iface||14-23|export interface PiUsereqSettingsMenuChoice|
|
|
3711
|
+
|`PiUsereqSettingsMenuBridge`|iface||29-35|export interface PiUsereqSettingsMenuBridge|
|
|
3712
|
+
|`PiUsereqSettingsMenuOptions`|iface||41-45|export interface PiUsereqSettingsMenuOptions|
|
|
3713
|
+
|`PiUsereqSettingsMenuComponent`|iface||51-53|export interface PiUsereqSettingsMenuComponent extends Co...|
|
|
3714
|
+
|`PiUsereqSettingsThemeColor`|type||61||
|
|
3715
|
+
|`PiUsereqSettingsTheme`|iface||70-73|interface PiUsereqSettingsTheme|
|
|
3716
|
+
|`buildFallbackPiUsereqSettingsListTheme`|fn||85-97|function buildFallbackPiUsereqSettingsListTheme(|
|
|
3717
|
+
|`buildPiUsereqSettingsListTheme`|fn||110-124|function buildPiUsereqSettingsListTheme(|
|
|
3718
|
+
|`formatPiUsereqSettingsMenuTitle`|fn||136-141|function formatPiUsereqSettingsMenuTitle(|
|
|
3719
|
+
|`createImmediateSelectionComponent`|fn||150-162|function createImmediateSelectionComponent(choiceId: stri...|
|
|
3720
|
+
|`buildSettingItems`|fn||172-193|function buildSettingItems(|
|
|
3721
|
+
|`setSettingsListSelectedIndex`|fn||202-207|function setSettingsListSelectedIndex(|
|
|
3722
|
+
|`getSettingsListSelectedIndex`|fn||215-220|function getSettingsListSelectedIndex(|
|
|
3723
|
+
|`showPiUsereqSettingsMenu`|fn||232-236|export async function showPiUsereqSettingsMenu(|
|
|
3724
|
+
|`rebuildMenu`|fn||272-279|const rebuildMenu = (selectedChoiceId?: string): void =>|
|
|
3619
3725
|
|
|
3620
3726
|
|
|
3621
3727
|
---
|
|
@@ -4125,7 +4231,7 @@ import { ReqError } from "./errors.js";
|
|
|
4125
4231
|
|
|
4126
4232
|
---
|
|
4127
4233
|
|
|
4128
|
-
# tool-runner.ts | TypeScript |
|
|
4234
|
+
# tool-runner.ts | TypeScript | 458L | 22 symbols | 11 imports | 24 comments
|
|
4129
4235
|
> Path: `src/core/tool-runner.ts`
|
|
4130
4236
|
- @brief Implements the executable back-end for pi-usereq CLI analysis and static-check commands.
|
|
4131
4237
|
- @details Centralizes project discovery, git-backed source-file collection, documentation token generation, compression, construct lookup, and static-check dispatch. Runtime depends on the selected command and may include filesystem reads, config writes, and process spawning.
|
|
@@ -4227,9 +4333,9 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4227
4333
|
- @return {ToolResult} Tool result containing the formatted summary and warnings.
|
|
4228
4334
|
- @throws {ReqError} Throws when no valid files are provided.
|
|
4229
4335
|
|
|
4230
|
-
### fn `export function
|
|
4231
|
-
- @brief Generates the monolithic
|
|
4232
|
-
- @details Delegates to `generateMarkdown(...)`, keeps output paths relative to the caller cwd, and returns the Python-compatible markdown document through stdout. Runtime is O(F + S). Side effects are limited to filesystem reads and optional stderr logging.
|
|
4336
|
+
### fn `export function runFilesSummarize(files: string[], cwd = process.cwd(), verbose = false): ToolResult` (L250-256)
|
|
4337
|
+
- @brief Generates the monolithic summary markdown for explicit files.
|
|
4338
|
+
- @details Delegates to `generateMarkdown(...)`, keeps output paths relative to the caller cwd, and returns the Python-compatible summary markdown document through stdout. Runtime is O(F + S). Side effects are limited to filesystem reads and optional stderr logging.
|
|
4233
4339
|
- @param[in] files {string[]} Explicit file paths.
|
|
4234
4340
|
- @param[in] cwd {string} Base directory used for relative output paths. Defaults to `process.cwd()`.
|
|
4235
4341
|
- @param[in] verbose {boolean} When `true`, emit per-file progress diagnostics to stderr.
|
|
@@ -4254,9 +4360,9 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4254
4360
|
- @return {ToolResult} Successful tool result containing construct markdown.
|
|
4255
4361
|
- @throws {ReqError} Throws when required arguments are missing.
|
|
4256
4362
|
|
|
4257
|
-
### fn `export function
|
|
4258
|
-
- @brief Generates the monolithic
|
|
4259
|
-
- @details Resolves the project base, collects configured source files, prepends the repository file-structure markdown block, and returns the Python-compatible
|
|
4363
|
+
### fn `export function runSummarize(projectBase: string, config?: UseReqConfig, verbose = false): ToolResult` (L298-309)
|
|
4364
|
+
- @brief Generates the monolithic summary markdown for configured source directories.
|
|
4365
|
+
- @details Resolves the project base, collects configured source files, prepends the repository file-structure markdown block, and returns the Python-compatible summary document through stdout. Runtime is O(F log F + S). Side effects are limited to filesystem reads and optional stderr logging.
|
|
4260
4366
|
- @param[in] projectBase {string} Candidate project root.
|
|
4261
4367
|
- @param[in] config {UseReqConfig | undefined} Optional preloaded configuration.
|
|
4262
4368
|
- @param[in] verbose {boolean} When `true`, emit per-file diagnostics to stderr.
|
|
@@ -4264,7 +4370,17 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4264
4370
|
- @throws {ReqError} Throws when no source files are found or no file can be analyzed.
|
|
4265
4371
|
- @satisfies REQ-014, REQ-076, REQ-077, REQ-078, REQ-079
|
|
4266
4372
|
|
|
4267
|
-
### fn `export function
|
|
4373
|
+
### fn `export function runReferences(projectBase: string, config?: UseReqConfig, verbose = false): ToolResult` (L321-329)
|
|
4374
|
+
- @brief Writes configured project references markdown to the canonical docs file.
|
|
4375
|
+
- @details Reuses `runSummarize(...)` to generate the same file-structure-plus-summary markdown, resolves `<docs-dir>/REFERENCES.md` from the effective project configuration, overwrites the target file, and returns the status-only stdout `success`. Runtime is O(F log F + S) plus one file write. Side effects include filesystem writes.
|
|
4376
|
+
- @param[in] projectBase {string} Candidate project root.
|
|
4377
|
+
- @param[in] config {UseReqConfig | undefined} Optional preloaded configuration.
|
|
4378
|
+
- @param[in] verbose {boolean} When `true`, emit per-file diagnostics to stderr during summary generation.
|
|
4379
|
+
- @return {ToolResult} Successful tool result containing the status-only stdout payload.
|
|
4380
|
+
- @throws {ReqError} Throws when source discovery, summary generation, or file writing fails.
|
|
4381
|
+
- @satisfies REQ-293
|
|
4382
|
+
|
|
4383
|
+
### fn `export function runCompress(projectBase: string, config?: UseReqConfig, enableLineNumbers = false, verbose = false): ToolResult` (L341-346)
|
|
4268
4384
|
- @brief Compresses all source files from configured source directories.
|
|
4269
4385
|
- @details Resolves the project base, collects source files, and delegates to `compressFiles`. Runtime is O(F + S). Side effects are limited to filesystem reads and optional stderr logging.
|
|
4270
4386
|
- @param[in] projectBase {string} Candidate project root.
|
|
@@ -4274,7 +4390,7 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4274
4390
|
- @return {ToolResult} Successful tool result containing compressed output.
|
|
4275
4391
|
- @throws {ReqError} Throws when no source files are found.
|
|
4276
4392
|
|
|
4277
|
-
### fn `export function runSearch(projectBase: string, tagFilter: string, pattern: string, config?: UseReqConfig, enableLineNumbers = false, verbose = false): ToolResult` (
|
|
4393
|
+
### fn `export function runSearch(projectBase: string, tagFilter: string, pattern: string, config?: UseReqConfig, enableLineNumbers = false, verbose = false): ToolResult` (L360-369)
|
|
4278
4394
|
- @brief Searches named constructs across configured project source files.
|
|
4279
4395
|
- @details Resolves the project base, collects source files, delegates to `searchConstructsInFiles`, and converts thrown search errors into structured `ReqError` failures. Runtime is O(F + S + M). Side effects are limited to filesystem reads and optional stderr logging.
|
|
4280
4396
|
- @param[in] projectBase {string} Candidate project root.
|
|
@@ -4286,7 +4402,7 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4286
4402
|
- @return {ToolResult} Successful tool result containing construct markdown.
|
|
4287
4403
|
- @throws {ReqError} Throws when no source files are found or the search fails.
|
|
4288
4404
|
|
|
4289
|
-
### fn `export function runTokens(projectBase: string, config?: UseReqConfig): ToolResult` (
|
|
4405
|
+
### fn `export function runTokens(projectBase: string, config?: UseReqConfig): ToolResult` (L379-388)
|
|
4290
4406
|
- @brief Counts tokens for canonical documentation files.
|
|
4291
4407
|
- @details Loads the configured docs directory, selects `REQUIREMENTS.md`, `WORKFLOW.md`, and `REFERENCES.md` when present, and delegates to `runFilesTokens`. Runtime is O(F + S). Side effects are limited to filesystem reads.
|
|
4292
4408
|
- @param[in] projectBase {string} Candidate project root.
|
|
@@ -4294,7 +4410,7 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4294
4410
|
- @return {ToolResult} Tool result containing documentation token metrics.
|
|
4295
4411
|
- @throws {ReqError} Throws when no canonical docs files exist.
|
|
4296
4412
|
|
|
4297
|
-
### fn `export function runFilesStaticCheck(files: string[], projectBase: string, config?: UseReqConfig): ToolResult` (
|
|
4413
|
+
### fn `export function runFilesStaticCheck(files: string[], projectBase: string, config?: UseReqConfig): ToolResult` (L398-434)
|
|
4298
4414
|
- @brief Runs configured static checks for explicit files.
|
|
4299
4415
|
- @details Loads the effective static-check config, resolves the active checker list per file-extension language through the per-language enable flag, captures checker stdout for each dispatched entry, and aggregates stderr warnings for invalid paths. Runtime is O(F * C) plus external checker cost. Side effects include filesystem reads, stdout interception, and process spawning.
|
|
4300
4416
|
- @param[in] files {string[]} Explicit file paths.
|
|
@@ -4302,7 +4418,7 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4302
4418
|
- @param[in] config {UseReqConfig | undefined} Optional preloaded configuration.
|
|
4303
4419
|
- @return {ToolResult} Aggregated static-check result.
|
|
4304
4420
|
|
|
4305
|
-
### fn `export function runProjectStaticCheck(projectBase: string, config?: UseReqConfig): ToolResult` (
|
|
4421
|
+
### fn `export function runProjectStaticCheck(projectBase: string, config?: UseReqConfig): ToolResult` (L444-457)
|
|
4306
4422
|
- @brief Runs configured static checks for project source and test directories.
|
|
4307
4423
|
- @details Collects source and test files, excludes fixture roots, and delegates to `runFilesStaticCheck`. Runtime is O(F * C) plus external checker cost. Side effects include filesystem reads, stdout interception, and process spawning.
|
|
4308
4424
|
- @param[in] projectBase {string} Candidate project root.
|
|
@@ -4325,15 +4441,16 @@ import { makeRelativeIfContainsProject } from "./utils.js";
|
|
|
4325
4441
|
|`resolveProjectSrcDirs`|fn||196-204|export function resolveProjectSrcDirs(projectBase: string...|
|
|
4326
4442
|
|`loadAndRepairConfig`|fn||213-218|export function loadAndRepairConfig(projectBase: string):...|
|
|
4327
4443
|
|`runFilesTokens`|fn||227-239|export function runFilesTokens(files: string[]): ToolResult|
|
|
4328
|
-
|`
|
|
4444
|
+
|`runFilesSummarize`|fn||250-256|export function runFilesSummarize(files: string[], cwd = ...|
|
|
4329
4445
|
|`runFilesCompress`|fn||267-269|export function runFilesCompress(files: string[], cwd = p...|
|
|
4330
4446
|
|`runFilesSearch`|fn||280-286|export function runFilesSearch(argsList: string[], enable...|
|
|
4331
|
-
|`
|
|
4332
|
-
|`
|
|
4333
|
-
|`
|
|
4334
|
-
|`
|
|
4335
|
-
|`
|
|
4336
|
-
|`
|
|
4447
|
+
|`runSummarize`|fn||298-309|export function runSummarize(projectBase: string, config?...|
|
|
4448
|
+
|`runReferences`|fn||321-329|export function runReferences(projectBase: string, config...|
|
|
4449
|
+
|`runCompress`|fn||341-346|export function runCompress(projectBase: string, config?:...|
|
|
4450
|
+
|`runSearch`|fn||360-369|export function runSearch(projectBase: string, tagFilter:...|
|
|
4451
|
+
|`runTokens`|fn||379-388|export function runTokens(projectBase: string, config?: U...|
|
|
4452
|
+
|`runFilesStaticCheck`|fn||398-434|export function runFilesStaticCheck(files: string[], proj...|
|
|
4453
|
+
|`runProjectStaticCheck`|fn||444-457|export function runProjectStaticCheck(projectBase: string...|
|
|
4337
4454
|
|
|
4338
4455
|
|
|
4339
4456
|
---
|
|
@@ -4420,7 +4537,7 @@ import path from "node:path";
|
|
|
4420
4537
|
|
|
4421
4538
|
---
|
|
4422
4539
|
|
|
4423
|
-
# index.ts | TypeScript |
|
|
4540
|
+
# index.ts | TypeScript | 4203L | 93 symbols | 27 imports | 99 comments
|
|
4424
4541
|
> Path: `src/index.ts`
|
|
4425
4542
|
- @brief Registers the pi-usereq extension commands, tools, and configuration UI.
|
|
4426
4543
|
- @details Bridges the standalone tool-runner layer into the pi extension API by registering prompt commands, agent tools, and interactive configuration menus. Runtime at module load is O(1); later behavior depends on the selected command or tool. Side effects include extension registration, UI updates, filesystem reads/writes, and delegated tool execution.
|
|
@@ -4442,6 +4559,8 @@ import {
|
|
|
4442
4559
|
import { renderPrompt } from "./core/prompts.js";
|
|
4443
4560
|
import {
|
|
4444
4561
|
import {
|
|
4562
|
+
import {
|
|
4563
|
+
import {
|
|
4445
4564
|
import { PROMPT_COMMAND_NAMES } from "./core/prompt-command-catalog.js";
|
|
4446
4565
|
import { resolveRuntimeGitPath } from "./core/runtime-project-paths.js";
|
|
4447
4566
|
import {
|
|
@@ -4456,45 +4575,45 @@ import { makeRelativeIfContainsProject, shellSplit } from "./core/utils.js";
|
|
|
4456
4575
|
|
|
4457
4576
|
## Definitions
|
|
4458
4577
|
|
|
4459
|
-
### iface `interface PiShortcutRegistrar` (
|
|
4578
|
+
### iface `interface PiShortcutRegistrar` (L177-185)
|
|
4460
4579
|
- @brief Describes the optional shortcut-registration surface used by pi-usereq.
|
|
4461
4580
|
- @details Narrows the runtime API to the documented `registerShortcut(...)`
|
|
4462
4581
|
method so the extension can remain compatible with offline harnesses that do
|
|
4463
4582
|
not implement shortcut capture. Compile-time only and introduces no runtime
|
|
4464
4583
|
cost.
|
|
4465
4584
|
|
|
4466
|
-
### fn `function getProjectBase(cwd: string): string` (
|
|
4585
|
+
### fn `function getProjectBase(cwd: string): string` (L193-202)
|
|
4467
4586
|
- @brief Resolves the effective project base from a working directory.
|
|
4468
4587
|
- @details Normalizes the provided cwd into an absolute path without consulting configuration. Time complexity is O(1). No I/O side effects occur.
|
|
4469
4588
|
- @param[in] cwd {string} Current working directory.
|
|
4470
4589
|
- @return {string} Absolute project base path.
|
|
4471
4590
|
|
|
4472
|
-
### fn `function getProcessCwdSafe(): string` (
|
|
4591
|
+
### fn `function getProcessCwdSafe(): string` (L209-218)
|
|
4473
4592
|
- @brief Resolves a safe process working directory for extension-load paths.
|
|
4474
4593
|
- @details Returns `process.cwd()` when available and falls back to absolute `PWD`, `HOME`, or `/` when the current shell directory has been deleted. Runtime is O(1). No external state is mutated.
|
|
4475
4594
|
- @return {string} Absolute fallback-safe process working directory.
|
|
4476
4595
|
|
|
4477
|
-
### fn `function resolveLiveBootstrapCwd(cwd: string): string` (
|
|
4596
|
+
### fn `function resolveLiveBootstrapCwd(cwd: string): string` (L226-238)
|
|
4478
4597
|
- @brief Resolves the live working directory used for bootstrap-sensitive flows.
|
|
4479
4598
|
- @details Prefers the supplied cwd when it still exists. Otherwise reuses the tracked runtime context path when it remains live, then the tracked runtime base path, and finally a process-safe cwd so deleted worktree paths retained by stale contexts cannot poison later prompt preflight or lifecycle bootstrap. Runtime is O(1) plus bounded filesystem probes. No external state is mutated.
|
|
4480
4599
|
- @param[in] cwd {string} Candidate context cwd.
|
|
4481
4600
|
- @return {string} Existing absolute cwd used for bootstrap work.
|
|
4482
4601
|
|
|
4483
|
-
### fn `function syncContextCwdMirror(ctx: { cwd?: string }, cwd: string): void` (
|
|
4602
|
+
### fn `function syncContextCwdMirror(ctx: { cwd?: string }, cwd: string): void` (L247-256)
|
|
4484
4603
|
- @brief Best-effort synchronizes one context `cwd` mirror with bootstrap reality.
|
|
4485
4604
|
- @details Applies the resolved live cwd to the supplied context when writable and ignores stale or read-only mirrors so command bootstrap can continue using authoritative filesystem probes. Runtime is O(1). Side effects are limited to optional `ctx.cwd` mutation.
|
|
4486
4605
|
- @param[in] cwd {string} Resolved live cwd.
|
|
4487
4606
|
- @param[in,out] ctx {{ cwd?: string }} Mutable context-like object.
|
|
4488
4607
|
- @return {void} No return value.
|
|
4489
4608
|
|
|
4490
|
-
### fn `function loadProjectConfig(cwd: string): UseReqConfig` (
|
|
4609
|
+
### fn `function loadProjectConfig(cwd: string): UseReqConfig` (L265-268)
|
|
4491
4610
|
- @brief Loads project configuration for the extension runtime.
|
|
4492
4611
|
- @details Resolves the project base, loads persisted config, and normalizes configured directory paths without reading or persisting runtime-derived `base-path` or `git-path` metadata. Runtime is dominated by config I/O. Side effects are limited to filesystem reads.
|
|
4493
4612
|
- @param[in] cwd {string} Current working directory.
|
|
4494
4613
|
- @return {UseReqConfig} Effective project configuration.
|
|
4495
4614
|
- @satisfies REQ-030, REQ-145, REQ-146
|
|
4496
4615
|
|
|
4497
|
-
### fn `function saveProjectConfig(cwd: string, config: UseReqConfig): void` (
|
|
4616
|
+
### fn `function saveProjectConfig(cwd: string, config: UseReqConfig): void` (L278-281)
|
|
4498
4617
|
- @brief Persists project configuration from the extension runtime.
|
|
4499
4618
|
- @details Resolves the project base, normalizes configured directory paths into project-relative form, and delegates persistence to `saveConfig` without serializing runtime-derived path metadata. Runtime is O(n) in config size. Side effects include config-file writes.
|
|
4500
4619
|
- @param[in] cwd {string} Current working directory.
|
|
@@ -4502,32 +4621,32 @@ cost.
|
|
|
4502
4621
|
- @return {void} No return value.
|
|
4503
4622
|
- @satisfies REQ-146
|
|
4504
4623
|
|
|
4505
|
-
### fn `function formatProjectConfigPathForMenu(cwd: string): string` (
|
|
4624
|
+
### fn `function formatProjectConfigPathForMenu(cwd: string): string` (L290-294)
|
|
4506
4625
|
- @brief Formats the current project config path for top-level menu display.
|
|
4507
4626
|
- @details Resolves `<base-path>/.pi-usereq.json` from the cwd-derived project base, reuses the shared runtime-path formatter, and rewrites a leading POSIX `$HOME` token to `~` for the `Show configuration` row only. Runtime is O(p) in path length. No external state is mutated.
|
|
4508
4627
|
- @param[in] cwd {string} Current working directory.
|
|
4509
4628
|
- @return {string} `~`-relative or absolute config path display value.
|
|
4510
4629
|
- @satisfies REQ-162
|
|
4511
4630
|
|
|
4512
|
-
### fn `function buildTerminalSettingsMenuChoices(options:` (
|
|
4631
|
+
### fn `function buildTerminalSettingsMenuChoices(options:` (L303-314)
|
|
4513
4632
|
- @brief Builds the standardized terminal rows appended to every configuration menu.
|
|
4514
|
-
- @details Returns the canonical `Reset defaults` row so all configuration menus and descendant selector menus share the same terminal ordering contract without rendering `Save and close`. Runtime is O(1). No external state is mutated.
|
|
4515
|
-
- @param[in] options {{ resetDefaultsDescription: string
|
|
4633
|
+
- @details Returns the canonical value-less `Reset defaults` row so all configuration menus and descendant selector menus share the same terminal ordering contract without rendering `Save and close`. Runtime is O(1). No external state is mutated.
|
|
4634
|
+
- @param[in] options {{ resetDefaultsDescription: string }} Menu-specific terminal-row metadata.
|
|
4516
4635
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered terminal menu rows.
|
|
4517
4636
|
- @satisfies REQ-193
|
|
4518
4637
|
|
|
4519
|
-
### iface `interface ResetConfirmationChange` (
|
|
4638
|
+
### iface `interface ResetConfirmationChange` (L320-324)
|
|
4520
4639
|
- @brief Describes one pending reset value change shown in confirmation menus.
|
|
4521
4640
|
- @details Stores the row label plus its previous and next values so reset-confirmation submenus can expose machine-readable and human-verifiable change previews. The interface is compile-time only and introduces no runtime cost.
|
|
4522
4641
|
|
|
4523
|
-
### fn `function formatResetConfirmationValue(previousValue: string, nextValue: string): string` (
|
|
4642
|
+
### fn `function formatResetConfirmationValue(previousValue: string, nextValue: string): string` (L333-335)
|
|
4524
4643
|
- @brief Formats one reset-confirmation value pair for menu display.
|
|
4525
4644
|
- @details Serializes the previous and next values into a deterministic `previous -> next` preview string used by confirmation submenus. Runtime is O(n) in combined value length. No external state is mutated.
|
|
4526
4645
|
- @param[in] previousValue {string} Current persisted value.
|
|
4527
4646
|
- @param[in] nextValue {string} Candidate default value.
|
|
4528
4647
|
- @return {string} Rendered preview string.
|
|
4529
4648
|
|
|
4530
|
-
### fn `function buildResetConfirmationChoices(` (
|
|
4649
|
+
### fn `function buildResetConfirmationChoices(` (L345-384)
|
|
4531
4650
|
- @brief Builds the shared settings-menu choices for one reset-confirmation submenu.
|
|
4532
4651
|
- @details Renders each pending changed value as a disabled preview row, appends explicit approve and abort actions, and falls back to one disabled no-op row when no values would change. Runtime is O(n) in changed-value count. No external state is mutated.
|
|
4533
4652
|
- @param[in] changes {ResetConfirmationChange[]} Changed-value preview rows.
|
|
@@ -4535,7 +4654,7 @@ cost.
|
|
|
4535
4654
|
- @param[in] abortDescription {string} Description for the abort action.
|
|
4536
4655
|
- @return {PiUsereqSettingsMenuChoice[]} Reset-confirmation submenu choices.
|
|
4537
4656
|
|
|
4538
|
-
### fn `async function confirmResetChanges(` (
|
|
4657
|
+
### fn `async function confirmResetChanges(` (L396-409)
|
|
4539
4658
|
- @brief Opens one explicit reset-confirmation submenu.
|
|
4540
4659
|
- @details Uses the shared settings-menu renderer to show every changed value before reset application and returns `true` only when the user selects the explicit approval action. Runtime depends on user interaction count. Side effects are limited to transient custom-UI rendering.
|
|
4541
4660
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
@@ -4545,7 +4664,7 @@ cost.
|
|
|
4545
4664
|
- @param[in] abortDescription {string} Description for the abort action.
|
|
4546
4665
|
- @return {Promise<boolean>} `true` when the reset is explicitly approved.
|
|
4547
4666
|
|
|
4548
|
-
### fn `function writePersistedProjectConfigToEditor(` (
|
|
4667
|
+
### fn `function writePersistedProjectConfigToEditor(` (L420-427)
|
|
4549
4668
|
- @brief Writes the already-persisted project configuration file text into the editor.
|
|
4550
4669
|
- @details Reads the current `.pi-usereq.json` file content from disk after the caller has saved any pending configuration changes and forwards that exact persisted text into the editor. Runtime is O(n) in serialized config size. Side effects include filesystem reads and editor-text mutation.
|
|
4551
4670
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
@@ -4554,51 +4673,51 @@ cost.
|
|
|
4554
4673
|
- @return {void} No return value.
|
|
4555
4674
|
- @satisfies REQ-031
|
|
4556
4675
|
|
|
4557
|
-
### fn `function buildSearchToolSupportedTagGuidelines(): string[]` (
|
|
4676
|
+
### fn `function buildSearchToolSupportedTagGuidelines(): string[]` (L488-492)
|
|
4558
4677
|
- @brief Builds the supported-tag guidance lines embedded in search-tool registrations.
|
|
4559
4678
|
- @details Emits one deterministic line per supported language containing its canonical registration label and sorted tag list so downstream agents can specialize requests without invoking the tool first. Runtime is O(l * t log t). No side effects occur.
|
|
4560
4679
|
- @return {string[]} Supported-tag guidance lines.
|
|
4561
4680
|
|
|
4562
|
-
### fn `function buildSearchToolSchemaDescription(scope: FindToolScope): string` (
|
|
4681
|
+
### fn `function buildSearchToolSchemaDescription(scope: FindToolScope): string` (L500-505)
|
|
4563
4682
|
- @brief Builds the schema description for one search-tool registration.
|
|
4564
4683
|
- @details Specializes the explicit-file and configured-directory input contracts while documenting the monolithic markdown output channel and minimal execution details shape. Runtime is O(1). No side effects occur.
|
|
4565
4684
|
- @param[in] scope {FindToolScope} Search-tool scope.
|
|
4566
4685
|
- @return {string} Parameter-schema description.
|
|
4567
4686
|
|
|
4568
|
-
### fn `function buildSearchToolPromptGuidelines(scope: FindToolScope): string[]` (
|
|
4687
|
+
### fn `function buildSearchToolPromptGuidelines(scope: FindToolScope): string[]` (L513-526)
|
|
4569
4688
|
- @brief Builds the prompt-guideline set for one search-tool registration.
|
|
4570
4689
|
- @details Encodes scope selection, monolithic markdown output semantics, regex semantics, line-number behavior, tag-filter rules, and the full language-to-tag matrix as stable agent-oriented strings. Runtime is O(l * t log t). No side effects occur.
|
|
4571
4690
|
- @param[in] scope {FindToolScope} Search-tool scope.
|
|
4572
4691
|
- @return {string[]} Prompt-guideline strings.
|
|
4573
4692
|
|
|
4574
|
-
- type `type MonolithicToolRenderResult = {` (
|
|
4693
|
+
- type `type MonolithicToolRenderResult = {` (L532)
|
|
4575
4694
|
- @brief Describes the monolithic tool-result surface consumed by tool-row renderers.
|
|
4576
4695
|
- @details Narrows execute-result data to the primary text content block plus the minimal `details.execution` metadata returned by monolithic tool wrappers. The alias is compile-time only and introduces no runtime cost.
|
|
4577
|
-
### fn `function getMonolithicToolText(result: MonolithicToolRenderResult): string` (
|
|
4696
|
+
### fn `function getMonolithicToolText(result: MonolithicToolRenderResult): string` (L549-552)
|
|
4578
4697
|
- @brief Extracts the primary monolithic text block from one tool result.
|
|
4579
4698
|
- @details Returns the first text content block when present and falls back to an empty string when the tool emitted no LLM-facing content. Runtime is O(1). No external state is mutated.
|
|
4580
4699
|
- @param[in] result {MonolithicToolRenderResult} Tool result wrapper.
|
|
4581
4700
|
- @return {string} Primary monolithic content text.
|
|
4582
4701
|
|
|
4583
|
-
### fn `function getMonolithicToolErrorText(result: MonolithicToolRenderResult): string | undefined` (
|
|
4702
|
+
### fn `function getMonolithicToolErrorText(result: MonolithicToolRenderResult): string | undefined` (L560-570)
|
|
4584
4703
|
- @brief Reads the first residual execution error string from one monolithic tool result.
|
|
4585
4704
|
- @details Prefers the first `stderr_lines` entry when present and otherwise falls back to the first line of `stderr`. Runtime is O(1) plus first-line split cost. No external state is mutated.
|
|
4586
4705
|
- @param[in] result {MonolithicToolRenderResult} Tool result wrapper.
|
|
4587
4706
|
- @return {string | undefined} First residual execution error string.
|
|
4588
4707
|
|
|
4589
|
-
### fn `function formatCompactToolArgumentValue(value: unknown): string | undefined` (
|
|
4708
|
+
### fn `function formatCompactToolArgumentValue(value: unknown): string | undefined` (L578-617)
|
|
4590
4709
|
- @brief Formats one scalar or structural tool argument for compact render summaries.
|
|
4591
4710
|
- @details Truncates long strings, compresses arrays into short previews, and renders plain object arguments as key indexes so collapsed tool rows stay compact while still exposing the essential invocation shape. Runtime is O(n) in preview size. No external state is mutated.
|
|
4592
4711
|
- @param[in] value {unknown} Candidate tool argument value.
|
|
4593
4712
|
- @return {string | undefined} Compact preview string or `undefined` when the value carries no useful summary.
|
|
4594
4713
|
|
|
4595
|
-
### fn `function buildCompactToolInvocationText(args: Record<string, unknown> | undefined): string` (
|
|
4714
|
+
### fn `function buildCompactToolInvocationText(args: Record<string, unknown> | undefined): string` (L625-636)
|
|
4596
4715
|
- @brief Builds the compact invocation summary appended to collapsed tool rows.
|
|
4597
4716
|
- @details Renders only caller-supplied parameters that have stable, non-empty compact previews and joins them in insertion order so agents can infer how the tool was used without expanding the full result. Runtime is O(n) in argument count and preview size. No external state is mutated.
|
|
4598
4717
|
- @param[in] args {Record<string, unknown> | undefined} Current tool call arguments.
|
|
4599
4718
|
- @return {string} Compact invocation summary prefixed with one separating space, or the empty string when no useful preview exists.
|
|
4600
4719
|
|
|
4601
|
-
### fn `function summarizeStructuredToolResult(` (
|
|
4720
|
+
### fn `function summarizeStructuredToolResult(` (L646-661)
|
|
4602
4721
|
- @brief Builds the compact default text for one monolithic tool result row.
|
|
4603
4722
|
- @details Prefers the tool name, compact invocation preview, and success marker for collapsed rows, and falls back to residual execution diagnostics when the tool failed before completing successfully. Runtime is O(n) in compact argument-preview size. No external state is mutated.
|
|
4604
4723
|
- @param[in] toolName {string} Registered tool name.
|
|
@@ -4606,20 +4725,27 @@ cost.
|
|
|
4606
4725
|
- @param[in] args {Record<string, unknown> | undefined} Current tool call arguments.
|
|
4607
4726
|
- @return {string} Compact single-line summary.
|
|
4608
4727
|
|
|
4609
|
-
### fn `function buildStructuredToolRenderResult(toolName: string)` (
|
|
4728
|
+
### fn `function buildStructuredToolRenderResult(toolName: string)` (L670-689)
|
|
4610
4729
|
- @brief Builds a custom `renderResult` implementation for one monolithic tool.
|
|
4611
4730
|
- @details Reuses a mutable `Text` component when possible, keeps the default collapsed row compact with essential invocation parameters plus result status, and reveals the full monolithic content only when the tool row is expanded. Runtime is O(n) in expanded content length and compact argument-preview size. No external state is mutated.
|
|
4612
4731
|
- @param[in] toolName {string} Registered tool name.
|
|
4613
4732
|
- @return {(result: MonolithicToolRenderResult, options: { expanded?: boolean; isPartial?: boolean }, _theme: unknown, context: { args?: Record<string, unknown>; lastComponent?: unknown }) => Text} Custom result renderer.
|
|
4614
4733
|
- @satisfies REQ-210
|
|
4615
4734
|
|
|
4616
|
-
### fn `function executeMonolithicTool(operation: () => ToolResult): ReturnType<typeof buildMonolithicToolExecuteResult>` (
|
|
4735
|
+
### fn `function executeMonolithicTool(operation: () => ToolResult): ReturnType<typeof buildMonolithicToolExecuteResult>` (L697-703)
|
|
4617
4736
|
- @brief Executes one CLI-style runner for a monolithic agent tool.
|
|
4618
4737
|
- @details Reuses the standalone tool-runner contract, normalizes thrown failures into `ToolResult`, and wraps the selected stdout or stderr text into the monolithic content channel. Runtime is dominated by the delegated runner. Side effects depend on the selected tool.
|
|
4619
4738
|
- @param[in] operation {() => ToolResult} Runner callback.
|
|
4620
4739
|
- @return {ReturnType<typeof buildMonolithicToolExecuteResult>} Monolithic tool execute result.
|
|
4621
4740
|
|
|
4622
|
-
### fn `function
|
|
4741
|
+
### fn `function executeStatusTool(operation: () => ToolResult): ReturnType<typeof buildMonolithicToolExecuteResult>` (L712-741)
|
|
4742
|
+
- @brief Executes one CLI-style runner for a status-only agent tool.
|
|
4743
|
+
- @details Reuses the standalone tool-runner contract, preserves `content[0].text` as the status-only `success` or `error: <diagnostic>` payload, and strips success-path `stdout_lines` so `details.execution` stays limited to the numeric code plus optional residual stderr diagnostics. Runtime is dominated by the delegated runner. Side effects depend on the selected tool.
|
|
4744
|
+
- @param[in] operation {() => ToolResult} Runner callback.
|
|
4745
|
+
- @return {ReturnType<typeof buildMonolithicToolExecuteResult>} Status-only tool execute result.
|
|
4746
|
+
- @satisfies REQ-294, REQ-295, REQ-296
|
|
4747
|
+
|
|
4748
|
+
### fn `function deliverPromptCommand(` (L752-770)
|
|
4623
4749
|
- @brief Starts delivery of one rendered prompt into the current active session.
|
|
4624
4750
|
- @details Prefers the replacement-session `sendUserMessage(...)` helper exposed by `withSession(...)` callbacks after session replacement so post-switch prompt delivery never reuses stale pre-switch session-bound extension objects. Returns the underlying delivery promise without awaiting it so callers can record the `running` workflow transition as soon as prompt handoff is accepted instead of waiting for the full agent turn to complete on runtimes whose async replacement-session helpers resolve only after `agent_end`. When pi later invalidates that replacement-session context during successful prompt-end restoration, the helper suppresses the documented stale-extension-context rejection because the prompt was already accepted and late rethrow would surface a false orchestration failure. Falls back to `pi.sendUserMessage(...)` only for non-replacement flows or runtimes that do not expose replacement-session helpers. Runtime is O(n) in prompt length. Side effects are limited to user-message delivery.
|
|
4625
4751
|
- @param[in] pi {ExtensionAPI} Handler-scoped extension API instance retained as the fallback dispatcher.
|
|
@@ -4628,7 +4754,7 @@ cost.
|
|
|
4628
4754
|
- @return {Promise<void>} Promise representing eventual prompt-delivery completion.
|
|
4629
4755
|
- @satisfies REQ-004, REQ-067, REQ-068, REQ-227, REQ-281
|
|
4630
4756
|
|
|
4631
|
-
### fn `function shouldIgnoreLatePromptDeliveryFailure(` (
|
|
4757
|
+
### fn `function shouldIgnoreLatePromptDeliveryFailure(` (L781-797)
|
|
4632
4758
|
- @brief Detects prompt-delivery failures that can be ignored after prompt ownership has moved past the command handler.
|
|
4633
4759
|
- @details Matches the documented stale-extension-context runtime error once prompt ownership has already moved beyond command-side preflight. The helper treats the failure as ignorable when the persisted prompt runtime state shows the same execution session as the active prompt run or when the persisted workflow state has already advanced beyond `checking|running`, because rethrowing at that point would incorrectly re-enter command-side abort logic after the prompt was already accepted. Runtime is O(n) in error-message length plus path length. No external state is mutated.
|
|
4634
4760
|
- @param[in] error {unknown} Candidate prompt-delivery failure.
|
|
@@ -4637,7 +4763,7 @@ cost.
|
|
|
4637
4763
|
- @return {boolean} `true` when the failure is a late stale-context delivery rejection that MUST be ignored.
|
|
4638
4764
|
- @satisfies REQ-208, REQ-280, REQ-281, REQ-282
|
|
4639
4765
|
|
|
4640
|
-
### fn `function logPromptWorkflowStateChange(` (
|
|
4766
|
+
### fn `function logPromptWorkflowStateChange(` (L810-829)
|
|
4641
4767
|
- @brief Appends one workflow-state debug entry for a bundled prompt when selected.
|
|
4642
4768
|
- @details Reuses the shared debug logger so `req-*` command handlers and prompt-end orchestration can record deterministic workflow transitions without duplicating JSON payload shaping. Runtime is O(n) in serialized payload size only when logging is enabled and O(1) otherwise. Side effects include debug-log file writes for matching enabled prompts.
|
|
4643
4769
|
- @param[in] projectBase {string} Absolute original project base path.
|
|
@@ -4648,7 +4774,7 @@ cost.
|
|
|
4648
4774
|
- @return {void} No return value.
|
|
4649
4775
|
- @satisfies REQ-245, REQ-246, REQ-247
|
|
4650
4776
|
|
|
4651
|
-
### fn `function logPromptWorkflowEvent(` (
|
|
4777
|
+
### fn `function logPromptWorkflowEvent(` (L845-865)
|
|
4652
4778
|
- @brief Appends one dedicated prompt workflow debug entry when selected.
|
|
4653
4779
|
- @details Reuses the shared workflow-event logger so prompt activation, restoration, closure, and session-shutdown paths can emit higher-granularity orchestration diagnostics without duplicating JSON payload shaping. Runtime is O(n) in serialized payload size only when logging is enabled and O(1) otherwise. Side effects include debug-log file writes for matching enabled prompts.
|
|
4654
4780
|
- @param[in] projectBase {string} Absolute original project base path.
|
|
@@ -4662,7 +4788,7 @@ cost.
|
|
|
4662
4788
|
- @return {void} No return value.
|
|
4663
4789
|
- @satisfies REQ-245, REQ-246, REQ-247, REQ-277
|
|
4664
4790
|
|
|
4665
|
-
### fn `function transitionPromptWorkflowState(` (
|
|
4791
|
+
### fn `function transitionPromptWorkflowState(` (L878-891)
|
|
4666
4792
|
- @brief Transitions one prompt workflow state and logs the transition immediately after the state update.
|
|
4667
4793
|
- @details Captures the previous workflow state, applies the new state through the shared status helper, and appends the gated `workflow_state` debug entry only after the transition has completed. Runtime is O(1). Side effects include status mutation, status-bar rendering, and optional debug-log writes.
|
|
4668
4794
|
- @param[in] ctx {ExtensionContext | ExtensionCommandContext} Active extension context.
|
|
@@ -4673,20 +4799,20 @@ cost.
|
|
|
4673
4799
|
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4674
4800
|
- @return {void} No return value.
|
|
4675
4801
|
|
|
4676
|
-
### fn `function resolvePromptCommandDescription(` (
|
|
4802
|
+
### fn `function resolvePromptCommandDescription(` (L899-903)
|
|
4677
4803
|
- @brief Resolves the runtime slash-command description for one bundled prompt.
|
|
4678
|
-
- @details Reads the bundled prompt
|
|
4804
|
+
- @details Reads the bundled prompt markdown, extracts the first `# ` heading payload, and falls back to the historical generated label when the prompt omits a level-one heading. Runtime is O(n) in prompt length. Side effects are limited to filesystem reads.
|
|
4679
4805
|
- @param[in] promptName {import("./core/prompt-command-catalog.js").PromptCommandName} Bundled prompt name.
|
|
4680
4806
|
- @return {string} Runtime command description.
|
|
4681
4807
|
|
|
4682
|
-
### fn `function resolveDebugProjectBase(cwd: string, statusController: PiUsereqStatusController): string` (
|
|
4808
|
+
### fn `function resolveDebugProjectBase(cwd: string, statusController: PiUsereqStatusController): string` (L912-916)
|
|
4683
4809
|
- @brief Resolves the original project base used for debug-log file writes.
|
|
4684
4810
|
- @details Prefers the active or pending prompt execution plan so tool-result logging during worktree-backed prompt runs persists into the original repository path instead of transient worktree directories. Runtime is O(1). No external state is mutated.
|
|
4685
4811
|
- @param[in] cwd {string} Current extension working directory.
|
|
4686
4812
|
- @param[in] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4687
4813
|
- @return {string} Absolute original project base path for debug logging.
|
|
4688
4814
|
|
|
4689
|
-
### fn `function notifyContextSafely(` (
|
|
4815
|
+
### fn `function notifyContextSafely(` (L927-944)
|
|
4690
4816
|
- @brief Delivers one best-effort UI notification without failing on stale replacement contexts.
|
|
4691
4817
|
- @details Attempts to use the supplied extension context for UI notification delivery and suppresses the documented stale-extension-context runtime error raised after session replacement, because prompt-orchestration closure can outlive the context that initiated the switch. Runtime is O(n) in message length. Side effects are limited to user notification delivery when the context is still active.
|
|
4692
4818
|
- @param[in] ctx {ExtensionContext | ExtensionCommandContext | undefined} Candidate UI context.
|
|
@@ -4695,20 +4821,30 @@ cost.
|
|
|
4695
4821
|
- @return {boolean} `true` when the notification was delivered and `false` when the context was already stale.
|
|
4696
4822
|
- @satisfies REQ-280
|
|
4697
4823
|
|
|
4698
|
-
### fn `function
|
|
4824
|
+
### fn `function rejectNonIdleReqCommand(` (L956-976)
|
|
4825
|
+
- @brief Rejects one non-`idle` req-command invocation and records the workflow error state.
|
|
4826
|
+
- @details Builds a deterministic busy-state diagnostic from the current workflow state, transitions the shared workflow state to `error`, preserves any pending or active prompt execution metadata for later closure handling, emits an error notification, and throws `ReqError`. Bundled prompt commands reuse `transitionPromptWorkflowState(...)` when cached configuration is available so prompt debug logging captures the actual state transition; specialized non-prompt commands fall back to direct status mutation. Runtime is O(1). Side effects include workflow-state mutation, status-bar rendering, optional debug-log writes, and user notification delivery.
|
|
4827
|
+
- @param[in] ctx {ExtensionContext | ExtensionCommandContext} Active extension context.
|
|
4828
|
+
- @param[in] promptName {import("./core/prompt-command-catalog.js").PromptCommandName | undefined} Optional bundled prompt name used for prompt debug logging.
|
|
4829
|
+
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4830
|
+
- @return {never} This helper always throws a deterministic `ReqError`.
|
|
4831
|
+
- @throws {ReqError} Always throws because non-`idle` req commands are rejected.
|
|
4832
|
+
- @satisfies REQ-224
|
|
4833
|
+
|
|
4834
|
+
### fn `function getPiUsereqStartupTools(pi: ExtensionAPI): ToolInfo[]` (L985-993)
|
|
4699
4835
|
- @brief Returns the configurable active-tool inventory visible to the extension.
|
|
4700
4836
|
- @details Filters runtime tools against the canonical configurable-tool set, keeps only builtin-backed embedded tools, and orders the result by the documented custom/files/embedded/default-disabled grouping. Runtime is O(t log t). No external state is mutated.
|
|
4701
4837
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4702
4838
|
- @return {ToolInfo[]} Sorted configurable tool descriptors.
|
|
4703
4839
|
- @satisfies REQ-007, REQ-063, REQ-231, REQ-232
|
|
4704
4840
|
|
|
4705
|
-
### fn `function getConfiguredEnabledPiUsereqTools(config: UseReqConfig): string[]` (
|
|
4841
|
+
### fn `function getConfiguredEnabledPiUsereqTools(config: UseReqConfig): string[]` (L1001-1005)
|
|
4706
4842
|
- @brief Normalizes and returns the configured enabled active tools.
|
|
4707
4843
|
- @details Reuses repository normalization rules, updates the config object in place, and returns the normalized array. Runtime is O(n) in configured tool count. Side effect: mutates `config["enabled-tools"]`.
|
|
4708
4844
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4709
4845
|
- @return {string[]} Normalized enabled tool names.
|
|
4710
4846
|
|
|
4711
|
-
### fn `function applyConfiguredPiUsereqTools(pi: ExtensionAPI, config: UseReqConfig): void` (
|
|
4847
|
+
### fn `function applyConfiguredPiUsereqTools(pi: ExtensionAPI, config: UseReqConfig): void` (L1015-1032)
|
|
4712
4848
|
- @brief Applies the configured active-tool enablement to the current session.
|
|
4713
4849
|
- @details Preserves non-configurable active tools, removes every configurable tool from the active set, then re-adds only configured tools that exist in the current runtime inventory. Runtime is O(t). Side effects include `pi.setActiveTools(...)`.
|
|
4714
4850
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -4716,18 +4852,18 @@ cost.
|
|
|
4716
4852
|
- @return {void} No return value.
|
|
4717
4853
|
- @satisfies REQ-009, REQ-064
|
|
4718
4854
|
|
|
4719
|
-
### fn `async function handleExtensionStatusEvent(` (
|
|
4855
|
+
### fn `async function handleExtensionStatusEvent(` (L1045-1316)
|
|
4720
4856
|
- @brief Handles one intercepted pi lifecycle hook for pi-usereq status updates.
|
|
4721
|
-
- @details Applies session-start-specific resource validation, project-config refresh, startup-tool enablement, and selected debug-tool logging before forwarding the originating hook name and payload into the shared `updateExtensionStatus(...)` pipeline. Before `agent_start`, re-verifies any prepared prompt execution session switch. On `agent_end`, dispatches configured command-notify, sound, and prompt-specific Pushover effects, logs dedicated workflow-closure diagnostics, restores the original session-backed `base-path` for every matched worktree-backed completion by reusing persisted replacement-session command contexts when event contexts omit `switchSession()`,
|
|
4857
|
+
- @details Applies session-start-specific resource validation, project-config refresh, startup-tool enablement, and selected debug-tool logging before forwarding the originating hook name and payload into the shared `updateExtensionStatus(...)` pipeline. Before `agent_start`, re-verifies any prepared prompt execution session switch. On `agent_end`, dispatches configured command-notify, sound, and prompt-specific Pushover effects, logs dedicated workflow-closure diagnostics, restores the original session-backed `base-path` for every matched worktree-backed completion by reusing persisted replacement-session command contexts when event contexts omit `switchSession()`, executes the stash-assisted merge-and-delete finalization path for every matched successful worktree-backed completion even when a later busy-command rejection already moved workflow state to `error`, emits a warning-only notification when restored `base-path` changes are reapplied after merge, tolerates stale replacement-session notification contexts after session replacement, retains the worktree plus notifies closure failure for interrupted or failed outcomes, logs selected prompt workflow transitions, and transitions workflow state through `merging`, `error`, and `idle` as required. On `session_shutdown`, captures pre-update prompt snapshots so workflow-shutdown diagnostics and same-runtime command continuation preserve the active prompt workflow state across switch-triggered rebinding, then disposes the shared controller. Runtime is dominated by configuration loading during `session_start` and git finalization during matched successful `agent_end` handling; all other hooks are O(1). Side effects include resource checks, active-tool mutation, active-session replacement, status updates, live-ticker disposal on shutdown, optional child-process spawning, outbound HTTPS requests, branch merges, worktree deletion, and optional debug-log writes.
|
|
4722
4858
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4723
4859
|
- @param[in] hookName {PiUsereqStatusHookName} Intercepted hook name.
|
|
4724
4860
|
- @param[in] event {unknown} Hook payload forwarded by pi.
|
|
4725
4861
|
- @param[in] ctx {ExtensionContext} Active extension context.
|
|
4726
4862
|
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4727
4863
|
- @return {Promise<void>} Promise resolved when hook processing completes.
|
|
4728
|
-
- @satisfies REQ-117, REQ-118, REQ-119, REQ-131, REQ-132, REQ-133, REQ-166, REQ-167, REQ-168, REQ-169, REQ-172, REQ-176, REQ-178, REQ-184, REQ-185, REQ-186, REQ-187, REQ-208, REQ-209, REQ-221, REQ-228, REQ-229, REQ-230, REQ-244, REQ-245, REQ-246, REQ-247, REQ-276, REQ-277, REQ-278, REQ-279, REQ-280
|
|
4864
|
+
- @satisfies REQ-117, REQ-118, REQ-119, REQ-131, REQ-132, REQ-133, REQ-166, REQ-167, REQ-168, REQ-169, REQ-172, REQ-176, REQ-178, REQ-184, REQ-185, REQ-186, REQ-187, REQ-208, REQ-209, REQ-221, REQ-228, REQ-229, REQ-230, REQ-244, REQ-245, REQ-246, REQ-247, REQ-276, REQ-277, REQ-278, REQ-279, REQ-280, REQ-291, REQ-292
|
|
4729
4865
|
|
|
4730
|
-
### fn `function registerExtensionStatusHooks(` (
|
|
4866
|
+
### fn `function registerExtensionStatusHooks(` (L1332-1351)
|
|
4731
4867
|
- @brief Registers shared wrappers for every supported pi lifecycle hook.
|
|
4732
4868
|
- @details Installs one generic wrapper per intercepted hook so every resource,
|
|
4733
4869
|
session, agent, model, tool, bash, and input event is routed through the
|
|
@@ -4741,7 +4877,7 @@ registered hook count. Side effects include hook registration.
|
|
|
4741
4877
|
- @return {void} No return value.
|
|
4742
4878
|
- @satisfies DES-002, REQ-113, REQ-114, REQ-115, REQ-116, REQ-117
|
|
4743
4879
|
|
|
4744
|
-
### fn `function setConfiguredPiUsereqTools(pi: ExtensionAPI, config: UseReqConfig, enabledTools: string[]): void` (
|
|
4880
|
+
### fn `function setConfiguredPiUsereqTools(pi: ExtensionAPI, config: UseReqConfig, enabledTools: string[]): void` (L1361-1364)
|
|
4745
4881
|
- @brief Replaces the configured active-tool selection and applies it immediately.
|
|
4746
4882
|
- @details Normalizes the requested tool names, stores them in config, and synchronizes the active tool set with runtime registration state. Runtime is O(n + t). Side effect: mutates config and active tools.
|
|
4747
4883
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -4749,26 +4885,26 @@ registered hook count. Side effects include hook registration.
|
|
|
4749
4885
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4750
4886
|
- @return {void} No return value.
|
|
4751
4887
|
|
|
4752
|
-
### fn `function getDebugToolToggleNames(): PiUsereqStartupToolName[]` (
|
|
4888
|
+
### fn `function getDebugToolToggleNames(): PiUsereqStartupToolName[]` (L1372-1374)
|
|
4753
4889
|
- @brief Returns the canonical debug-tool toggle order.
|
|
4754
4890
|
- @details Reuses the documented configurable-tool ordering so debug toggles list extension-owned tools before embedded tools and remain deterministic across sessions. Runtime is O(t log t). No external state is mutated.
|
|
4755
4891
|
- @return {PiUsereqStartupToolName[]} Ordered debug-tool toggle names.
|
|
4756
4892
|
- @satisfies REQ-242
|
|
4757
4893
|
|
|
4758
|
-
### fn `function resetDebugConfigToDefaults(config: UseReqConfig): void` (
|
|
4894
|
+
### fn `function resetDebugConfigToDefaults(config: UseReqConfig): void` (L1383-1391)
|
|
4759
4895
|
- @brief Restores the debug configuration subtree to its documented defaults.
|
|
4760
4896
|
- @details Resets global debug enablement, log path, workflow-state filter, dedicated workflow-event logging, and selected tool plus prompt debug toggles without mutating unrelated settings. Runtime is O(1). Side effect: mutates `config`.
|
|
4761
4897
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4762
4898
|
- @return {void} No return value.
|
|
4763
4899
|
- @satisfies REQ-236, REQ-237, REQ-238, REQ-239, REQ-195, REQ-277
|
|
4764
4900
|
|
|
4765
|
-
### fn `function formatDebugMenuSummary(config: UseReqConfig): string` (
|
|
4901
|
+
### fn `function formatDebugMenuSummary(config: UseReqConfig): string` (L1399-1405)
|
|
4766
4902
|
- @brief Formats the top-level Debug summary value.
|
|
4767
4903
|
- @details Emits the current global debug mode plus compact selected-tool and selected-prompt counts for right-aligned menu display. Runtime is O(n) in configured selector count. No external state is mutated.
|
|
4768
4904
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4769
4905
|
- @return {string} Compact debug summary string.
|
|
4770
4906
|
|
|
4771
|
-
### fn `function buildDebugMenuChoice(` (
|
|
4907
|
+
### fn `function buildDebugMenuChoice(` (L1415-1428)
|
|
4772
4908
|
- @brief Builds one debug-menu row with optional disabled styling.
|
|
4773
4909
|
- @details Applies dim styling and disables selection whenever global debug is off for all rows except the global `Debug` toggle row. Runtime is O(1). No external state is mutated.
|
|
4774
4910
|
- @param[in] choice {PiUsereqSettingsMenuChoice} Base debug-menu row.
|
|
@@ -4776,21 +4912,21 @@ registered hook count. Side effects include hook registration.
|
|
|
4776
4912
|
- @return {PiUsereqSettingsMenuChoice} Styled debug-menu row.
|
|
4777
4913
|
- @satisfies REQ-241
|
|
4778
4914
|
|
|
4779
|
-
### fn `async function selectDebugLogOnStatus(` (
|
|
4915
|
+
### fn `async function selectDebugLogOnStatus(` (L1437-1465)
|
|
4780
4916
|
- @brief Opens the workflow-state filter selector used by the Debug submenu.
|
|
4781
4917
|
- @details Exposes `any` plus each canonical workflow state through the shared settings-menu renderer and returns the selected normalized filter or `undefined` when the user cancels the submenu. Runtime depends on user interaction count. Side effects are limited to transient custom-UI rendering.
|
|
4782
4918
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
4783
4919
|
- @param[in] currentValue {DebugLogOnStatus} Current persisted workflow-state filter.
|
|
4784
4920
|
- @return {Promise<DebugLogOnStatus | undefined>} Selected workflow-state filter or `undefined` when cancelled.
|
|
4785
4921
|
|
|
4786
|
-
### fn `function buildDebugMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
4922
|
+
### fn `function buildDebugMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L1474-1550)
|
|
4787
4923
|
- @brief Builds the shared settings-menu choices for debug logging configuration.
|
|
4788
4924
|
- @details Serializes global debug controls plus workflow-state, dedicated workflow-event, per-tool, and per-prompt toggles into one submenu, deriving inventories from the canonical tool and prompt lists and dimming locked rows while debug is disabled. Runtime is O(t + p). No external state is mutated.
|
|
4789
4925
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4790
4926
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered debug-menu choices.
|
|
4791
4927
|
- @satisfies REQ-240, REQ-241, REQ-242, REQ-243, REQ-193, REQ-277
|
|
4792
4928
|
|
|
4793
|
-
### fn `async function configureDebugMenu(` (
|
|
4929
|
+
### fn `async function configureDebugMenu(` (L1560-1729)
|
|
4794
4930
|
- @brief Runs the interactive Debug submenu.
|
|
4795
4931
|
- @details Lets the user toggle global debug enablement, edit debug file and workflow filters, toggle dedicated workflow-event logging, mutate per-tool and per-prompt debug selectors, and restore subtree defaults while preserving row focus across re-renders. Runtime depends on user interaction count. Side effects include UI updates and config mutation.
|
|
4796
4932
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
@@ -4798,45 +4934,45 @@ registered hook count. Side effects include hook registration.
|
|
|
4798
4934
|
- @return {Promise<void>} Promise resolved when the submenu closes.
|
|
4799
4935
|
- @satisfies REQ-236, REQ-237, REQ-238, REQ-239, REQ-240, REQ-241, REQ-242, REQ-243, REQ-192, REQ-193, REQ-195, REQ-277
|
|
4800
4936
|
|
|
4801
|
-
- type `type PiNotifyBooleanConfigKey =` (
|
|
4937
|
+
- type `type PiNotifyBooleanConfigKey =` (L1735)
|
|
4802
4938
|
- @brief Represents one persisted boolean notification-setting key.
|
|
4803
4939
|
- @details Restricts menu toggles to the global enable flags and completed/interrupted/failed event toggles used by command-notify, sound, and Pushover configuration. Compile-time only and introduces no runtime cost.
|
|
4804
|
-
- type `type PiNotifyEventBooleanConfigKey = Exclude<` (
|
|
4940
|
+
- type `type PiNotifyEventBooleanConfigKey = Exclude<` (L1752)
|
|
4805
4941
|
- @brief Represents one persisted boolean notification event-toggle key.
|
|
4806
4942
|
- @details Restricts shared event-submenu mutation helpers to completed/interrupted/failed toggles and excludes global enable flags. Compile-time only and introduces no runtime cost.
|
|
4807
|
-
- type `type PiNotifyEventId = "completed" | "interrupted" | "failed";` (
|
|
4943
|
+
- type `type PiNotifyEventId = "completed" | "interrupted" | "failed";` (L1761)
|
|
4808
4944
|
- @brief Represents one shared prompt-end event identifier used by notification menus.
|
|
4809
4945
|
- @details Restricts event-submenu rendering to the canonical completed/interrupted/failed domain shared by command-notify, sound, and Pushover routing. Compile-time only and introduces no runtime cost.
|
|
4810
|
-
### iface `interface PiNotifyEventRowDefinition` (
|
|
4946
|
+
### iface `interface PiNotifyEventRowDefinition` (L1767-1771)
|
|
4811
4947
|
- @brief Describes one shared prompt-end event row rendered inside notification event submenus.
|
|
4812
4948
|
- @details Binds one canonical event identifier to the human-readable label and terminal-outcome description reused across command-notify, sound, and Pushover event menus. The interface is compile-time only and introduces no runtime cost.
|
|
4813
4949
|
|
|
4814
|
-
### iface `interface PiNotifyEventMenuDefinition` (
|
|
4950
|
+
### iface `interface PiNotifyEventMenuDefinition` (L1777-1783)
|
|
4815
4951
|
- @brief Describes one notification-system event submenu contract.
|
|
4816
4952
|
- @details Binds the top-level launcher row, submenu title, toast prefix, and completed/interrupted/failed config keys for one notification transport. The interface is compile-time only and introduces no runtime cost.
|
|
4817
4953
|
|
|
4818
|
-
### fn `function togglePiNotifyFlag(config: UseReqConfig, key: PiNotifyBooleanConfigKey): boolean` (
|
|
4954
|
+
### fn `function togglePiNotifyFlag(config: UseReqConfig, key: PiNotifyBooleanConfigKey): boolean` (L1792-1795)
|
|
4819
4955
|
- @brief Flips one persisted boolean notification setting.
|
|
4820
4956
|
- @details Negates the selected configuration flag in place and returns the resulting boolean value so callers can emit deterministic UI feedback. Runtime is O(1). Side effect: mutates `config`.
|
|
4821
4957
|
- @param[in] key {PiNotifyBooleanConfigKey} Boolean configuration key to toggle.
|
|
4822
4958
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4823
4959
|
- @return {boolean} Next enabled state.
|
|
4824
4960
|
|
|
4825
|
-
### fn `function resetPiNotifyConfigToDefaults(config: UseReqConfig): void` (
|
|
4961
|
+
### fn `function resetPiNotifyConfigToDefaults(config: UseReqConfig): void` (L1804-1828)
|
|
4826
4962
|
- @brief Restores notification-related settings to their documented defaults.
|
|
4827
4963
|
- @details Copies the command-notify, sound, and Pushover configuration subtree from a fresh default config into the supplied mutable project config. Runtime is O(1). Side effect: mutates `config`.
|
|
4828
4964
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4829
4965
|
- @return {void} No return value.
|
|
4830
4966
|
- @satisfies REQ-174, REQ-178, REQ-184, REQ-195, REQ-196
|
|
4831
4967
|
|
|
4832
|
-
### fn `function formatPiNotifyPushoverPriority(priority: PiNotifyPushoverPriority): string` (
|
|
4968
|
+
### fn `function formatPiNotifyPushoverPriority(priority: PiNotifyPushoverPriority): string` (L1837-1839)
|
|
4833
4969
|
- @brief Formats one persisted Pushover priority for menu display.
|
|
4834
4970
|
- @details Maps the canonical `0|1` priority domain to deterministic `Normal|High` labels reused by the Pushover configuration UI. Runtime is O(1). No external state is mutated.
|
|
4835
4971
|
- @param[in] priority {PiNotifyPushoverPriority} Persisted Pushover priority.
|
|
4836
4972
|
- @return {string} Menu-display label.
|
|
4837
4973
|
- @satisfies REQ-172
|
|
4838
4974
|
|
|
4839
|
-
### fn `function formatPiNotifyEventMenuSummary(` (
|
|
4975
|
+
### fn `function formatPiNotifyEventMenuSummary(` (L1923-1931)
|
|
4840
4976
|
- @brief Formats the top-level summary value for one notification event submenu.
|
|
4841
4977
|
- @details Counts enabled completed/interrupted/failed toggles for the selected transport and renders the result as `n/3 on` for right-aligned menu display. Runtime is O(1). No external state is mutated.
|
|
4842
4978
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
@@ -4844,7 +4980,7 @@ registered hook count. Side effects include hook registration.
|
|
|
4844
4980
|
- @return {string} Compact enabled-toggle summary.
|
|
4845
4981
|
- @satisfies REQ-198
|
|
4846
4982
|
|
|
4847
|
-
### fn `function buildPiNotifyEventLauncherChoice(` (
|
|
4983
|
+
### fn `function buildPiNotifyEventLauncherChoice(` (L1941-1951)
|
|
4848
4984
|
- @brief Builds the top-level launcher row for one notification event submenu.
|
|
4849
4985
|
- @details Reuses the shared completed/interrupted/failed summary renderer so the `Notifications` menu can expose dedicated event editors for command-notify, sound, and Pushover in a uniform shape. Runtime is O(1). No external state is mutated.
|
|
4850
4986
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
@@ -4852,15 +4988,15 @@ registered hook count. Side effects include hook registration.
|
|
|
4852
4988
|
- @return {PiUsereqSettingsMenuChoice} Launcher row for the selected event submenu.
|
|
4853
4989
|
- @satisfies REQ-181, REQ-183, REQ-165, REQ-198
|
|
4854
4990
|
|
|
4855
|
-
### fn `function buildPiNotifyEventMenuChoices(` (
|
|
4991
|
+
### fn `function buildPiNotifyEventMenuChoices(` (L1961-1977)
|
|
4856
4992
|
- @brief Builds the shared settings-menu choices for one notification event submenu.
|
|
4857
|
-
- @details Serializes completed/interrupted/failed rows with right-aligned `on|off` values, then appends `Reset defaults`
|
|
4993
|
+
- @details Serializes completed/interrupted/failed rows with right-aligned `on|off` values, then appends a value-less `Reset defaults` row for submenu-scoped mutation control. Runtime is O(1). No external state is mutated.
|
|
4858
4994
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4859
4995
|
- @param[in] eventMenu {PiNotifyEventMenuDefinition} Notification-system event submenu contract.
|
|
4860
4996
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered event-submenu choice vector.
|
|
4861
4997
|
- @satisfies REQ-188, REQ-193, REQ-198
|
|
4862
4998
|
|
|
4863
|
-
### fn `function resetPiNotifyEventMenuToDefaults(` (
|
|
4999
|
+
### fn `function resetPiNotifyEventMenuToDefaults(` (L1987-1995)
|
|
4864
5000
|
- @brief Restores one notification event submenu to its documented defaults.
|
|
4865
5001
|
- @details Copies only the completed/interrupted/failed toggles referenced by the supplied submenu contract from a fresh default config into the mutable project config. Runtime is O(1). Side effect: mutates `config`.
|
|
4866
5002
|
- @param[in] eventMenu {PiNotifyEventMenuDefinition} Notification-system event submenu contract.
|
|
@@ -4868,7 +5004,7 @@ registered hook count. Side effects include hook registration.
|
|
|
4868
5004
|
- @return {void} No return value.
|
|
4869
5005
|
- @satisfies REQ-174, REQ-178, REQ-184, REQ-195
|
|
4870
5006
|
|
|
4871
|
-
### fn `function resolvePiNotifyEventLabel(` (
|
|
5007
|
+
### fn `function resolvePiNotifyEventLabel(` (L2005-2012)
|
|
4872
5008
|
- @brief Resolves the human-readable event label for one event-toggle config key.
|
|
4873
5009
|
- @details Matches the supplied config key against the submenu contract and returns the corresponding completed/interrupted/failed menu label for deterministic notification toasts. Runtime is O(1). No external state is mutated.
|
|
4874
5010
|
- @param[in] key {PiNotifyEventBooleanConfigKey} Event-toggle configuration key.
|
|
@@ -4876,7 +5012,7 @@ registered hook count. Side effects include hook registration.
|
|
|
4876
5012
|
- @return {string} Human-readable event label.
|
|
4877
5013
|
- @satisfies REQ-188, REQ-198
|
|
4878
5014
|
|
|
4879
|
-
### fn `async function configurePiNotifyEventMenu(` (
|
|
5015
|
+
### fn `async function configurePiNotifyEventMenu(` (L2023-2099)
|
|
4880
5016
|
- @brief Runs one dedicated notification event submenu.
|
|
4881
5017
|
- @details Reuses the shared settings-menu renderer to toggle completed/interrupted/failed delivery flags, preserve row focus, and apply submenu-scoped reset semantics for command-notify, sound, or Pushover events. Runtime depends on user interaction count. Side effects include UI updates and config mutation.
|
|
4882
5018
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
@@ -4885,73 +5021,97 @@ registered hook count. Side effects include hook registration.
|
|
|
4885
5021
|
- @return {Promise<void>} Promise resolved when the submenu closes.
|
|
4886
5022
|
- @satisfies REQ-188, REQ-192, REQ-193, REQ-195, REQ-198
|
|
4887
5023
|
|
|
4888
|
-
### fn `function buildPiNotifyPushoverRows(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5024
|
+
### fn `function buildPiNotifyPushoverRows(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L2108-2158)
|
|
4889
5025
|
- @brief Builds the direct Pushover rows rendered inside `Notifications`.
|
|
4890
|
-
- @details Serializes the global enable flag, shared-event submenu launcher, priority, title, text, and credential rows into right-valued menu items appended after the sound-command rows, dims and disables the enable row until both credentials are populated, and escapes control characters for the single-line `Pushover text` value. Runtime is O(n) in the rendered text-template length. No external state is mutated.
|
|
5026
|
+
- @details Serializes the global enable flag, shared-event submenu launcher, priority, title, text, and credential rows into right-valued menu items appended after the sound-command rows, dims and disables the enable row until both credentials are populated, renders the locked value as `configure user/token keys first`, and escapes control characters for the single-line `Pushover text` value. Runtime is O(n) in the rendered text-template length. No external state is mutated.
|
|
4891
5027
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4892
5028
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered direct Pushover rows.
|
|
4893
5029
|
- @satisfies REQ-163, REQ-165, REQ-172, REQ-184, REQ-185, REQ-198, REQ-234, REQ-235
|
|
4894
5030
|
|
|
4895
|
-
### fn `async function selectPiNotifyPushoverPriority(` (
|
|
5031
|
+
### fn `async function selectPiNotifyPushoverPriority(` (L2168-2196)
|
|
4896
5032
|
- @brief Opens the shared settings-menu selector for Pushover priority.
|
|
4897
|
-
- @details Reuses the pi-usereq settings-menu renderer so Pushover priority selection remains stylistically aligned with the notification menus and appends subtree-local `Reset defaults`
|
|
5033
|
+
- @details Reuses the pi-usereq settings-menu renderer so Pushover priority selection remains stylistically aligned with the notification menus and appends a value-less subtree-local `Reset defaults` row. Runtime depends on user interaction count. Side effects are limited to transient custom-UI rendering.
|
|
4898
5034
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
4899
5035
|
- @param[in] currentPriority {PiNotifyPushoverPriority} Persisted priority value.
|
|
4900
5036
|
- @return {Promise<PiNotifyPushoverPriority | "reset-defaults" | undefined>} Selected priority, reset action, or `undefined` when cancelled.
|
|
4901
5037
|
- @satisfies REQ-172, REQ-192
|
|
4902
5038
|
|
|
4903
|
-
### fn `function buildPiNotifyMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5039
|
+
### fn `function buildPiNotifyMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L2205-2263)
|
|
4904
5040
|
- @brief Builds the shared settings-menu choices for notification configuration.
|
|
4905
|
-
- @details Serializes command-notify, sound, and Pushover blocks with dedicated shared-event submenu launchers so the settings-menu renderer can expose one unified but modular configuration surface, including locked Pushover enablement and escaped single-line rendering for `Pushover text`. Runtime is O(n) in the longest rendered command or text field. No external state is mutated.
|
|
5041
|
+
- @details Serializes command-notify, sound, and Pushover blocks with dedicated shared-event submenu launchers so the settings-menu renderer can expose one unified but modular configuration surface, including locked Pushover enablement, persisted boot-sound rows that stay decoupled from the active runtime sound level, and escaped single-line rendering for `Pushover text`. Runtime is O(n) in the longest rendered command or text field. No external state is mutated.
|
|
4906
5042
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4907
5043
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered notification-menu choice vector.
|
|
4908
|
-
- @satisfies REQ-137, REQ-149, REQ-150, REQ-151, REQ-152, REQ-163, REQ-164, REQ-165, REQ-172, REQ-179, REQ-181, REQ-183, REQ-188, REQ-193, REQ-198, REQ-234, REQ-235
|
|
5044
|
+
- @satisfies REQ-137, REQ-149, REQ-150, REQ-151, REQ-152, REQ-163, REQ-164, REQ-165, REQ-172, REQ-179, REQ-181, REQ-183, REQ-188, REQ-193, REQ-198, REQ-234, REQ-235, REQ-289
|
|
4909
5045
|
|
|
4910
|
-
### fn `async function selectPiNotifySoundLevel(` (
|
|
4911
|
-
- @brief Opens the shared settings-menu selector for the
|
|
4912
|
-
- @details Reuses the pi-usereq settings-menu renderer so sound
|
|
5046
|
+
### fn `async function selectPiNotifySoundLevel(` (L2273-2313)
|
|
5047
|
+
- @brief Opens the shared settings-menu selector for the persisted boot sound level.
|
|
5048
|
+
- @details Reuses the pi-usereq settings-menu renderer so boot-sound selection remains stylistically aligned with the notification menu, keeps the active runtime sound level unchanged, and appends a value-less subtree-local `Reset defaults` row. Runtime depends on user interaction count. Side effects are limited to transient custom-UI rendering.
|
|
4913
5049
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
4914
|
-
- @param[in] currentLevel {PiNotifySoundLevel}
|
|
4915
|
-
- @return {Promise<PiNotifySoundLevel | "reset-defaults" | undefined>} Selected sound level, reset action, or `undefined` when cancelled.
|
|
4916
|
-
- @satisfies REQ-131, REQ-179, REQ-192
|
|
5050
|
+
- @param[in] currentLevel {PiNotifySoundLevel} Persisted boot sound level.
|
|
5051
|
+
- @return {Promise<PiNotifySoundLevel | "reset-defaults" | undefined>} Selected boot sound level, reset action, or `undefined` when cancelled.
|
|
5052
|
+
- @satisfies REQ-131, REQ-179, REQ-192, REQ-289
|
|
4917
5053
|
|
|
4918
|
-
### fn `async function configurePiNotifyMenu(` (
|
|
5054
|
+
### fn `async function configurePiNotifyMenu(` (L2323-2609)
|
|
4919
5055
|
- @brief Runs the interactive notification-configuration menu.
|
|
4920
|
-
- @details Exposes command-notify, sound, and Pushover controls through the shared settings-menu renderer, delegates completed/interrupted/failed toggles to dedicated event submenus, keeps `Enable pushover` locked until both credentials are populated, decodes escaped control-sequence input for `Pushover text`, and preserves row focus across menu re-renders. Runtime depends on user interaction count. Side effects include UI updates and config mutation.
|
|
5056
|
+
- @details Exposes command-notify, sound, and Pushover controls through the shared settings-menu renderer, delegates completed/interrupted/failed toggles to dedicated event submenus, persists boot-sound changes without altering the active runtime sound level, keeps `Enable pushover` locked until both credentials are populated, decodes escaped control-sequence input for `Pushover text`, and preserves row focus across menu re-renders. Runtime depends on user interaction count. Side effects include UI updates and config mutation.
|
|
4921
5057
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
4922
5058
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
4923
5059
|
- @return {Promise<boolean>} `true` when the sound-toggle shortcut changed.
|
|
4924
|
-
- @satisfies REQ-131, REQ-133, REQ-134, REQ-137, REQ-163, REQ-164, REQ-165, REQ-172, REQ-179, REQ-181, REQ-183, REQ-184, REQ-188, REQ-192, REQ-193, REQ-195, REQ-196, REQ-198, REQ-234, REQ-235
|
|
5060
|
+
- @satisfies REQ-131, REQ-133, REQ-134, REQ-137, REQ-163, REQ-164, REQ-165, REQ-172, REQ-179, REQ-181, REQ-183, REQ-184, REQ-188, REQ-192, REQ-193, REQ-195, REQ-196, REQ-198, REQ-234, REQ-235, REQ-288, REQ-289
|
|
4925
5061
|
|
|
4926
|
-
### fn `function registerPiNotifyShortcut(` (
|
|
5062
|
+
### fn `function registerPiNotifyShortcut(` (L2624-2647)
|
|
4927
5063
|
- @brief Registers the configurable notification-sound shortcut when supported.
|
|
4928
5064
|
- @details Loads the current project config, registers one raw pi shortcut when
|
|
4929
|
-
the runtime exposes `registerShortcut(...)`, cycles
|
|
4930
|
-
invocation,
|
|
4931
|
-
notification. Runtime is O(1) for registration
|
|
4932
|
-
use. Side effects include shortcut
|
|
4933
|
-
updates.
|
|
5065
|
+
the runtime exposes `registerShortcut(...)`, cycles only the active runtime
|
|
5066
|
+
sound level on invocation, leaves `.pi-usereq.json` unchanged, refreshes the
|
|
5067
|
+
status bar, and emits one info notification. Runtime is O(1) for registration
|
|
5068
|
+
plus one status update per shortcut use. Side effects include shortcut
|
|
5069
|
+
registration and status updates.
|
|
5070
|
+
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
5071
|
+
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
5072
|
+
- @return {void} No return value.
|
|
5073
|
+
- @satisfies REQ-134, REQ-180, REQ-286, REQ-287
|
|
5074
|
+
|
|
5075
|
+
### fn `function resolveReqResetPromptRequest(` (L2655-2681)
|
|
5076
|
+
- @brief Resolves the prompt execution plan targeted by `req-reset` recovery.
|
|
5077
|
+
- @details Prefers the current in-memory active request, then the current in-memory pending request, then the process-scoped persisted prompt runtime state so the dedicated reset command can recover from same-host unclean prompt termination after session replacement. Runtime is O(1). No external state is mutated.
|
|
5078
|
+
- @param[in] statusController {PiUsereqStatusController} Mutable status controller.
|
|
5079
|
+
- @return {PromptCommandExecutionPlan | undefined} Recoverable prompt execution plan when one remains available.
|
|
5080
|
+
|
|
5081
|
+
### fn `const isWorktreeBacked = (request: PromptCommandExecutionPlan | undefined): request is PromptCommandExecutionPlan =>` (L2658-2665)
|
|
5082
|
+
|
|
5083
|
+
### fn `function registerReqResetCommand(` (L2691-2745)
|
|
5084
|
+
- @brief Registers the specialized `req-reset` slash command.
|
|
5085
|
+
- @details Registers the non-agentic prompt-recovery command that accepts any current workflow state, reuses persisted prompt runtime state when available, restores the original session-backed `base-path`, force-removes matching generated worktrees plus branches, clears recoverable prompt state when restoration succeeds, and notifies pi without starting an LLM session or creating a worktree. Runtime is dominated by session restoration plus git cleanup. Side effects include command registration, status-controller mutation, active-session replacement, worktree deletion, branch deletion, and user notifications.
|
|
5086
|
+
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
5087
|
+
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
5088
|
+
- @return {void} No return value.
|
|
5089
|
+
- @satisfies REQ-304, REQ-305, REQ-306, REQ-307, REQ-308, REQ-309, REQ-310, REQ-311, REQ-312, REQ-313
|
|
5090
|
+
|
|
5091
|
+
### fn `function registerReqReferencesCommand(` (L2755-2795)
|
|
5092
|
+
- @brief Registers the specialized `req-references` slash command.
|
|
5093
|
+
- @details Registers the non-agentic references-maintenance command that rejects non-`idle` invocations by transitioning workflow state to `error` before direct execution, otherwise reuses slash-command-owned git validation, transitions workflow state through `checking|running|idle`, regenerates `REFERENCES.md` directly from configured source directories, stages only the generated file, creates the fixed-message git commit, verifies repository cleanliness, and notifies pi without starting an LLM session or creating a worktree. Runtime is dominated by git subprocess execution plus source-summary generation. Side effects include command registration, status-controller mutation, filesystem writes, git index/history mutation, and user notifications.
|
|
4934
5094
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4935
5095
|
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4936
5096
|
- @return {void} No return value.
|
|
4937
|
-
- @satisfies REQ-
|
|
5097
|
+
- @satisfies REQ-200, REQ-221, REQ-224, REQ-298, REQ-299, REQ-300, REQ-301, REQ-302, REQ-303
|
|
4938
5098
|
|
|
4939
|
-
### fn `function registerPromptCommands(` (
|
|
4940
|
-
- @brief Registers bundled prompt commands with the extension.
|
|
4941
|
-
- @details Creates one `req-<prompt>` command per bundled prompt name. Each handler rejects non-`idle` workflow state, transitions the shared workflow state through `checking`, `error`, and `running`, runs dedicated prompt-command git and required-doc preflight checks, optionally prepares a dedicated worktree execution plan using the active session directory, persists the prompt metadata needed for switch-triggered rebinding, switches the active session to the verified execution cwd before prompt handoff, logs dedicated workflow-activation diagnostics, renders the prompt, starts prompt delivery into the forked active session, records `running` immediately after delivery handoff begins, and then awaits the wrapped prompt-delivery promise whose stale post-restore rejections are suppressed. Runtime is O(p) for registration; handler cost depends on prompt preflight, worktree preparation, session switching, prompt rendering, prompt dispatch, and optional debug logging. Side effects include command registration, status-controller mutation, worktree creation, active-session replacement, optional worktree rollback, user-message delivery during execution, and optional debug-log writes.
|
|
5099
|
+
### fn `function registerPromptCommands(` (L2805-2921)
|
|
5100
|
+
- @brief Registers bundled prompt-backed commands with the extension.
|
|
5101
|
+
- @details Creates one prompt-template-backed `req-<prompt>` command per bundled prompt name. Each handler rejects non-`idle` workflow state by transitioning the shared workflow state to `error` before command-side preflight, otherwise transitions the shared workflow state through `checking`, `error`, and `running`, runs dedicated prompt-command git and required-doc preflight checks, optionally prepares a dedicated worktree execution plan using the active session directory, persists the prompt metadata needed for switch-triggered rebinding, switches the active session to the verified execution cwd before prompt handoff, logs dedicated workflow-activation diagnostics, renders the prompt, starts prompt delivery into the forked active session, records `running` immediately after delivery handoff begins, and then awaits the wrapped prompt-delivery promise whose stale post-restore rejections are suppressed. Runtime is O(p) for registration; handler cost depends on prompt preflight, worktree preparation, session switching, prompt rendering, prompt dispatch, and optional debug logging. Side effects include command registration, status-controller mutation, worktree creation, active-session replacement, optional worktree rollback, user-message delivery during execution, and optional debug-log writes.
|
|
4942
5102
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4943
5103
|
- @param[in,out] statusController {PiUsereqStatusController} Mutable status controller.
|
|
4944
5104
|
- @return {void} No return value.
|
|
4945
5105
|
- @satisfies REQ-004, REQ-067, REQ-068, REQ-169, REQ-200, REQ-201, REQ-202, REQ-203, REQ-206, REQ-207, REQ-219, REQ-220, REQ-221, REQ-224, REQ-225, REQ-226, REQ-227, REQ-245, REQ-246, REQ-247, REQ-277, REQ-281
|
|
4946
5106
|
|
|
4947
|
-
### fn `function registerAgentTools(pi: ExtensionAPI): void` (
|
|
5107
|
+
### fn `function registerAgentTools(pi: ExtensionAPI): void` (L2931-3230)
|
|
4948
5108
|
- @brief Registers pi-usereq agent tools exposed to the model.
|
|
4949
5109
|
- @details Defines the tool schemas, prompt metadata, and execution handlers that bridge extension tool calls into tool-runner operations without registering duplicate custom slash commands for the same capabilities. Runtime is O(t) for registration; execution cost depends on the selected tool. Side effects include tool registration.
|
|
4950
5110
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4951
5111
|
- @return {void} No return value.
|
|
4952
|
-
- @satisfies REQ-005, REQ-010, REQ-011, REQ-014, REQ-017, REQ-044, REQ-069, REQ-070, REQ-071, REQ-072, REQ-073, REQ-074, REQ-075, REQ-076, REQ-077, REQ-078, REQ-079, REQ-080, REQ-089, REQ-090, REQ-091, REQ-092, REQ-093, REQ-094, REQ-095, REQ-096, REQ-097, REQ-098, REQ-099, REQ-100, REQ-101, REQ-102
|
|
5112
|
+
- @satisfies REQ-005, REQ-010, REQ-011, REQ-014, REQ-017, REQ-044, REQ-069, REQ-070, REQ-071, REQ-072, REQ-073, REQ-074, REQ-075, REQ-076, REQ-077, REQ-078, REQ-079, REQ-080, REQ-089, REQ-090, REQ-091, REQ-092, REQ-093, REQ-094, REQ-095, REQ-096, REQ-097, REQ-098, REQ-099, REQ-100, REQ-101, REQ-102, REQ-293, REQ-294, REQ-295, REQ-296, REQ-297
|
|
4953
5113
|
|
|
4954
|
-
### fn `function buildPiUsereqToolsMenuChoices(pi: ExtensionAPI, config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5114
|
+
### fn `function buildPiUsereqToolsMenuChoices(pi: ExtensionAPI, config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3275-3300)
|
|
4955
5115
|
- @brief Builds the shared settings-menu choices for startup-tool management.
|
|
4956
5116
|
- @details Serializes startup-tool actions into right-valued menu rows consumed by the shared settings-menu renderer while omitting the removed status-reference action. Runtime is O(t) in configurable-tool count. No external state is mutated.
|
|
4957
5117
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -4959,15 +5119,15 @@ updates.
|
|
|
4959
5119
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered startup-tool menu choices.
|
|
4960
5120
|
- @satisfies REQ-007, REQ-150, REQ-151, REQ-152, REQ-153, REQ-154, REQ-193
|
|
4961
5121
|
|
|
4962
|
-
### fn `function buildPiUsereqToolToggleChoices(pi: ExtensionAPI, config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5122
|
+
### fn `function buildPiUsereqToolToggleChoices(pi: ExtensionAPI, config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3310-3324)
|
|
4963
5123
|
- @brief Builds the shared settings-menu choices for per-tool startup toggles.
|
|
4964
|
-
- @details Exposes every configurable startup tool as one row whose right-side value reports the current enabled state, preserves the documented custom/files/embedded/default-disabled ordering, and appends subtree-local `Reset defaults`
|
|
5124
|
+
- @details Exposes every configurable startup tool as one row whose right-side value reports the current enabled state, preserves the documented custom/files/embedded/default-disabled ordering, and appends a value-less subtree-local `Reset defaults` row. Runtime is O(t) in configurable-tool count. No external state is mutated.
|
|
4965
5125
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
4966
5126
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4967
5127
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered per-tool toggle choices.
|
|
4968
5128
|
- @satisfies REQ-007, REQ-151, REQ-152, REQ-153, REQ-154, REQ-231, REQ-232
|
|
4969
5129
|
|
|
4970
|
-
### fn `async function configurePiUsereqToolsMenu(` (
|
|
5130
|
+
### fn `async function configurePiUsereqToolsMenu(` (L3335-3452)
|
|
4971
5131
|
- @brief Runs the interactive active-tool configuration menu.
|
|
4972
5132
|
- @details Synchronizes runtime active tools with persisted config, renders startup-tool actions through the shared settings-menu UI, preserves the documented per-tool ordering, and updates configuration state in response to selections until the user exits. Runtime depends on user interaction count. Side effects include UI updates, active-tool changes, and config mutation.
|
|
4973
5133
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -4976,58 +5136,58 @@ updates.
|
|
|
4976
5136
|
- @return {Promise<void>} Promise resolved when the menu closes.
|
|
4977
5137
|
- @satisfies REQ-007, REQ-063, REQ-064, REQ-150, REQ-151, REQ-152, REQ-153, REQ-154, REQ-193, REQ-231, REQ-232
|
|
4978
5138
|
|
|
4979
|
-
### fn `function getStaticCheckLanguageConfigForMenu(` (
|
|
5139
|
+
### fn `function getStaticCheckLanguageConfigForMenu(` (L3461-3466)
|
|
4980
5140
|
- @brief Resolves one static-check language config for menu rendering.
|
|
4981
5141
|
- @details Returns the configured per-language static-check object when present and otherwise synthesizes a disabled empty-language object so menu code can render all supported languages deterministically. Runtime is O(1). No external state is mutated.
|
|
4982
5142
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4983
5143
|
- @param[in] language {string} Canonical language name.
|
|
4984
5144
|
- @return {StaticCheckLanguageConfig} Resolved per-language config object.
|
|
4985
5145
|
|
|
4986
|
-
### fn `function countConfiguredStaticCheckLanguages(config: UseReqConfig): number` (
|
|
5146
|
+
### fn `function countConfiguredStaticCheckLanguages(config: UseReqConfig): number` (L3474-3476)
|
|
4987
5147
|
- @brief Counts languages that currently expose at least one configured checker.
|
|
4988
5148
|
- @details Treats configured-but-disabled languages as configured when their checker list is non-empty so removal actions remain deterministic. Runtime is O(l). No external state is mutated.
|
|
4989
5149
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4990
5150
|
- @return {number} Number of languages with at least one configured checker.
|
|
4991
5151
|
|
|
4992
|
-
### fn `function countEnabledStaticCheckLanguages(config: UseReqConfig): number` (
|
|
5152
|
+
### fn `function countEnabledStaticCheckLanguages(config: UseReqConfig): number` (L3484-3486)
|
|
4993
5153
|
- @brief Counts languages whose static-check enable flag is on.
|
|
4994
5154
|
- @details Counts only languages whose persisted per-language config explicitly sets `enabled=enable`, regardless of checker count. Runtime is O(l). No external state is mutated.
|
|
4995
5155
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
4996
5156
|
- @return {number} Number of enabled languages.
|
|
4997
5157
|
|
|
4998
|
-
### fn `function resetStaticCheckConfig(config: UseReqConfig): void` (
|
|
5158
|
+
### fn `function resetStaticCheckConfig(config: UseReqConfig): void` (L3495-3497)
|
|
4999
5159
|
- @brief Restores the documented static-check default configuration.
|
|
5000
5160
|
- @details Replaces the mutable config subtree with a fresh clone of the documented per-language defaults so menu reset actions restore both enable flags and checker lists in one step. Runtime is O(l + c). Side effect: mutates `config`.
|
|
5001
5161
|
- @param[in,out] config {UseReqConfig} Mutable configuration object.
|
|
5002
5162
|
- @return {void} No return value.
|
|
5003
5163
|
- @satisfies REQ-250, REQ-251, REQ-252
|
|
5004
5164
|
|
|
5005
|
-
### fn `function formatStaticCheckLanguagesSummary(config: UseReqConfig): string` (
|
|
5165
|
+
### fn `function formatStaticCheckLanguagesSummary(config: UseReqConfig): string` (L3505-3507)
|
|
5006
5166
|
- @brief Summarizes enabled and configured static-check languages.
|
|
5007
5167
|
- @details Counts enabled languages and languages with at least one checker, then emits one compact summary string suitable for the top-level configuration menu. Runtime is O(l). No external state is mutated.
|
|
5008
5168
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5009
5169
|
- @return {string} Compact summary string.
|
|
5010
5170
|
|
|
5011
|
-
### fn `function buildStaticCheckMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5171
|
+
### fn `function buildStaticCheckMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3516-3548)
|
|
5012
5172
|
- @brief Builds the shared settings-menu choices for static-check management.
|
|
5013
5173
|
- @details Serializes guided Command-oriented add and remove actions, renders one direct on/off toggle row for every supported language, and appends canonical terminal rows while omitting raw-spec and reference-only actions. Runtime is O(l). No external state is mutated.
|
|
5014
5174
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5015
5175
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered static-check menu choices.
|
|
5016
5176
|
- @satisfies REQ-008, REQ-150, REQ-151, REQ-152, REQ-153, REQ-154, REQ-160, REQ-161, REQ-193, REQ-248
|
|
5017
5177
|
|
|
5018
|
-
### fn `function buildSupportedStaticCheckLanguageChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5178
|
+
### fn `function buildSupportedStaticCheckLanguageChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3556-3573)
|
|
5019
5179
|
- @brief Builds the shared settings-menu choices for supported static-check languages.
|
|
5020
5180
|
- @details Exposes every supported language as one row whose right-side value reports extensions, enablement, and configured checker count for guided Command configuration flows, then appends subtree-local terminal rows. Runtime is O(l). No external state is mutated.
|
|
5021
5181
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5022
5182
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered language-choice vector.
|
|
5023
5183
|
|
|
5024
|
-
### fn `function buildConfiguredStaticCheckLanguageChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5184
|
+
### fn `function buildConfiguredStaticCheckLanguageChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3581-3598)
|
|
5025
5185
|
- @brief Builds the shared settings-menu choices for configured static-check languages.
|
|
5026
5186
|
- @details Exposes only languages whose checker lists are non-empty so removal remains deterministic, then appends subtree-local terminal rows. Runtime is O(l). No external state is mutated.
|
|
5027
5187
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5028
5188
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered configured-language vector.
|
|
5029
5189
|
|
|
5030
|
-
### fn `async function configureStaticCheckMenu(` (
|
|
5190
|
+
### fn `async function configureStaticCheckMenu(` (L3608-3754)
|
|
5031
5191
|
- @brief Runs the interactive static-check configuration menu.
|
|
5032
5192
|
- @details Lets the user add Command entries by guided prompts, remove configured language entries, toggle direct per-language enable flags, and reset the subtree to documented defaults through the shared settings-menu renderer until the user exits. Runtime depends on user interaction count. Side effects include UI updates and config mutation.
|
|
5033
5193
|
- @param[in] ctx {ExtensionCommandContext} Active command context.
|
|
@@ -5035,7 +5195,7 @@ updates.
|
|
|
5035
5195
|
- @return {Promise<void>} Promise resolved when the menu closes.
|
|
5036
5196
|
- @satisfies REQ-008, REQ-151, REQ-152, REQ-153, REQ-154, REQ-160, REQ-161, REQ-193, REQ-195, REQ-248, REQ-253
|
|
5037
5197
|
|
|
5038
|
-
### fn `function buildPiUsereqMenuChoices(` (
|
|
5198
|
+
### fn `function buildPiUsereqMenuChoices(` (L3764-3856)
|
|
5039
5199
|
- @brief Builds the shared settings-menu choices for the top-level pi-usereq configuration UI.
|
|
5040
5200
|
- @details Serializes primary configuration actions into right-valued menu rows consumed by the shared settings-menu renderer, including automatic git-commit mode, effective prompt-command worktree state, notification summary, debug summary, locked worktree rows when automatic git commit is disabled, and the display-only config path beside `show-config`. Runtime is O(s) in source-directory count. No external state is mutated.
|
|
5041
5201
|
- @param[in] cwd {string} Current working directory.
|
|
@@ -5043,21 +5203,21 @@ updates.
|
|
|
5043
5203
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered top-level menu choices.
|
|
5044
5204
|
- @satisfies REQ-006, REQ-031, REQ-137, REQ-150, REQ-151, REQ-152, REQ-162, REQ-190, REQ-191, REQ-197, REQ-204, REQ-205, REQ-212, REQ-215, REQ-216, REQ-236, REQ-237, REQ-238, REQ-239, REQ-240
|
|
5045
5205
|
|
|
5046
|
-
### fn `function buildSrcDirMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5206
|
+
### fn `function buildSrcDirMenuChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3865-3883)
|
|
5047
5207
|
- @brief Builds the shared settings-menu choices for source-directory management.
|
|
5048
5208
|
- @details Exposes add and remove actions for `src-dir` entries through right-valued menu rows consumed by the shared settings-menu renderer. Runtime is O(s) in source-directory count. No external state is mutated.
|
|
5049
5209
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5050
5210
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered source-directory management choices.
|
|
5051
5211
|
- @satisfies REQ-006, REQ-151, REQ-152, REQ-153, REQ-154, REQ-193
|
|
5052
5212
|
|
|
5053
|
-
### fn `function buildSrcDirRemovalChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (
|
|
5213
|
+
### fn `function buildSrcDirRemovalChoices(config: UseReqConfig): PiUsereqSettingsMenuChoice[]` (L3892-3904)
|
|
5054
5214
|
- @brief Builds the shared settings-menu choices for removing one source-directory entry.
|
|
5055
|
-
- @details Exposes every configured `src-dir` entry as one removable row and appends subtree-local `Reset defaults`
|
|
5215
|
+
- @details Exposes every configured `src-dir` entry as one removable row and appends a value-less subtree-local `Reset defaults` row. Runtime is O(s) in source-directory count. No external state is mutated.
|
|
5056
5216
|
- @param[in] config {UseReqConfig} Effective project configuration.
|
|
5057
5217
|
- @return {PiUsereqSettingsMenuChoice[]} Ordered removable source-directory choices.
|
|
5058
5218
|
- @satisfies REQ-006, REQ-151, REQ-152, REQ-153, REQ-154
|
|
5059
5219
|
|
|
5060
|
-
### fn `async function configurePiUsereq(` (
|
|
5220
|
+
### fn `async function configurePiUsereq(` (L3915-4164)
|
|
5061
5221
|
- @brief Runs the top-level pi-usereq configuration menu.
|
|
5062
5222
|
- @details Loads project config, exposes docs/test/source/automatic-commit/worktree/static-check/startup-tool/notification/debug actions through the shared settings-menu renderer, forces worktree disablement when automatic git commit is disabled, prevents locked row edits, persists changes on exit, closes immediately after `Show configuration`, and refreshes the single-line status bar. Runtime depends on user interaction count. Side effects include UI updates, config writes, active-tool changes, and editor text updates.
|
|
5063
5223
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -5066,9 +5226,9 @@ updates.
|
|
|
5066
5226
|
- @return {Promise<void>} Promise resolved when configuration is saved and the menu closes.
|
|
5067
5227
|
- @satisfies REQ-006, REQ-031, REQ-137, REQ-150, REQ-151, REQ-152, REQ-153, REQ-154, REQ-162, REQ-190, REQ-191, REQ-192, REQ-194, REQ-195, REQ-204, REQ-205, REQ-212, REQ-215, REQ-216, REQ-236, REQ-237, REQ-238, REQ-239, REQ-240, REQ-241, REQ-242, REQ-243
|
|
5068
5228
|
|
|
5069
|
-
### fn `const persistConfigChange = () =>` (
|
|
5229
|
+
### fn `const persistConfigChange = () =>` (L3926-3931)
|
|
5070
5230
|
|
|
5071
|
-
### fn `function registerConfigCommands(` (
|
|
5231
|
+
### fn `function registerConfigCommands(` (L4174-4184)
|
|
5072
5232
|
- @brief Registers configuration-management commands.
|
|
5073
5233
|
- @details Adds the interactive `pi-usereq` configuration command only; the config-viewer action is now exposed exclusively inside that menu. Runtime is O(1) for registration. Side effects include command registration.
|
|
5074
5234
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
@@ -5076,110 +5236,107 @@ updates.
|
|
|
5076
5236
|
- @return {void} No return value.
|
|
5077
5237
|
- @satisfies REQ-006, REQ-031
|
|
5078
5238
|
|
|
5079
|
-
### fn `export default function piUsereqExtension(pi: ExtensionAPI): void` (
|
|
5239
|
+
### fn `export default function piUsereqExtension(pi: ExtensionAPI): void` (L4193-4203)
|
|
5080
5240
|
- @brief Registers the complete pi-usereq extension.
|
|
5081
|
-
- @details Validates installation-owned bundled resources, registers prompt and
|
|
5082
|
-
configuration commands plus agent tools, registers the configurable
|
|
5083
|
-
notification-sound shortcut when the runtime supports shortcuts, and
|
|
5084
|
-
installs shared wrappers for all supported pi lifecycle hooks so status
|
|
5085
|
-
telemetry, context usage, prompt timing, cumulative runtime, prompt-specific
|
|
5086
|
-
Pushover metadata, tool-result debug logging, and prompt-orchestration debug
|
|
5087
|
-
effects remain synchronized with runtime events. Runtime is O(h) in hook
|
|
5088
|
-
count during registration. Side effects include filesystem reads,
|
|
5089
|
-
command/tool/shortcut registration, UI updates, active-tool changes,
|
|
5090
|
-
optional debug-log writes, and timer scheduling.
|
|
5241
|
+
- @details Validates installation-owned bundled resources, registers the specialized `req-reset` and `req-references` commands plus bundled prompt-backed commands and agent tools, registers configuration commands, registers the configurable notification-sound shortcut when the runtime supports shortcuts, and installs shared wrappers for all supported pi lifecycle hooks so status telemetry, context usage, prompt timing, cumulative runtime, prompt-specific Pushover metadata, tool-result debug logging, and prompt-orchestration effects remain synchronized with runtime events. Runtime is O(h) in hook count during registration. Side effects include filesystem reads, command/tool/shortcut registration, UI updates, active-tool changes, optional debug-log writes, and timer scheduling.
|
|
5091
5242
|
- @param[in] pi {ExtensionAPI} Active extension API instance.
|
|
5092
5243
|
- @return {void} No return value.
|
|
5093
|
-
- @satisfies DES-002, REQ-004, REQ-005, REQ-009, REQ-044, REQ-067, REQ-068, REQ-109, REQ-111, REQ-112, REQ-113, REQ-114, REQ-115, REQ-116, REQ-117, REQ-118, REQ-119, REQ-120, REQ-121, REQ-122, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-131, REQ-132, REQ-133, REQ-134, REQ-137, REQ-
|
|
5244
|
+
- @satisfies DES-002, REQ-004, REQ-005, REQ-009, REQ-044, REQ-067, REQ-068, REQ-109, REQ-111, REQ-112, REQ-113, REQ-114, REQ-115, REQ-116, REQ-117, REQ-118, REQ-119, REQ-120, REQ-121, REQ-122, REQ-123, REQ-124, REQ-125, REQ-126, REQ-127, REQ-128, REQ-131, REQ-132, REQ-133, REQ-134, REQ-137, REQ-159, REQ-163, REQ-164, REQ-165, REQ-166, REQ-167, REQ-168, REQ-169, REQ-172, REQ-174, REQ-179, REQ-180, REQ-184, REQ-188, REQ-190, REQ-191, REQ-192, REQ-193, REQ-194, REQ-195, REQ-196, REQ-197, REQ-236, REQ-237, REQ-238, REQ-239, REQ-240, REQ-241, REQ-242, REQ-243, REQ-244, REQ-245, REQ-246, REQ-247, REQ-298, REQ-299, REQ-300, REQ-301, REQ-302, REQ-303, REQ-304, REQ-305, REQ-306, REQ-312, REQ-313
|
|
5094
5245
|
|
|
5095
5246
|
## Symbol Index
|
|
5096
5247
|
|Symbol|Kind|Vis|Lines|Sig|
|
|
5097
5248
|
|---|---|---|---|---|
|
|
5098
|
-
|`PiShortcutRegistrar`|iface||
|
|
5099
|
-
|`getProjectBase`|fn||
|
|
5100
|
-
|`getProcessCwdSafe`|fn||
|
|
5101
|
-
|`resolveLiveBootstrapCwd`|fn||
|
|
5102
|
-
|`syncContextCwdMirror`|fn||
|
|
5103
|
-
|`loadProjectConfig`|fn||
|
|
5104
|
-
|`saveProjectConfig`|fn||
|
|
5105
|
-
|`formatProjectConfigPathForMenu`|fn||
|
|
5106
|
-
|`buildTerminalSettingsMenuChoices`|fn||
|
|
5107
|
-
|`ResetConfirmationChange`|iface||
|
|
5108
|
-
|`formatResetConfirmationValue`|fn||
|
|
5109
|
-
|`buildResetConfirmationChoices`|fn||
|
|
5110
|
-
|`confirmResetChanges`|fn||
|
|
5111
|
-
|`writePersistedProjectConfigToEditor`|fn||
|
|
5112
|
-
|`buildSearchToolSupportedTagGuidelines`|fn||
|
|
5113
|
-
|`buildSearchToolSchemaDescription`|fn||
|
|
5114
|
-
|`buildSearchToolPromptGuidelines`|fn||
|
|
5115
|
-
|`MonolithicToolRenderResult`|type||
|
|
5116
|
-
|`getMonolithicToolText`|fn||
|
|
5117
|
-
|`getMonolithicToolErrorText`|fn||
|
|
5118
|
-
|`formatCompactToolArgumentValue`|fn||
|
|
5119
|
-
|`buildCompactToolInvocationText`|fn||
|
|
5120
|
-
|`summarizeStructuredToolResult`|fn||
|
|
5121
|
-
|`buildStructuredToolRenderResult`|fn||
|
|
5122
|
-
|`executeMonolithicTool`|fn||
|
|
5123
|
-
|`
|
|
5124
|
-
|`
|
|
5125
|
-
|`
|
|
5126
|
-
|`
|
|
5127
|
-
|`
|
|
5128
|
-
|`
|
|
5129
|
-
|`
|
|
5130
|
-
|`
|
|
5131
|
-
|`
|
|
5132
|
-
|`
|
|
5133
|
-
|`
|
|
5134
|
-
|`
|
|
5135
|
-
|`
|
|
5136
|
-
|`
|
|
5137
|
-
|`
|
|
5138
|
-
|`
|
|
5139
|
-
|`
|
|
5140
|
-
|`
|
|
5141
|
-
|`
|
|
5142
|
-
|`
|
|
5143
|
-
|`
|
|
5144
|
-
|`
|
|
5145
|
-
|`
|
|
5146
|
-
|`
|
|
5147
|
-
|`
|
|
5148
|
-
|`
|
|
5149
|
-
|`
|
|
5150
|
-
|`
|
|
5151
|
-
|`
|
|
5152
|
-
|`
|
|
5153
|
-
|`
|
|
5154
|
-
|`
|
|
5155
|
-
|`
|
|
5156
|
-
|`
|
|
5157
|
-
|`
|
|
5158
|
-
|`
|
|
5159
|
-
|`
|
|
5160
|
-
|`
|
|
5161
|
-
|`
|
|
5162
|
-
|`
|
|
5163
|
-
|`
|
|
5164
|
-
|`
|
|
5165
|
-
|`
|
|
5166
|
-
|`
|
|
5167
|
-
|`
|
|
5168
|
-
|`
|
|
5169
|
-
|`
|
|
5170
|
-
|`
|
|
5171
|
-
|`
|
|
5172
|
-
|`
|
|
5173
|
-
|`
|
|
5174
|
-
|`
|
|
5175
|
-
|`
|
|
5176
|
-
|`
|
|
5177
|
-
|`
|
|
5178
|
-
|`
|
|
5179
|
-
|`
|
|
5180
|
-
|`
|
|
5181
|
-
|`
|
|
5182
|
-
|`
|
|
5183
|
-
|`
|
|
5184
|
-
|`
|
|
5249
|
+
|`PiShortcutRegistrar`|iface||177-185|interface PiShortcutRegistrar|
|
|
5250
|
+
|`getProjectBase`|fn||193-202|function getProjectBase(cwd: string): string|
|
|
5251
|
+
|`getProcessCwdSafe`|fn||209-218|function getProcessCwdSafe(): string|
|
|
5252
|
+
|`resolveLiveBootstrapCwd`|fn||226-238|function resolveLiveBootstrapCwd(cwd: string): string|
|
|
5253
|
+
|`syncContextCwdMirror`|fn||247-256|function syncContextCwdMirror(ctx: { cwd?: string }, cwd:...|
|
|
5254
|
+
|`loadProjectConfig`|fn||265-268|function loadProjectConfig(cwd: string): UseReqConfig|
|
|
5255
|
+
|`saveProjectConfig`|fn||278-281|function saveProjectConfig(cwd: string, config: UseReqCon...|
|
|
5256
|
+
|`formatProjectConfigPathForMenu`|fn||290-294|function formatProjectConfigPathForMenu(cwd: string): string|
|
|
5257
|
+
|`buildTerminalSettingsMenuChoices`|fn||303-314|function buildTerminalSettingsMenuChoices(options:|
|
|
5258
|
+
|`ResetConfirmationChange`|iface||320-324|interface ResetConfirmationChange|
|
|
5259
|
+
|`formatResetConfirmationValue`|fn||333-335|function formatResetConfirmationValue(previousValue: stri...|
|
|
5260
|
+
|`buildResetConfirmationChoices`|fn||345-384|function buildResetConfirmationChoices(|
|
|
5261
|
+
|`confirmResetChanges`|fn||396-409|async function confirmResetChanges(|
|
|
5262
|
+
|`writePersistedProjectConfigToEditor`|fn||420-427|function writePersistedProjectConfigToEditor(|
|
|
5263
|
+
|`buildSearchToolSupportedTagGuidelines`|fn||488-492|function buildSearchToolSupportedTagGuidelines(): string[]|
|
|
5264
|
+
|`buildSearchToolSchemaDescription`|fn||500-505|function buildSearchToolSchemaDescription(scope: FindTool...|
|
|
5265
|
+
|`buildSearchToolPromptGuidelines`|fn||513-526|function buildSearchToolPromptGuidelines(scope: FindToolS...|
|
|
5266
|
+
|`MonolithicToolRenderResult`|type||532||
|
|
5267
|
+
|`getMonolithicToolText`|fn||549-552|function getMonolithicToolText(result: MonolithicToolRend...|
|
|
5268
|
+
|`getMonolithicToolErrorText`|fn||560-570|function getMonolithicToolErrorText(result: MonolithicToo...|
|
|
5269
|
+
|`formatCompactToolArgumentValue`|fn||578-617|function formatCompactToolArgumentValue(value: unknown): ...|
|
|
5270
|
+
|`buildCompactToolInvocationText`|fn||625-636|function buildCompactToolInvocationText(args: Record<stri...|
|
|
5271
|
+
|`summarizeStructuredToolResult`|fn||646-661|function summarizeStructuredToolResult(|
|
|
5272
|
+
|`buildStructuredToolRenderResult`|fn||670-689|function buildStructuredToolRenderResult(toolName: string)|
|
|
5273
|
+
|`executeMonolithicTool`|fn||697-703|function executeMonolithicTool(operation: () => ToolResul...|
|
|
5274
|
+
|`executeStatusTool`|fn||712-741|function executeStatusTool(operation: () => ToolResult): ...|
|
|
5275
|
+
|`deliverPromptCommand`|fn||752-770|function deliverPromptCommand(|
|
|
5276
|
+
|`shouldIgnoreLatePromptDeliveryFailure`|fn||781-797|function shouldIgnoreLatePromptDeliveryFailure(|
|
|
5277
|
+
|`logPromptWorkflowStateChange`|fn||810-829|function logPromptWorkflowStateChange(|
|
|
5278
|
+
|`logPromptWorkflowEvent`|fn||845-865|function logPromptWorkflowEvent(|
|
|
5279
|
+
|`transitionPromptWorkflowState`|fn||878-891|function transitionPromptWorkflowState(|
|
|
5280
|
+
|`resolvePromptCommandDescription`|fn||899-903|function resolvePromptCommandDescription(|
|
|
5281
|
+
|`resolveDebugProjectBase`|fn||912-916|function resolveDebugProjectBase(cwd: string, statusContr...|
|
|
5282
|
+
|`notifyContextSafely`|fn||927-944|function notifyContextSafely(|
|
|
5283
|
+
|`rejectNonIdleReqCommand`|fn||956-976|function rejectNonIdleReqCommand(|
|
|
5284
|
+
|`getPiUsereqStartupTools`|fn||985-993|function getPiUsereqStartupTools(pi: ExtensionAPI): ToolI...|
|
|
5285
|
+
|`getConfiguredEnabledPiUsereqTools`|fn||1001-1005|function getConfiguredEnabledPiUsereqTools(config: UseReq...|
|
|
5286
|
+
|`applyConfiguredPiUsereqTools`|fn||1015-1032|function applyConfiguredPiUsereqTools(pi: ExtensionAPI, c...|
|
|
5287
|
+
|`handleExtensionStatusEvent`|fn||1045-1316|async function handleExtensionStatusEvent(|
|
|
5288
|
+
|`registerExtensionStatusHooks`|fn||1332-1351|function registerExtensionStatusHooks(|
|
|
5289
|
+
|`setConfiguredPiUsereqTools`|fn||1361-1364|function setConfiguredPiUsereqTools(pi: ExtensionAPI, con...|
|
|
5290
|
+
|`getDebugToolToggleNames`|fn||1372-1374|function getDebugToolToggleNames(): PiUsereqStartupToolNa...|
|
|
5291
|
+
|`resetDebugConfigToDefaults`|fn||1383-1391|function resetDebugConfigToDefaults(config: UseReqConfig)...|
|
|
5292
|
+
|`formatDebugMenuSummary`|fn||1399-1405|function formatDebugMenuSummary(config: UseReqConfig): st...|
|
|
5293
|
+
|`buildDebugMenuChoice`|fn||1415-1428|function buildDebugMenuChoice(|
|
|
5294
|
+
|`selectDebugLogOnStatus`|fn||1437-1465|async function selectDebugLogOnStatus(|
|
|
5295
|
+
|`buildDebugMenuChoices`|fn||1474-1550|function buildDebugMenuChoices(config: UseReqConfig): PiU...|
|
|
5296
|
+
|`configureDebugMenu`|fn||1560-1729|async function configureDebugMenu(|
|
|
5297
|
+
|`PiNotifyBooleanConfigKey`|type||1735||
|
|
5298
|
+
|`PiNotifyEventBooleanConfigKey`|type||1752||
|
|
5299
|
+
|`PiNotifyEventId`|type||1761||
|
|
5300
|
+
|`PiNotifyEventRowDefinition`|iface||1767-1771|interface PiNotifyEventRowDefinition|
|
|
5301
|
+
|`PiNotifyEventMenuDefinition`|iface||1777-1783|interface PiNotifyEventMenuDefinition|
|
|
5302
|
+
|`togglePiNotifyFlag`|fn||1792-1795|function togglePiNotifyFlag(config: UseReqConfig, key: Pi...|
|
|
5303
|
+
|`resetPiNotifyConfigToDefaults`|fn||1804-1828|function resetPiNotifyConfigToDefaults(config: UseReqConf...|
|
|
5304
|
+
|`formatPiNotifyPushoverPriority`|fn||1837-1839|function formatPiNotifyPushoverPriority(priority: PiNotif...|
|
|
5305
|
+
|`formatPiNotifyEventMenuSummary`|fn||1923-1931|function formatPiNotifyEventMenuSummary(|
|
|
5306
|
+
|`buildPiNotifyEventLauncherChoice`|fn||1941-1951|function buildPiNotifyEventLauncherChoice(|
|
|
5307
|
+
|`buildPiNotifyEventMenuChoices`|fn||1961-1977|function buildPiNotifyEventMenuChoices(|
|
|
5308
|
+
|`resetPiNotifyEventMenuToDefaults`|fn||1987-1995|function resetPiNotifyEventMenuToDefaults(|
|
|
5309
|
+
|`resolvePiNotifyEventLabel`|fn||2005-2012|function resolvePiNotifyEventLabel(|
|
|
5310
|
+
|`configurePiNotifyEventMenu`|fn||2023-2099|async function configurePiNotifyEventMenu(|
|
|
5311
|
+
|`buildPiNotifyPushoverRows`|fn||2108-2158|function buildPiNotifyPushoverRows(config: UseReqConfig):...|
|
|
5312
|
+
|`selectPiNotifyPushoverPriority`|fn||2168-2196|async function selectPiNotifyPushoverPriority(|
|
|
5313
|
+
|`buildPiNotifyMenuChoices`|fn||2205-2263|function buildPiNotifyMenuChoices(config: UseReqConfig): ...|
|
|
5314
|
+
|`selectPiNotifySoundLevel`|fn||2273-2313|async function selectPiNotifySoundLevel(|
|
|
5315
|
+
|`configurePiNotifyMenu`|fn||2323-2609|async function configurePiNotifyMenu(|
|
|
5316
|
+
|`registerPiNotifyShortcut`|fn||2624-2647|function registerPiNotifyShortcut(|
|
|
5317
|
+
|`resolveReqResetPromptRequest`|fn||2655-2681|function resolveReqResetPromptRequest(|
|
|
5318
|
+
|`isWorktreeBacked`|fn||2658-2665|const isWorktreeBacked = (request: PromptCommandExecution...|
|
|
5319
|
+
|`registerReqResetCommand`|fn||2691-2745|function registerReqResetCommand(|
|
|
5320
|
+
|`registerReqReferencesCommand`|fn||2755-2795|function registerReqReferencesCommand(|
|
|
5321
|
+
|`registerPromptCommands`|fn||2805-2921|function registerPromptCommands(|
|
|
5322
|
+
|`registerAgentTools`|fn||2931-3230|function registerAgentTools(pi: ExtensionAPI): void|
|
|
5323
|
+
|`buildPiUsereqToolsMenuChoices`|fn||3275-3300|function buildPiUsereqToolsMenuChoices(pi: ExtensionAPI, ...|
|
|
5324
|
+
|`buildPiUsereqToolToggleChoices`|fn||3310-3324|function buildPiUsereqToolToggleChoices(pi: ExtensionAPI,...|
|
|
5325
|
+
|`configurePiUsereqToolsMenu`|fn||3335-3452|async function configurePiUsereqToolsMenu(|
|
|
5326
|
+
|`getStaticCheckLanguageConfigForMenu`|fn||3461-3466|function getStaticCheckLanguageConfigForMenu(|
|
|
5327
|
+
|`countConfiguredStaticCheckLanguages`|fn||3474-3476|function countConfiguredStaticCheckLanguages(config: UseR...|
|
|
5328
|
+
|`countEnabledStaticCheckLanguages`|fn||3484-3486|function countEnabledStaticCheckLanguages(config: UseReqC...|
|
|
5329
|
+
|`resetStaticCheckConfig`|fn||3495-3497|function resetStaticCheckConfig(config: UseReqConfig): void|
|
|
5330
|
+
|`formatStaticCheckLanguagesSummary`|fn||3505-3507|function formatStaticCheckLanguagesSummary(config: UseReq...|
|
|
5331
|
+
|`buildStaticCheckMenuChoices`|fn||3516-3548|function buildStaticCheckMenuChoices(config: UseReqConfig...|
|
|
5332
|
+
|`buildSupportedStaticCheckLanguageChoices`|fn||3556-3573|function buildSupportedStaticCheckLanguageChoices(config:...|
|
|
5333
|
+
|`buildConfiguredStaticCheckLanguageChoices`|fn||3581-3598|function buildConfiguredStaticCheckLanguageChoices(config...|
|
|
5334
|
+
|`configureStaticCheckMenu`|fn||3608-3754|async function configureStaticCheckMenu(|
|
|
5335
|
+
|`buildPiUsereqMenuChoices`|fn||3764-3856|function buildPiUsereqMenuChoices(|
|
|
5336
|
+
|`buildSrcDirMenuChoices`|fn||3865-3883|function buildSrcDirMenuChoices(config: UseReqConfig): Pi...|
|
|
5337
|
+
|`buildSrcDirRemovalChoices`|fn||3892-3904|function buildSrcDirRemovalChoices(config: UseReqConfig):...|
|
|
5338
|
+
|`configurePiUsereq`|fn||3915-4164|async function configurePiUsereq(|
|
|
5339
|
+
|`persistConfigChange`|fn||3926-3931|const persistConfigChange = () =>|
|
|
5340
|
+
|`registerConfigCommands`|fn||4174-4184|function registerConfigCommands(|
|
|
5341
|
+
|`piUsereqExtension`|fn||4193-4203|export default function piUsereqExtension(pi: ExtensionAP...|
|
|
5185
5342
|
|