pi-orchestrator-config 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +808 -0
  2. package/agents/api-documenter.md +32 -0
  3. package/agents/bash-expert.md +53 -0
  4. package/agents/code-reviewer-docs.md +145 -0
  5. package/agents/code-reviewer-guidelines.md +97 -0
  6. package/agents/code-reviewer-quality.md +142 -0
  7. package/agents/code-reviewer-security.md +107 -0
  8. package/agents/code-reviewer-spec.md +164 -0
  9. package/agents/debugger.md +63 -0
  10. package/agents/docker-expert.md +40 -0
  11. package/agents/docs-fetcher.md +48 -0
  12. package/agents/git-expert.md +63 -0
  13. package/agents/github-expert.md +83 -0
  14. package/agents/go-expert.md +62 -0
  15. package/agents/issue-reviewer-feasibility.md +60 -0
  16. package/agents/issue-reviewer-scope.md +63 -0
  17. package/agents/issue-reviewer-spec.md +77 -0
  18. package/agents/java-expert.md +31 -0
  19. package/agents/jenkins-expert.md +38 -0
  20. package/agents/kubernetes-expert.md +40 -0
  21. package/agents/planner.md +42 -0
  22. package/agents/python-expert.md +61 -0
  23. package/agents/reviewer.md +26 -0
  24. package/agents/scout.md +40 -0
  25. package/agents/security-auditor.md +254 -0
  26. package/agents/technical-documentation-writer.md +37 -0
  27. package/agents/test-automator.md +55 -0
  28. package/agents/test-runner.md +47 -0
  29. package/agents/ts-expert.md +23 -0
  30. package/agents/worker.md +30 -0
  31. package/extensions/acpx-provider/index.ts +104 -0
  32. package/extensions/acpx-provider/load-runtime.ts +99 -0
  33. package/extensions/acpx-provider/runtime-models.ts +40 -0
  34. package/extensions/cli-provider/agents/claude.ts +128 -0
  35. package/extensions/cli-provider/agents/cursor.ts +84 -0
  36. package/extensions/cli-provider/agents/gemini.ts +100 -0
  37. package/extensions/cli-provider/discover.ts +77 -0
  38. package/extensions/cli-provider/index.ts +57 -0
  39. package/extensions/cli-provider/parsers.ts +304 -0
  40. package/extensions/cli-provider/providers.ts +58 -0
  41. package/extensions/cli-provider/runner.ts +225 -0
  42. package/extensions/cli-provider/runtime-models.ts +32 -0
  43. package/extensions/cli-provider/session-reaper.ts +122 -0
  44. package/extensions/cli-provider/sessions.ts +533 -0
  45. package/extensions/cli-provider/shared/discover-cache.ts +235 -0
  46. package/extensions/cli-provider/types.ts +48 -0
  47. package/extensions/coms/coms-net-server.ts +1642 -0
  48. package/extensions/coms/coms-net-wrapper.ts +521 -0
  49. package/extensions/coms/coms-net.ts +1589 -0
  50. package/extensions/coms/coms-p2p.ts +1879 -0
  51. package/extensions/coms/coms-shared.ts +510 -0
  52. package/extensions/coms/coms-wrapper.ts +138 -0
  53. package/extensions/coms/index.ts +20 -0
  54. package/extensions/coms/themeMap.ts +147 -0
  55. package/extensions/image-gen/image-gen.ts +332 -0
  56. package/extensions/image-gen/index.ts +14 -0
  57. package/extensions/orchestrator/agents.ts +134 -0
  58. package/extensions/orchestrator/ask-user.ts +293 -0
  59. package/extensions/orchestrator/async-agents.ts +1037 -0
  60. package/extensions/orchestrator/async-capability.ts +129 -0
  61. package/extensions/orchestrator/async-runner.ts +324 -0
  62. package/extensions/orchestrator/async-status-parse.ts +31 -0
  63. package/extensions/orchestrator/async-status-ui.ts +201 -0
  64. package/extensions/orchestrator/async-wait.ts +36 -0
  65. package/extensions/orchestrator/btw.ts +210 -0
  66. package/extensions/orchestrator/cron-status-format.ts +126 -0
  67. package/extensions/orchestrator/cron-status-ui.ts +132 -0
  68. package/extensions/orchestrator/cron.ts +730 -0
  69. package/extensions/orchestrator/dreaming.ts +355 -0
  70. package/extensions/orchestrator/enforcement-helpers.ts +530 -0
  71. package/extensions/orchestrator/enforcement-rules.ts +329 -0
  72. package/extensions/orchestrator/enforcement.ts +828 -0
  73. package/extensions/orchestrator/extended-autocomplete.ts +593 -0
  74. package/extensions/orchestrator/git-helpers.ts +420 -0
  75. package/extensions/orchestrator/github-autocomplete.ts +250 -0
  76. package/extensions/orchestrator/icons.ts +17 -0
  77. package/extensions/orchestrator/index.ts +100 -0
  78. package/extensions/orchestrator/memory-embeddings.ts +281 -0
  79. package/extensions/orchestrator/memory-promotion.ts +449 -0
  80. package/extensions/orchestrator/memory-provenance.ts +80 -0
  81. package/extensions/orchestrator/memory-query-class.ts +90 -0
  82. package/extensions/orchestrator/memory-scoring.ts +434 -0
  83. package/extensions/orchestrator/memory-tools.ts +883 -0
  84. package/extensions/orchestrator/memory-tree.ts +212 -0
  85. package/extensions/orchestrator/nvim.ts +169 -0
  86. package/extensions/orchestrator/overlay-dashboard-utils.ts +25 -0
  87. package/extensions/orchestrator/overlay-dashboard.ts +512 -0
  88. package/extensions/orchestrator/pi-config-review-state.ts +303 -0
  89. package/extensions/orchestrator/preference-extractor.ts +106 -0
  90. package/extensions/orchestrator/project-settings.ts +468 -0
  91. package/extensions/orchestrator/promotion-queue.ts +311 -0
  92. package/extensions/orchestrator/resolve-agent-model.ts +32 -0
  93. package/extensions/orchestrator/review-ui.ts +204 -0
  94. package/extensions/orchestrator/rule-placeholders.ts +12 -0
  95. package/extensions/orchestrator/rules.ts +481 -0
  96. package/extensions/orchestrator/session-search.ts +243 -0
  97. package/extensions/orchestrator/session-validation.ts +374 -0
  98. package/extensions/orchestrator/situation-report.ts +370 -0
  99. package/extensions/orchestrator/status-bar.ts +31 -0
  100. package/extensions/orchestrator/status-line.ts +192 -0
  101. package/extensions/orchestrator/status.ts +110 -0
  102. package/extensions/orchestrator/subagent-tool.ts +1748 -0
  103. package/extensions/orchestrator/task-lifecycle.ts +88 -0
  104. package/extensions/orchestrator/utils.ts +227 -0
  105. package/extensions/pidash/index.ts +15 -0
  106. package/extensions/pidash/pidash.ts +941 -0
  107. package/extensions/pidiff/index.ts +13 -0
  108. package/extensions/pidiff/pidiff.ts +369 -0
  109. package/extensions/providers/acpx-driver.ts +479 -0
  110. package/extensions/providers/built-in-drivers.ts +52 -0
  111. package/extensions/providers/claude-driver.ts +319 -0
  112. package/extensions/providers/cursor-acpx-driver.ts +398 -0
  113. package/extensions/providers/cursor-cli-driver.ts +484 -0
  114. package/extensions/providers/gemini-driver.ts +302 -0
  115. package/extensions/providers/index.ts +513 -0
  116. package/extensions/shared/build-system-prompt.ts +57 -0
  117. package/extensions/shared/create-runtime-provider.ts +190 -0
  118. package/extensions/shared/daemon-manager.ts +248 -0
  119. package/extensions/shared/file-logger.ts +115 -0
  120. package/extensions/shared/managed-refresh.ts +211 -0
  121. package/extensions/shared/provider-driver.ts +295 -0
  122. package/extensions/shared/provider-errors.ts +305 -0
  123. package/extensions/shared/provider-registry.ts +388 -0
  124. package/extensions/shared/stream-builder.ts +275 -0
  125. package/extensions/shared/types.ts +20 -0
  126. package/extensions/shared/ui/README.md +10 -0
  127. package/extensions/shared/ui/badge.tsx +52 -0
  128. package/extensions/shared/ui/button.tsx +58 -0
  129. package/extensions/shared/ui/collapsible.tsx +21 -0
  130. package/extensions/shared/ui/dropdown-menu.tsx +266 -0
  131. package/extensions/shared/ui/input.tsx +20 -0
  132. package/extensions/shared/ui/popover.tsx +114 -0
  133. package/extensions/shared/ui/resizable.tsx +48 -0
  134. package/extensions/shared/ui/scroll-area.tsx +53 -0
  135. package/extensions/shared/ui/select.tsx +201 -0
  136. package/extensions/shared/ui/separator.tsx +25 -0
  137. package/extensions/shared/ui/tooltip.tsx +64 -0
  138. package/extensions/shared/ws-client.ts +74 -0
  139. package/package.json +59 -0
  140. package/prompts/coderabbit-rate-limit.md +95 -0
  141. package/prompts/create-coms-feature-manager.md +186 -0
  142. package/prompts/create-skill.md +128 -0
  143. package/prompts/domain-model.md +109 -0
  144. package/prompts/external-ai.md +665 -0
  145. package/prompts/implement-and-review.md +25 -0
  146. package/prompts/implement.md +26 -0
  147. package/prompts/issue-review.md +256 -0
  148. package/prompts/pr-review.md +753 -0
  149. package/prompts/query-db.md +154 -0
  150. package/prompts/refine-review.md +208 -0
  151. package/prompts/release.md +235 -0
  152. package/prompts/remember.md +33 -0
  153. package/prompts/review-handler-status.md +27 -0
  154. package/prompts/review-handler.md +677 -0
  155. package/prompts/review-local.md +159 -0
  156. package/prompts/scout-and-plan.md +21 -0
  157. package/rules/00-orchestrator-core.md +42 -0
  158. package/rules/05-issue-first-workflow.md +119 -0
  159. package/rules/10-agent-routing.md +58 -0
  160. package/rules/15-mcp-launchpad.md +46 -0
  161. package/rules/20-code-review-loop.md +234 -0
  162. package/rules/25-documentation-updates.md +15 -0
  163. package/rules/30-prompt-templates.md +19 -0
  164. package/rules/35-memory.md +240 -0
  165. package/rules/40-critical-rules.md +124 -0
  166. package/rules/45-file-preview.md +29 -0
  167. package/rules/50-agent-bug-reporting.md +90 -0
  168. package/rules/55-coms-protocol.md +63 -0
  169. package/rules/60-task-tracking.md +66 -0
  170. package/skills/conflict-resolver/SKILL.md +213 -0
  171. package/skills/skill-creator/SKILL.md +85 -0
  172. package/skills/systematic-debugging/SKILL.md +353 -0
  173. package/skills/test-driven-development/SKILL.md +335 -0
  174. package/skills/update-agents-md/SKILL.md +282 -0
  175. package/templates/coms-feature-manager-prompt.md +313 -0
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Shared helpers for CLI model discovery (cache + binary resolve).
3
+ */
4
+
5
+ import {
6
+ accessSync,
7
+ constants,
8
+ existsSync,
9
+ mkdirSync,
10
+ readFileSync,
11
+ realpathSync,
12
+ statSync,
13
+ writeFileSync,
14
+ } from "node:fs";
15
+ import { extname, isAbsolute, join, posix, win32 } from "node:path";
16
+ import { homedir } from "node:os";
17
+ import { createHash } from "node:crypto";
18
+ import type { DiscoveredCliModel } from "../types.js";
19
+
20
+ export function modelIdToDisplayName(modelId: string): string {
21
+ const bracketIdx = modelId.indexOf("[");
22
+ const baseName = bracketIdx >= 0 ? modelId.substring(0, bracketIdx) : modelId;
23
+ return baseName
24
+ .replace(/-/g, " ")
25
+ .replace(/\b\w/g, (c) => c.toUpperCase());
26
+ }
27
+
28
+ /** Cache keyed by `${platform}\0${binary}\0${PATH}\0${PATHEXT}` — successful resolves only. */
29
+ const resolveBinaryCache = new Map<string, string>();
30
+
31
+ export type ResolveBinaryEnv = {
32
+ PATH?: string;
33
+ PATHEXT?: string;
34
+ };
35
+
36
+ /** Parse PATHEXT into uppercase extensions (e.g. ".EXE"). Exported for tests. */
37
+ export function parsePathext(pathextEnv?: string): string[] {
38
+ const raw = pathextEnv ?? process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM";
39
+ return raw
40
+ .split(";")
41
+ .map((s) => s.trim())
42
+ .filter(Boolean)
43
+ .map((s) => (s.startsWith(".") ? s : `.${s}`).toUpperCase());
44
+ }
45
+
46
+ /**
47
+ * True when filePath has an extension listed in PATHEXT (case-insensitive).
48
+ * Extensionless files are not CreateProcess-launchable on Windows.
49
+ */
50
+ export function isLaunchableWin32(
51
+ filePath: string,
52
+ pathextEnv?: string,
53
+ ): boolean {
54
+ const ext = extname(filePath);
55
+ if (!ext) return false;
56
+ return parsePathext(pathextEnv).includes(ext.toUpperCase());
57
+ }
58
+
59
+ /**
60
+ * Suffixes to try when scanning PATH for `binary`.
61
+ * On win32: if `binary` already has a PATHEXT extension, try as-is only;
62
+ * otherwise try each PATHEXT suffix (no bare/empty suffix).
63
+ */
64
+ export function candidateSuffixesFor(
65
+ binary: string,
66
+ platform: NodeJS.Platform = process.platform,
67
+ pathextEnv?: string,
68
+ ): string[] {
69
+ if (platform !== "win32") return [""];
70
+ const ext = extname(binary);
71
+ if (ext && parsePathext(pathextEnv).includes(ext.toUpperCase())) {
72
+ return [""];
73
+ }
74
+ return parsePathext(pathextEnv);
75
+ }
76
+
77
+ /**
78
+ * PATH list separator for the *resolved* platform (not the host OS).
79
+ * Needed so win32 simulation on Unix splits semicolon-separated PATH correctly.
80
+ */
81
+ export function pathDelimiterFor(platform: NodeJS.Platform): string {
82
+ return platform === "win32" ? win32.delimiter : posix.delimiter;
83
+ }
84
+
85
+ /** Exported for tests — regular file + platform launchability rules. */
86
+ export function isExecutableForPlatform(
87
+ filePath: string,
88
+ platform: NodeJS.Platform,
89
+ pathextEnv?: string,
90
+ ): boolean {
91
+ let st;
92
+ try {
93
+ st = statSync(filePath);
94
+ } catch {
95
+ return false;
96
+ }
97
+ // Directories are often X_OK (searchable); only regular files are binaries.
98
+ if (!st.isFile()) return false;
99
+ // Win32: never treat any regular file as executable — require PATHEXT.
100
+ if (platform === "win32") return isLaunchableWin32(filePath, pathextEnv);
101
+ try {
102
+ accessSync(filePath, constants.X_OK);
103
+ return true;
104
+ } catch {
105
+ return false;
106
+ }
107
+ }
108
+
109
+ function finalizeResolved(filePath: string): string {
110
+ try {
111
+ return realpathSync(filePath);
112
+ } catch {
113
+ return filePath;
114
+ }
115
+ }
116
+
117
+ function cacheKeyFor(
118
+ binary: string,
119
+ platform: NodeJS.Platform,
120
+ pathEnv: string,
121
+ pathextEnv: string,
122
+ ): string {
123
+ return `${platform}\0${binary}\0${pathEnv}\0${pathextEnv}`;
124
+ }
125
+
126
+ /**
127
+ * Resolve a binary for an explicit platform (injectable for win32 tests on Unix).
128
+ * Absolute paths still require a launchable PATHEXT extension on win32.
129
+ */
130
+ export function resolveBinaryForPlatform(
131
+ binary: string,
132
+ platform: NodeJS.Platform,
133
+ env: ResolveBinaryEnv = {},
134
+ ): string | null {
135
+ if (!binary) return null;
136
+
137
+ const pathEnv = env.PATH ?? process.env.PATH ?? "";
138
+ const pathextEnv =
139
+ env.PATHEXT ?? process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM";
140
+ const cacheKey = cacheKeyFor(binary, platform, pathEnv, pathextEnv);
141
+ const cached = resolveBinaryCache.get(cacheKey);
142
+ if (cached !== undefined) {
143
+ if (isExecutableForPlatform(cached, platform, pathextEnv)) return cached;
144
+ resolveBinaryCache.delete(cacheKey);
145
+ }
146
+
147
+ const isExec = (p: string) =>
148
+ isExecutableForPlatform(p, platform, pathextEnv);
149
+
150
+ // Absolute or explicit relative path — check directly (mirrors `which /path`).
151
+ if (isAbsolute(binary) || binary.includes("/") || binary.includes("\\")) {
152
+ if (!isExec(binary)) return null;
153
+ const resolved = finalizeResolved(binary);
154
+ resolveBinaryCache.set(cacheKey, resolved);
155
+ return resolved;
156
+ }
157
+
158
+ const suffixes = candidateSuffixesFor(binary, platform, pathextEnv);
159
+ const envDelimiter = pathDelimiterFor(platform);
160
+ for (const dir of pathEnv.split(envDelimiter)) {
161
+ if (!dir) continue;
162
+ for (const suffix of suffixes) {
163
+ // PATHEXT is typically uppercase; Windows FS is case-insensitive.
164
+ // On case-sensitive hosts (win32 simulation in tests), also try lowercase.
165
+ const variants =
166
+ platform === "win32" && suffix && suffix !== suffix.toLowerCase()
167
+ ? [binary + suffix, binary + suffix.toLowerCase()]
168
+ : [binary + suffix];
169
+ for (const name of variants) {
170
+ const candidate = join(dir, name);
171
+ if (!isExec(candidate)) continue;
172
+ const resolved = finalizeResolved(candidate);
173
+ resolveBinaryCache.set(cacheKey, resolved);
174
+ return resolved;
175
+ }
176
+ }
177
+ }
178
+
179
+ // Do not cache misses — mid-session install with same PATH must rediscover.
180
+ return null;
181
+ }
182
+
183
+ /**
184
+ * Resolve a binary name (or absolute path) via an in-process PATH scan.
185
+ * Avoids spawnSync("which") on auth/filter hot paths.
186
+ * Returns realpath when possible, null if missing.
187
+ */
188
+ export function resolveBinary(binary: string): string | null {
189
+ return resolveBinaryForPlatform(binary, process.platform, {
190
+ PATH: process.env.PATH,
191
+ PATHEXT: process.env.PATHEXT,
192
+ });
193
+ }
194
+
195
+ /** Clear PATH resolve cache (tests / PATH mutation). */
196
+ export function clearResolveBinaryCache(): void {
197
+ resolveBinaryCache.clear();
198
+ }
199
+
200
+ function cacheDir(): string {
201
+ return join(homedir(), ".pi", "cli-model-cache");
202
+ }
203
+
204
+ export function readModelCache(key: string): DiscoveredCliModel[] | null {
205
+ const path = join(cacheDir(), `${key}.json`);
206
+ if (!existsSync(path)) return null;
207
+ try {
208
+ const data = JSON.parse(readFileSync(path, "utf-8"));
209
+ if (!Array.isArray(data?.models)) return null;
210
+ return data.models.filter(
211
+ (m: any) => typeof m?.id === "string" && typeof m?.name === "string",
212
+ );
213
+ } catch {
214
+ return null;
215
+ }
216
+ }
217
+
218
+ export function writeModelCache(key: string, models: DiscoveredCliModel[]): void {
219
+ try {
220
+ mkdirSync(cacheDir(), { recursive: true, mode: 0o700 });
221
+ writeFileSync(
222
+ join(cacheDir(), `${key}.json`),
223
+ JSON.stringify({ updatedAt: new Date().toISOString(), models }, null, 0),
224
+ { mode: 0o600 },
225
+ );
226
+ } catch {
227
+ /* ignore */
228
+ }
229
+ }
230
+
231
+ export function cacheKeyForFile(agent: string, filePath: string): string {
232
+ const st = statSync(filePath);
233
+ const raw = `${agent}\0${filePath}\0${st.size}\0${st.mtimeMs}`;
234
+ return createHash("sha256").update(raw).digest("hex").slice(0, 24);
235
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Shared types for cli-provider agents.
3
+ */
4
+
5
+ export type CliAgentName = "claude" | "gemini" | "cursor";
6
+
7
+ export interface DiscoveredCliModel {
8
+ id: string;
9
+ name: string;
10
+ }
11
+
12
+ export interface CliProviderDef {
13
+ /** Settings / registration name (claude, gemini, cursor) */
14
+ name: CliAgentName;
15
+ binary: string;
16
+ /** Build argv before prompt/session flags (excludes resume/continue). */
17
+ buildBaseArgs: (model: string, cwd: string) => string[];
18
+ resumeFlag: string;
19
+ continueFlags: string[];
20
+ /** Value for --output-format sent to the CLI */
21
+ outputFormat: string;
22
+ /** Pass prompt on stdin (true) or as final argv (false) */
23
+ promptOnStdin: boolean;
24
+ /** Discover models via this agent's CLI only (no API keys). */
25
+ discoverModels: () => DiscoveredCliModel[];
26
+ }
27
+
28
+ export interface CliSessionKey {
29
+ cwd: string;
30
+ agent: string;
31
+ model: string;
32
+ /** Pi session id: real UUID, per-process provisional `tmp-…`, or legacy `"default"`. */
33
+ piSessionId?: string | null;
34
+ }
35
+
36
+ export type CliSessionStatus = "running" | "stopped";
37
+
38
+ export interface CliSessionRecord {
39
+ sessionId: string;
40
+ agent: string;
41
+ model: string;
42
+ cwd: string;
43
+ piSessionId: string;
44
+ status: CliSessionStatus;
45
+ createdAt: string;
46
+ lastSeenAt: string;
47
+ resumeFailures?: number;
48
+ }