@piup/contracts 0.1.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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/index.d.mts +175 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 piup contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
export declare const PIUP_API_VERSION: 1;
|
|
3
|
+
export type RouteId = "debug" | "small" | "standard" | "foundation" | "infra";
|
|
4
|
+
export type RequestKind = "read-only" | "change" | "ambiguous";
|
|
5
|
+
export type RequestDisposition = "continue" | "reroute" | "follow-up" | "read-only" | "clarify";
|
|
6
|
+
export type Complexity = "low" | "medium" | "high";
|
|
7
|
+
export type RiskLevel = "low" | "medium" | "high";
|
|
8
|
+
export type DispatchMode = "inline";
|
|
9
|
+
export interface RouteScope {
|
|
10
|
+
/** Workspace-relative paths. A single "." means the whole workspace. */
|
|
11
|
+
readonly paths: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
/** A read-only routing decision. Producing this value must not create a task or mutate a workspace. */
|
|
14
|
+
export interface RouteResult {
|
|
15
|
+
readonly requestKind: RequestKind;
|
|
16
|
+
readonly route: RouteId | null;
|
|
17
|
+
readonly complexity: Complexity | null;
|
|
18
|
+
readonly risk: RiskLevel | null;
|
|
19
|
+
readonly strategyId: string | null;
|
|
20
|
+
readonly dispatchMode: DispatchMode;
|
|
21
|
+
readonly scope: RouteScope;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
}
|
|
24
|
+
export type StageStatus = "pending" | "running" | "validating" | "committed" | "waiting" | "blocked" | "failed" | "interrupted" | "cancelled";
|
|
25
|
+
export type TaskStatus = "queued" | "running" | "completed" | "failed" | "interrupted" | "cancelled";
|
|
26
|
+
export interface ExecutionIdentity {
|
|
27
|
+
readonly taskId: string;
|
|
28
|
+
readonly stageId: string;
|
|
29
|
+
readonly attempt: number;
|
|
30
|
+
readonly revision: number;
|
|
31
|
+
readonly leaseToken: string;
|
|
32
|
+
}
|
|
33
|
+
export type StageKind = "command" | "inline-agent";
|
|
34
|
+
export type StagePhase = "analysis" | "implementation" | "check" | "acceptance";
|
|
35
|
+
export interface CommandStageDefinition {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly type?: "command";
|
|
38
|
+
readonly phase?: StagePhase;
|
|
39
|
+
readonly command: readonly [string, ...string[]];
|
|
40
|
+
readonly cwd?: string;
|
|
41
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
42
|
+
}
|
|
43
|
+
export interface InlineAgentStageDefinition {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly type: "inline-agent";
|
|
46
|
+
readonly phase?: StagePhase;
|
|
47
|
+
readonly instructions?: string;
|
|
48
|
+
}
|
|
49
|
+
export type StageDefinition = CommandStageDefinition | InlineAgentStageDefinition;
|
|
50
|
+
export type GateStatus = "pending" | "passed" | "failed" | "blocked" | "coverage_gap" | "not_applicable";
|
|
51
|
+
export interface GateDefinition {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly required: boolean;
|
|
54
|
+
readonly description: string;
|
|
55
|
+
}
|
|
56
|
+
export interface Strategy {
|
|
57
|
+
readonly version: 1;
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly route: RouteId;
|
|
60
|
+
readonly stages: readonly StageDefinition[];
|
|
61
|
+
readonly gates: readonly GateDefinition[];
|
|
62
|
+
}
|
|
63
|
+
export interface WorkflowDefinition {
|
|
64
|
+
readonly version: 1;
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly stages: readonly StageDefinition[];
|
|
67
|
+
readonly gates?: readonly GateDefinition[];
|
|
68
|
+
}
|
|
69
|
+
export interface WorkspaceFileSnapshot {
|
|
70
|
+
readonly path: string;
|
|
71
|
+
readonly sha256: string;
|
|
72
|
+
}
|
|
73
|
+
export interface WorkspaceSnapshot {
|
|
74
|
+
readonly digest: string;
|
|
75
|
+
readonly files: readonly WorkspaceFileSnapshot[];
|
|
76
|
+
}
|
|
77
|
+
export interface TaskStageRecord {
|
|
78
|
+
readonly index: number;
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly kind: StageKind;
|
|
81
|
+
readonly phase: StagePhase;
|
|
82
|
+
readonly status: StageStatus;
|
|
83
|
+
readonly attempt: number;
|
|
84
|
+
readonly command: readonly string[];
|
|
85
|
+
readonly cwd: string | null;
|
|
86
|
+
readonly instructions: string | null;
|
|
87
|
+
readonly startedAt: string | null;
|
|
88
|
+
readonly finishedAt: string | null;
|
|
89
|
+
readonly exitCode: number | null;
|
|
90
|
+
readonly logPath: string | null;
|
|
91
|
+
readonly summary: string | null;
|
|
92
|
+
readonly evidence: readonly string[];
|
|
93
|
+
readonly error: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface GateRecord {
|
|
96
|
+
readonly taskId: string;
|
|
97
|
+
readonly stageIndex: number;
|
|
98
|
+
readonly gateId: string;
|
|
99
|
+
readonly required: boolean;
|
|
100
|
+
readonly status: GateStatus;
|
|
101
|
+
readonly description: string;
|
|
102
|
+
readonly paths: readonly string[];
|
|
103
|
+
readonly workspaceDigest: string | null;
|
|
104
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
105
|
+
readonly createdAt: string;
|
|
106
|
+
readonly updatedAt: string;
|
|
107
|
+
}
|
|
108
|
+
export interface TaskRecord {
|
|
109
|
+
readonly id: string;
|
|
110
|
+
/** Isolates active task ownership between Pi terminal sessions. */
|
|
111
|
+
readonly ownerId: string;
|
|
112
|
+
readonly title: string;
|
|
113
|
+
readonly request: string;
|
|
114
|
+
readonly workflowName: string;
|
|
115
|
+
readonly workspace: string;
|
|
116
|
+
readonly status: TaskStatus;
|
|
117
|
+
readonly route: RouteId | null;
|
|
118
|
+
readonly strategyId: string | null;
|
|
119
|
+
readonly complexity: Complexity | null;
|
|
120
|
+
readonly risk: RiskLevel | null;
|
|
121
|
+
readonly scope: RouteScope;
|
|
122
|
+
readonly currentStageIndex: number;
|
|
123
|
+
readonly revision: number;
|
|
124
|
+
readonly planVersion: number;
|
|
125
|
+
readonly baselineDigest: string | null;
|
|
126
|
+
readonly validatedDigest: string | null;
|
|
127
|
+
readonly createdAt: string;
|
|
128
|
+
readonly updatedAt: string;
|
|
129
|
+
readonly stages: readonly TaskStageRecord[];
|
|
130
|
+
readonly gates: readonly GateRecord[];
|
|
131
|
+
}
|
|
132
|
+
export interface TaskEvent {
|
|
133
|
+
readonly eventId: string;
|
|
134
|
+
readonly sequence: number;
|
|
135
|
+
readonly taskId: string;
|
|
136
|
+
readonly type: string;
|
|
137
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
138
|
+
readonly dedupeKey: string | null;
|
|
139
|
+
readonly createdAt: string;
|
|
140
|
+
}
|
|
141
|
+
export type HookKind = "transform" | "guard" | "observer" | "cleanup";
|
|
142
|
+
export type HookInvocationStatus = "scheduled" | "started" | "succeeded" | "blocked" | "failed" | "timed_out" | "cancelled" | "interrupted";
|
|
143
|
+
export interface HookInvocation {
|
|
144
|
+
readonly invocationId: string;
|
|
145
|
+
readonly taskId: string;
|
|
146
|
+
readonly stageId: string;
|
|
147
|
+
readonly attempt: number;
|
|
148
|
+
readonly revision: number;
|
|
149
|
+
readonly pluginId: string;
|
|
150
|
+
readonly hookName: string;
|
|
151
|
+
readonly kind: HookKind;
|
|
152
|
+
readonly inputRef: string;
|
|
153
|
+
readonly status: HookInvocationStatus;
|
|
154
|
+
readonly result: Readonly<Record<string, unknown>> | null;
|
|
155
|
+
readonly error: string | null;
|
|
156
|
+
readonly scheduledAt: string;
|
|
157
|
+
readonly startedAt: string | null;
|
|
158
|
+
readonly finishedAt: string | null;
|
|
159
|
+
}
|
|
160
|
+
export type GuardResult = {
|
|
161
|
+
readonly action: "continue";
|
|
162
|
+
} | {
|
|
163
|
+
readonly action: "wait";
|
|
164
|
+
readonly request: string;
|
|
165
|
+
} | {
|
|
166
|
+
readonly action: "block";
|
|
167
|
+
readonly reason: string;
|
|
168
|
+
};
|
|
169
|
+
export interface PluginDescriptor {
|
|
170
|
+
readonly id: string;
|
|
171
|
+
readonly apiVersion: typeof PIUP_API_VERSION;
|
|
172
|
+
readonly capabilities: readonly string[];
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export const PIUP_API_VERSION = 1 as const;\n\nexport type RouteId = \"debug\" | \"small\" | \"standard\" | \"foundation\" | \"infra\";\nexport type RequestKind = \"read-only\" | \"change\" | \"ambiguous\";\nexport type RequestDisposition =\n | \"continue\"\n | \"reroute\"\n | \"follow-up\"\n | \"read-only\"\n | \"clarify\";\nexport type Complexity = \"low\" | \"medium\" | \"high\";\nexport type RiskLevel = \"low\" | \"medium\" | \"high\";\nexport type DispatchMode = \"inline\";\n\nexport interface RouteScope {\n /** Workspace-relative paths. A single \".\" means the whole workspace. */\n readonly paths: readonly string[];\n}\n\n/** A read-only routing decision. Producing this value must not create a task or mutate a workspace. */\nexport interface RouteResult {\n readonly requestKind: RequestKind;\n readonly route: RouteId | null;\n readonly complexity: Complexity | null;\n readonly risk: RiskLevel | null;\n readonly strategyId: string | null;\n readonly dispatchMode: DispatchMode;\n readonly scope: RouteScope;\n readonly reason: string;\n}\n\nexport type StageStatus =\n | \"pending\"\n | \"running\"\n | \"validating\"\n | \"committed\"\n | \"waiting\"\n | \"blocked\"\n | \"failed\"\n | \"interrupted\"\n | \"cancelled\";\n\nexport type TaskStatus =\n | \"queued\"\n | \"running\"\n | \"completed\"\n | \"failed\"\n | \"interrupted\"\n | \"cancelled\";\n\nexport interface ExecutionIdentity {\n readonly taskId: string;\n readonly stageId: string;\n readonly attempt: number;\n readonly revision: number;\n readonly leaseToken: string;\n}\n\nexport type StageKind = \"command\" | \"inline-agent\";\nexport type StagePhase = \"analysis\" | \"implementation\" | \"check\" | \"acceptance\";\n\nexport interface CommandStageDefinition {\n readonly id: string;\n readonly type?: \"command\";\n readonly phase?: StagePhase;\n readonly command: readonly [string, ...string[]];\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string>>;\n}\n\nexport interface InlineAgentStageDefinition {\n readonly id: string;\n readonly type: \"inline-agent\";\n readonly phase?: StagePhase;\n readonly instructions?: string;\n}\n\nexport type StageDefinition =\n | CommandStageDefinition\n | InlineAgentStageDefinition;\n\nexport type GateStatus =\n | \"pending\"\n | \"passed\"\n | \"failed\"\n | \"blocked\"\n | \"coverage_gap\"\n | \"not_applicable\";\n\nexport interface GateDefinition {\n readonly id: string;\n readonly required: boolean;\n readonly description: string;\n}\n\nexport interface Strategy {\n readonly version: 1;\n readonly id: string;\n readonly route: RouteId;\n readonly stages: readonly StageDefinition[];\n readonly gates: readonly GateDefinition[];\n}\n\nexport interface WorkflowDefinition {\n readonly version: 1;\n readonly name: string;\n readonly stages: readonly StageDefinition[];\n readonly gates?: readonly GateDefinition[];\n}\n\nexport interface WorkspaceFileSnapshot {\n readonly path: string;\n readonly sha256: string;\n}\n\nexport interface WorkspaceSnapshot {\n readonly digest: string;\n readonly files: readonly WorkspaceFileSnapshot[];\n}\n\nexport interface TaskStageRecord {\n readonly index: number;\n readonly id: string;\n readonly kind: StageKind;\n readonly phase: StagePhase;\n readonly status: StageStatus;\n readonly attempt: number;\n readonly command: readonly string[];\n readonly cwd: string | null;\n readonly instructions: string | null;\n readonly startedAt: string | null;\n readonly finishedAt: string | null;\n readonly exitCode: number | null;\n readonly logPath: string | null;\n readonly summary: string | null;\n readonly evidence: readonly string[];\n readonly error: string | null;\n}\n\nexport interface GateRecord {\n readonly taskId: string;\n readonly stageIndex: number;\n readonly gateId: string;\n readonly required: boolean;\n readonly status: GateStatus;\n readonly description: string;\n readonly paths: readonly string[];\n readonly workspaceDigest: string | null;\n readonly details: Readonly<Record<string, unknown>>;\n readonly createdAt: string;\n readonly updatedAt: string;\n}\n\nexport interface TaskRecord {\n readonly id: string;\n /** Isolates active task ownership between Pi terminal sessions. */\n readonly ownerId: string;\n readonly title: string;\n readonly request: string;\n readonly workflowName: string;\n readonly workspace: string;\n readonly status: TaskStatus;\n readonly route: RouteId | null;\n readonly strategyId: string | null;\n readonly complexity: Complexity | null;\n readonly risk: RiskLevel | null;\n readonly scope: RouteScope;\n readonly currentStageIndex: number;\n readonly revision: number;\n readonly planVersion: number;\n readonly baselineDigest: string | null;\n readonly validatedDigest: string | null;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly stages: readonly TaskStageRecord[];\n readonly gates: readonly GateRecord[];\n}\n\nexport interface TaskEvent {\n readonly eventId: string;\n readonly sequence: number;\n readonly taskId: string;\n readonly type: string;\n readonly payload: Readonly<Record<string, unknown>>;\n readonly dedupeKey: string | null;\n readonly createdAt: string;\n}\n\nexport type HookKind = \"transform\" | \"guard\" | \"observer\" | \"cleanup\";\nexport type HookInvocationStatus =\n | \"scheduled\"\n | \"started\"\n | \"succeeded\"\n | \"blocked\"\n | \"failed\"\n | \"timed_out\"\n | \"cancelled\"\n | \"interrupted\";\n\nexport interface HookInvocation {\n readonly invocationId: string;\n readonly taskId: string;\n readonly stageId: string;\n readonly attempt: number;\n readonly revision: number;\n readonly pluginId: string;\n readonly hookName: string;\n readonly kind: HookKind;\n readonly inputRef: string;\n readonly status: HookInvocationStatus;\n readonly result: Readonly<Record<string, unknown>> | null;\n readonly error: string | null;\n readonly scheduledAt: string;\n readonly startedAt: string | null;\n readonly finishedAt: string | null;\n}\n\nexport type GuardResult =\n | { readonly action: \"continue\" }\n | { readonly action: \"wait\"; readonly request: string }\n | { readonly action: \"block\"; readonly reason: string };\n\nexport interface PluginDescriptor {\n readonly id: string;\n readonly apiVersion: typeof PIUP_API_VERSION;\n readonly capabilities: readonly string[];\n}\n"],"mappings":";AAAA,MAAa,mBAAmB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@piup/contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared TypeScript contracts for piup workflows, tasks, Gates, and plugins.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"import": "./dist/index.mjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.19.0"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Keylenn/piup.git",
|
|
25
|
+
"directory": "packages/contracts"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Keylenn/piup#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/Keylenn/piup/issues"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|