pactwright 0.0.1
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 +201 -0
- package/README.md +68 -0
- package/dist/adapter/claude-code.d.ts +53 -0
- package/dist/adapter/claude-code.js +241 -0
- package/dist/adapter/commands.d.ts +19 -0
- package/dist/adapter/commands.js +162 -0
- package/dist/atomic.d.ts +6 -0
- package/dist/atomic.js +11 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +561 -0
- package/dist/config/config.d.ts +55 -0
- package/dist/config/config.js +199 -0
- package/dist/config/lifecycle.d.ts +34 -0
- package/dist/config/lifecycle.js +81 -0
- package/dist/config/lock.d.ts +43 -0
- package/dist/config/lock.js +141 -0
- package/dist/context.d.ts +59 -0
- package/dist/context.js +111 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +25 -0
- package/dist/eval/case.d.ts +123 -0
- package/dist/eval/case.js +17 -0
- package/dist/eval/core-suite.d.ts +3 -0
- package/dist/eval/core-suite.js +431 -0
- package/dist/eval/runner.d.ts +75 -0
- package/dist/eval/runner.js +159 -0
- package/dist/eval/sandbox.d.ts +39 -0
- package/dist/eval/sandbox.js +143 -0
- package/dist/extension/manage.d.ts +65 -0
- package/dist/extension/manage.js +372 -0
- package/dist/extension/manifest.d.ts +36 -0
- package/dist/extension/manifest.js +164 -0
- package/dist/extension/resolve.d.ts +77 -0
- package/dist/extension/resolve.js +271 -0
- package/dist/graph/edge-schema.d.ts +55 -0
- package/dist/graph/edge-schema.js +0 -0
- package/dist/graph/edges.d.ts +22 -0
- package/dist/graph/edges.js +63 -0
- package/dist/graph/ids.d.ts +14 -0
- package/dist/graph/ids.js +38 -0
- package/dist/graph/lineage.d.ts +48 -0
- package/dist/graph/lineage.js +226 -0
- package/dist/graph/mutations.d.ts +108 -0
- package/dist/graph/mutations.js +356 -0
- package/dist/graph/nodes.d.ts +46 -0
- package/dist/graph/nodes.js +137 -0
- package/dist/graph/revision.d.ts +50 -0
- package/dist/graph/revision.js +75 -0
- package/dist/graph/schema.d.ts +54 -0
- package/dist/graph/schema.js +90 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +33 -0
- package/dist/init.d.ts +47 -0
- package/dist/init.js +132 -0
- package/dist/lifecycle/engine.d.ts +75 -0
- package/dist/lifecycle/engine.js +146 -0
- package/dist/lifecycle/record.d.ts +18 -0
- package/dist/lifecycle/record.js +157 -0
- package/dist/lifecycle/run.d.ts +62 -0
- package/dist/lifecycle/run.js +167 -0
- package/dist/loader.d.ts +38 -0
- package/dist/loader.js +64 -0
- package/dist/pack/capabilities.d.ts +22 -0
- package/dist/pack/capabilities.js +31 -0
- package/dist/pack/locate.d.ts +22 -0
- package/dist/pack/locate.js +80 -0
- package/dist/pack/manifest.d.ts +34 -0
- package/dist/pack/manifest.js +168 -0
- package/dist/pack/resolve.d.ts +92 -0
- package/dist/pack/resolve.js +238 -0
- package/dist/project.d.ts +22 -0
- package/dist/project.js +37 -0
- package/dist/sync.d.ts +54 -0
- package/dist/sync.js +98 -0
- package/dist/validate.d.ts +23 -0
- package/dist/validate.js +32 -0
- package/dist/validation.d.ts +24 -0
- package/dist/validation.js +83 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +8 -0
- package/dist/yaml.d.ts +12 -0
- package/dist/yaml.js +32 -0
- package/package.json +65 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { CORE_STAGES } from "../config/lifecycle.js";
|
|
2
|
+
const RECORD = (stage, fields) => [
|
|
3
|
+
`## 3. Hand the result to the runtime`,
|
|
4
|
+
``,
|
|
5
|
+
`Write a YAML file in a temporary location outside the repository with:`,
|
|
6
|
+
``,
|
|
7
|
+
"```yaml",
|
|
8
|
+
fields,
|
|
9
|
+
"```",
|
|
10
|
+
``,
|
|
11
|
+
`Then run \`pnpm pactwright lifecycle record ${stage} --file <path>\`.`,
|
|
12
|
+
`The runtime checks the transition, validates the complete graph and writes`,
|
|
13
|
+
`the record. Do not create or edit anything under \`specs/\` yourself.`,
|
|
14
|
+
].join("\n");
|
|
15
|
+
const TRANSIENT = [
|
|
16
|
+
`## 3. Report, do not record`,
|
|
17
|
+
``,
|
|
18
|
+
`This stage leaves no graph record. Present the result to the user. Do not`,
|
|
19
|
+
`create or edit anything under \`specs/\`.`,
|
|
20
|
+
].join("\n");
|
|
21
|
+
const STOP = [
|
|
22
|
+
`## 4. Stop`,
|
|
23
|
+
``,
|
|
24
|
+
`Show the runtime output verbatim and stop. Do not run another adapter`,
|
|
25
|
+
`command; the user decides what to do next.`,
|
|
26
|
+
].join("\n");
|
|
27
|
+
const delegate = (agent, task) => agent === undefined
|
|
28
|
+
? task
|
|
29
|
+
: `Use the \`${agent}\` agent (from \`.claude/agents/${agent}.md\`) for this. Give it the runtime context verbatim. ${task}`;
|
|
30
|
+
export const COMMAND_TEMPLATES = [
|
|
31
|
+
{
|
|
32
|
+
stage: "capture-intent",
|
|
33
|
+
description: "Capture a new Delivery intent from text",
|
|
34
|
+
argumentHint: "<text>",
|
|
35
|
+
body: () => [
|
|
36
|
+
`## 2. Shape the intent`,
|
|
37
|
+
``,
|
|
38
|
+
`\`$ARGUMENTS\` is the whole intent text. Derive a short title (under ten`,
|
|
39
|
+
`words) from it. The body is the text as given, restated only if it is`,
|
|
40
|
+
`not already a clear statement of who is affected, the outcome wanted and`,
|
|
41
|
+
`any constraint. Target 300 words or fewer. Do not add solutions.`,
|
|
42
|
+
``,
|
|
43
|
+
RECORD("capture-intent", `title: <title>\nbody: |\n <intent body>`),
|
|
44
|
+
``,
|
|
45
|
+
STOP,
|
|
46
|
+
].join("\n"),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
stage: "propose-contracts",
|
|
50
|
+
description: "Generate transient contract alternatives for an intent",
|
|
51
|
+
argumentHint: "<intent-id>",
|
|
52
|
+
capability: "delivery-specification",
|
|
53
|
+
body: (agent) => [
|
|
54
|
+
`## 2. Propose alternatives`,
|
|
55
|
+
``,
|
|
56
|
+
delegate(agent, `Produce two to four genuinely different contract alternatives for the intent. Label them A, B, C, D.`),
|
|
57
|
+
``,
|
|
58
|
+
TRANSIENT,
|
|
59
|
+
`Alternatives are transient material for a decision; they are not saved.`,
|
|
60
|
+
``,
|
|
61
|
+
STOP,
|
|
62
|
+
].join("\n"),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
stage: "approve-contract",
|
|
66
|
+
description: "Record the human decision on an intent and its canonical contract",
|
|
67
|
+
argumentHint: "<intent-id> <alternative> [notes]",
|
|
68
|
+
capability: "delivery-specification",
|
|
69
|
+
body: (agent) => [
|
|
70
|
+
`## 2. Synthesise the canonical contract`,
|
|
71
|
+
``,
|
|
72
|
+
`\`$ARGUMENTS\` is the intent id, the label of the chosen alternative (or`,
|
|
73
|
+
`\`reject\` / \`defer\`) and optional notes. This command is run by a human;`,
|
|
74
|
+
`their choice is the decision.`,
|
|
75
|
+
``,
|
|
76
|
+
delegate(agent, `For a chosen alternative, write the one canonical contract from it (the contract-writing skill applies). For reject or defer, write nothing but the decision body.`),
|
|
77
|
+
``,
|
|
78
|
+
RECORD("approve-contract", [
|
|
79
|
+
`intent: <intent-id>`,
|
|
80
|
+
`outcome: proceed | reject | defer`,
|
|
81
|
+
`decided_by: human:<handle> # short handle for the deciding human, no spaces (e.g. human:samir)`,
|
|
82
|
+
`body: |`,
|
|
83
|
+
` <why this alternative; include the notes>`,
|
|
84
|
+
`contract: # proceed only`,
|
|
85
|
+
` title: <contract title>`,
|
|
86
|
+
` body: |`,
|
|
87
|
+
` <canonical contract>`,
|
|
88
|
+
].join("\n")),
|
|
89
|
+
`Alternatives that were not chosen are not saved anywhere.`,
|
|
90
|
+
``,
|
|
91
|
+
STOP,
|
|
92
|
+
].join("\n"),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
stage: "write-brief",
|
|
96
|
+
description: "Write the delivery brief for an approved contract",
|
|
97
|
+
argumentHint: "<contract-id>",
|
|
98
|
+
capability: "delivery-specification",
|
|
99
|
+
body: (agent) => [
|
|
100
|
+
`## 2. Write the brief`,
|
|
101
|
+
``,
|
|
102
|
+
delegate(agent, `Inspect the relevant project and repository state and write one focused brief for the contract. Reference the contract; do not copy it.`),
|
|
103
|
+
``,
|
|
104
|
+
RECORD("write-brief", `contract: <contract-id>\ntitle: <brief title>\nbody: |\n <brief>`),
|
|
105
|
+
``,
|
|
106
|
+
STOP,
|
|
107
|
+
].join("\n"),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
stage: "deliver-brief",
|
|
111
|
+
description: "Execute a brief against the repository",
|
|
112
|
+
argumentHint: "<brief-id>",
|
|
113
|
+
capability: "delivery-execution",
|
|
114
|
+
body: (agent) => [
|
|
115
|
+
`## 2. Execute the brief`,
|
|
116
|
+
``,
|
|
117
|
+
delegate(agent, `Execute the brief within the contract's scope, run the verification it names and report what changed, file by file, with the real verification result.`),
|
|
118
|
+
``,
|
|
119
|
+
TRANSIENT,
|
|
120
|
+
`Repository changes stay in the working tree for the user to review.`,
|
|
121
|
+
``,
|
|
122
|
+
STOP,
|
|
123
|
+
].join("\n"),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
stage: "review",
|
|
127
|
+
description: "Review delivered changes against the contract and brief",
|
|
128
|
+
argumentHint: "<brief-id>",
|
|
129
|
+
capability: "delivery-review",
|
|
130
|
+
body: (agent) => [
|
|
131
|
+
`## 2. Review`,
|
|
132
|
+
``,
|
|
133
|
+
delegate(agent, `Review the contract, the brief, the delivered changes and the required verification. Report findings with file references.`),
|
|
134
|
+
``,
|
|
135
|
+
TRANSIENT,
|
|
136
|
+
`Review reasoning is not graph state.`,
|
|
137
|
+
``,
|
|
138
|
+
STOP,
|
|
139
|
+
].join("\n"),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
stage: "prepare-evidence",
|
|
143
|
+
description: "Record final delivery and verification facts for a brief",
|
|
144
|
+
argumentHint: "<brief-id>",
|
|
145
|
+
capability: "delivery-execution",
|
|
146
|
+
body: (agent) => [
|
|
147
|
+
`## 2. Collect the facts`,
|
|
148
|
+
``,
|
|
149
|
+
delegate(agent, `State what was delivered (files, commits or output references) and the verification that was run with its result. Facts only: no contract, brief or review text, no reasoning. Target 400 words or fewer.`),
|
|
150
|
+
``,
|
|
151
|
+
RECORD("prepare-evidence", `brief: <brief-id>\ntitle: <evidence title>\nbody: |\n <facts>`),
|
|
152
|
+
``,
|
|
153
|
+
STOP,
|
|
154
|
+
].join("\n"),
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
/** Every core stage has exactly one template, in lifecycle order. */
|
|
158
|
+
export function templateFor(stage) {
|
|
159
|
+
return COMMAND_TEMPLATES.find((template) => template.stage === stage);
|
|
160
|
+
}
|
|
161
|
+
// Guard kept next to the data so a stage rename fails typecheck here.
|
|
162
|
+
void CORE_STAGES;
|
package/dist/atomic.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unique temporary sibling path for atomic writes. The pid distinguishes
|
|
3
|
+
* processes; the monotonic counter distinguishes writes within one process,
|
|
4
|
+
* so two writes targeting the same path never collide on their temp file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function tempSibling(target: string): string;
|
package/dist/atomic.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { basename, dirname, join } from "node:path";
|
|
2
|
+
let counter = 0;
|
|
3
|
+
/**
|
|
4
|
+
* A unique temporary sibling path for atomic writes. The pid distinguishes
|
|
5
|
+
* processes; the monotonic counter distinguishes writes within one process,
|
|
6
|
+
* so two writes targeting the same path never collide on their temp file.
|
|
7
|
+
*/
|
|
8
|
+
export function tempSibling(target) {
|
|
9
|
+
counter += 1;
|
|
10
|
+
return join(dirname(target), `.${basename(target)}.tmp-${process.pid}-${counter}`);
|
|
11
|
+
}
|
package/dist/cli.d.ts
ADDED