paseo-req-kit 1.8.0 → 1.9.0-beta.2

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 (44) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -0
  3. package/bin/req-plugin.mjs +226 -0
  4. package/bin/req.mjs +27 -0
  5. package/contracts/README.md +2 -0
  6. package/contracts/cli-json.md +66 -0
  7. package/contracts/usage-record.md +48 -0
  8. package/docs/adr/0026-machine-records-and-api.md +23 -0
  9. package/docs/adr/0027-paseo-plugin.md +23 -0
  10. package/docs/adr/README.md +2 -0
  11. package/docs/guide//344/275/277/347/224/250/350/200/205/346/214/207/345/215/227.md +2 -0
  12. package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +26 -0
  13. package/docs/guide//347/273/264/346/212/244/350/200/205/346/214/207/345/215/227.md +3 -1
  14. package/docs/guide//351/241/271/347/233/256/345/256/232/345/210/266/344/270/216/350/277/220/350/241/214/350/247/204/345/210/231.md +10 -0
  15. package/engine/src/api.ts +397 -0
  16. package/engine/src/control.ts +2 -2
  17. package/engine/src/eval.ts +2 -0
  18. package/engine/src/index-cmd.ts +33 -0
  19. package/engine/src/main.ts +26 -0
  20. package/engine/src/records.ts +271 -0
  21. package/engine/src/state.ts +3 -0
  22. package/engine/src/stats.ts +479 -0
  23. package/install.mjs +3 -0
  24. package/package.json +3 -2
  25. package/paseo-plugin/OVERVIEW.md +7 -0
  26. package/paseo-plugin/client/data.ts +55 -0
  27. package/paseo-plugin/client/detail.tsx +277 -0
  28. package/paseo-plugin/client/format.ts +101 -0
  29. package/paseo-plugin/client/live.ts +161 -0
  30. package/paseo-plugin/client/overview.tsx +89 -0
  31. package/paseo-plugin/client/panel.tsx +56 -0
  32. package/paseo-plugin/client/row.tsx +40 -0
  33. package/paseo-plugin/client/settings.tsx +90 -0
  34. package/paseo-plugin/client/sidebar.tsx +27 -0
  35. package/paseo-plugin/client/stats.tsx +80 -0
  36. package/paseo-plugin/client/ui.tsx +111 -0
  37. package/paseo-plugin/index.client.tsx +52 -0
  38. package/paseo-plugin/index.server.ts +41 -0
  39. package/paseo-plugin/package.json +22 -0
  40. package/paseo-plugin/paseo-plugin.json +6 -0
  41. package/paseo-plugin/server/handlers.ts +45 -0
  42. package/paseo-plugin/server/req.ts +100 -0
  43. package/paseo-plugin/shared/contracts.ts +165 -0
  44. package/paseo-plugin/tsconfig.json +16 -0
@@ -0,0 +1,165 @@
1
+ // What the plugin's app side asks its daemon side. The daemon side answers by running
2
+ // `req api …` (contracts/cli-json.md in req-kit); these types mirror that format.
3
+ import { defineRpc, defineSettings } from "@getpaseo/plugin";
4
+ import { z } from "zod";
5
+
6
+ export type Attention = "approval" | "business" | "interrupted" | "not_completed" | null;
7
+
8
+ export interface Usage {
9
+ steps: number;
10
+ agentMinutes: number;
11
+ inputTokens: number | null;
12
+ outputTokens: number | null;
13
+ costUsd: number | null;
14
+ }
15
+
16
+ export interface Requirement {
17
+ key: string;
18
+ project: string;
19
+ repo: string;
20
+ sourceRepo: string | null;
21
+ workspaceId: string | null;
22
+ featureDir: string;
23
+ name: string;
24
+ title: string;
25
+ type: string | null;
26
+ profile: string | null;
27
+ branch: string | null;
28
+ stage: string;
29
+ status: string | null;
30
+ running: boolean;
31
+ phase: string | null;
32
+ attention: Attention;
33
+ current: Array<{ key: string; title: string; agentId: string }>;
34
+ updatedAt: string;
35
+ usage: Usage | null;
36
+ present: boolean;
37
+ }
38
+
39
+ export interface Step {
40
+ key: string;
41
+ stepId: string;
42
+ title: string;
43
+ phase: string | null;
44
+ attempt: number;
45
+ round: number | null;
46
+ agentId: string;
47
+ startedAt: string;
48
+ endedAt: string | null;
49
+ minutes: number;
50
+ outcome: "running" | "completed" | "failed";
51
+ result: string | null;
52
+ error: string | null;
53
+ }
54
+
55
+ export interface GateRun {
56
+ key: string;
57
+ attempt: number;
58
+ at: string;
59
+ checks: Array<{ name: string; result: string; failedBefore: boolean }>;
60
+ newFailures: string[];
61
+ fixRounds: number;
62
+ passed: boolean;
63
+ }
64
+
65
+ export interface RequirementDetail extends Requirement {
66
+ files: string[];
67
+ run: {
68
+ attempt: number;
69
+ startedAt: string;
70
+ updatedAt: string;
71
+ phaseMode: string | null;
72
+ stopReason: string | null;
73
+ outcome: string | null;
74
+ queuedSince: string | null;
75
+ verifyAt: string | null;
76
+ approval: { attempt: number; status: string; at: string } | null;
77
+ originAgentId: string | null;
78
+ } | null;
79
+ steps: Step[];
80
+ gate: { runs: GateRun[] } | null;
81
+ joint: Array<{ name: string; repo: string; branch: string; workspaceId: string; gate: { runs: GateRun[] } | null }>;
82
+ }
83
+
84
+ export interface StatsSummary {
85
+ period: { label: string };
86
+ machines: string[];
87
+ active: number;
88
+ completed: { total: number; byOutcome: Record<string, number> };
89
+ byType: Record<string, number>;
90
+ cycleHours: { median: number | null; average: number | null };
91
+ steps: Array<{ stepId: string; title: string; count: number; averageMinutes: number; totalMinutes: number }>;
92
+ rework: { averageReviewRounds: number | null; withDefectRounds: number | null; gateRuns: number; gateFailed: number };
93
+ waits: Array<{ kind: string; label: string; requirements: number; averageMinutes: number }>;
94
+ usage: { agentMinutes: number; inputTokens: number | null; outputTokens: number | null; costUsd: number | null };
95
+ }
96
+
97
+ export interface KitInfo {
98
+ kitVersion: string;
99
+ kitRoot: string;
100
+ apiSchema: number;
101
+ paseo: string | null;
102
+ /** Where the daemon side found req-kit (the kit home it read active.json from). */
103
+ kitHome: string;
104
+ }
105
+
106
+ /** Where a requirement is: as `req api` names it. */
107
+ const target = z.object({ repo: z.string().min(1), featureDir: z.string().min(1) });
108
+
109
+ export const versionRpc = defineRpc({
110
+ name: "req.version",
111
+ input: z.object({}),
112
+ output: z.custom<KitInfo>(),
113
+ });
114
+
115
+ export const listRpc = defineRpc({
116
+ name: "req.list",
117
+ input: z.object({}),
118
+ output: z.custom<Requirement[]>(),
119
+ });
120
+
121
+ export const statusRpc = defineRpc({
122
+ name: "req.status",
123
+ input: target,
124
+ output: z.custom<RequirementDetail>(),
125
+ });
126
+
127
+ /** Documents the plugin shows; req api only allows its own list (READABLE_FILES). */
128
+ export const fileRpc = defineRpc({
129
+ name: "req.file",
130
+ input: target.extend({ file: z.string().min(1) }),
131
+ output: z.custom<{ file: string; size: number; truncated: boolean; content: string }>(),
132
+ });
133
+
134
+ export const statsRpc = defineRpc({
135
+ name: "req.stats",
136
+ input: z.object({ since: z.string().optional(), month: z.string().optional() }),
137
+ output: z.custom<StatsSummary>(),
138
+ });
139
+
140
+ export const ACTIONS = ["approve", "stop", "resume", "verify"] as const;
141
+ export type Action = (typeof ACTIONS)[number];
142
+
143
+ export const runRpc = defineRpc({
144
+ name: "req.run",
145
+ input: target.extend({
146
+ action: z.enum(ACTIONS),
147
+ /** For verify: local | deployed. */
148
+ verifyEnv: z.enum(["local", "deployed"]).optional(),
149
+ }),
150
+ output: z.object({ ok: z.boolean(), message: z.string() }),
151
+ });
152
+
153
+ export const preferences = defineSettings({
154
+ id: "preferences",
155
+ scope: "host",
156
+ version: 1,
157
+ schema: z.object({
158
+ /** Show requirements and documents only; hide stop, resume, approve and verify. */
159
+ readOnly: z.boolean().default(false),
160
+ /** How often an open screen refreshes, in seconds. */
161
+ refreshSeconds: z.number().int().min(3).max(300).default(10),
162
+ /** req-kit's machine directory when it is not ~/.req-kit (REQ_KIT_HOME). */
163
+ kitHome: z.string().default(""),
164
+ }),
165
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2023"],
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true,
11
+ "allowSyntheticDefaultImports": true,
12
+ "noEmit": true,
13
+ "types": ["node"]
14
+ },
15
+ "include": ["index.client.tsx", "index.server.ts", "client/**/*", "server/**/*", "shared/**/*"]
16
+ }