@wichayutdew/pi-workflows 0.1.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.
Files changed (45) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +752 -0
  3. package/agents/step.md +17 -0
  4. package/dist/index.js +4576 -0
  5. package/examples/mr-comments.workflow.yaml +115 -0
  6. package/examples/prompts/mr-comments/implement.md +8 -0
  7. package/examples/prompts/mr-comments/inspect.md +5 -0
  8. package/examples/prompts/mr-comments/plan.md +13 -0
  9. package/examples/prompts/mr-comments/verify.md +7 -0
  10. package/examples/settings.yaml +19 -0
  11. package/package.json +81 -0
  12. package/schemas/settings.schema.json +22 -0
  13. package/schemas/workflow.schema.json +585 -0
  14. package/src/command-names.ts +46 -0
  15. package/src/commands.ts +80 -0
  16. package/src/config/ceiling.ts +153 -0
  17. package/src/config/command-conflicts.ts +31 -0
  18. package/src/config/load.ts +327 -0
  19. package/src/config/types.ts +187 -0
  20. package/src/config/validate.ts +1145 -0
  21. package/src/digest.ts +23 -0
  22. package/src/engine/checkpoint.ts +30 -0
  23. package/src/engine/resume.ts +44 -0
  24. package/src/engine/state.ts +186 -0
  25. package/src/engine/transitions.ts +426 -0
  26. package/src/harness.ts +1676 -0
  27. package/src/index.ts +15 -0
  28. package/src/integrations/plannotator.ts +235 -0
  29. package/src/integrations/prompt-gate.ts +54 -0
  30. package/src/integrations/subagents/child-runtime.ts +306 -0
  31. package/src/integrations/subagents/client.ts +239 -0
  32. package/src/integrations/subagents/protocol.ts +304 -0
  33. package/src/policy/approved-commands.ts +225 -0
  34. package/src/policy/bash.ts +355 -0
  35. package/src/policy/completion-batch.ts +36 -0
  36. package/src/policy/immutable-input.ts +18 -0
  37. package/src/policy/tools.ts +150 -0
  38. package/src/preflight.ts +76 -0
  39. package/src/prompt.ts +146 -0
  40. package/src/runtime/completion-tool.ts +22 -0
  41. package/src/runtime/main-step-runtime.ts +227 -0
  42. package/src/runtime/serial-task-queue.ts +17 -0
  43. package/src/runtime/step-result.ts +85 -0
  44. package/src/workflow-list.ts +25 -0
  45. package/src/workflow-status.ts +611 -0
@@ -0,0 +1,115 @@
1
+ # yaml-language-server: $schema=../schemas/workflow.schema.json
2
+ version: 1
3
+ id: mr-comments
4
+ command: mr-comments
5
+ description: Inspect merge-request feedback, plan changes, implement, and verify
6
+ start: inspect
7
+ maxStepVisits: 5
8
+ summaryMaxChars: 4000
9
+ steps:
10
+ inspect:
11
+ title: Inspect merge request
12
+ prompt:
13
+ file: prompts/mr-comments/inspect.md
14
+ subagent:
15
+ agent: pi-workflows.step
16
+ context: fresh
17
+ timeoutMs: 600000
18
+ turnBudget:
19
+ maxTurns: 12
20
+ graceTurns: 2
21
+ permissions:
22
+ tools: [read, grep, bash]
23
+ mcp: [gitlab/get_merge_request, gitlab/list_merge_request_discussions]
24
+ bash:
25
+ mode: read-only
26
+ requires:
27
+ tools: [read, bash, mcp]
28
+ transitions:
29
+ ready: plan
30
+ blocked: $pause
31
+ plan:
32
+ title: Plan the change
33
+ prompt:
34
+ file: prompts/mr-comments/plan.md
35
+ subagent:
36
+ agent: pi-workflows.step
37
+ context: fresh
38
+ timeoutMs: 600000
39
+ turnBudget:
40
+ maxTurns: 16
41
+ graceTurns: 2
42
+ permissions:
43
+ tools: [read, grep, bash]
44
+ mcp: [gitlab/get_merge_request, gitlab/list_merge_request_discussions]
45
+ extensions: [plannotator]
46
+ skills: [superpowers:brainstorming]
47
+ bash:
48
+ mode: read-only
49
+ requires:
50
+ tools: [read, mcp]
51
+ extensions: [plannotator]
52
+ skills: [superpowers:brainstorming]
53
+ gate:
54
+ provider: plannotator
55
+ submitOutcome: submit
56
+ approvedOutcome: approved
57
+ rejectedOutcome: changes-requested
58
+ timeoutMs: 5000
59
+ transitions:
60
+ approved: implement
61
+ changes-requested: plan
62
+ blocked: $pause
63
+ implement:
64
+ title: Implement the approved plan
65
+ prompt:
66
+ file: prompts/mr-comments/implement.md
67
+ subagent:
68
+ agent: pi-workflows.step
69
+ context: fresh
70
+ timeoutMs: 1200000
71
+ artifacts: true
72
+ permissions:
73
+ tools: [read, grep, edit, write, bash]
74
+ skills: [superpowers:test-driven-development]
75
+ bash:
76
+ mode: allow-list
77
+ allow:
78
+ - executable: git
79
+ argsPrefixes: [[status], [diff]]
80
+ - executable: npm
81
+ argsPrefix: [test]
82
+ approvedSources: [verification-worker]
83
+ requires:
84
+ tools: [read, edit, bash]
85
+ skills: [superpowers:test-driven-development]
86
+ transitions:
87
+ ready: verify
88
+ blocked: $pause
89
+ verify:
90
+ title: Verify the result
91
+ prompt:
92
+ file: prompts/mr-comments/verify.md
93
+ subagent:
94
+ agent: pi-workflows.step
95
+ context: fresh
96
+ timeoutMs: 600000
97
+ turnBudget:
98
+ maxTurns: 16
99
+ graceTurns: 2
100
+ permissions:
101
+ tools: [read, grep, bash]
102
+ bash:
103
+ mode: allow-list
104
+ allow:
105
+ - executable: git
106
+ argsPrefixes: [[status], [diff]]
107
+ - executable: npm
108
+ argsPrefix: [test]
109
+ approvedSources: [verification-reviewer]
110
+ requires:
111
+ tools: [read, bash]
112
+ transitions:
113
+ passed: $done
114
+ failed: implement
115
+ blocked: $pause
@@ -0,0 +1,8 @@
1
+ Implement the approved plan with a small, coherent diff.
2
+
3
+ Use repository conventions and the allowed skill. Add or update focused tests
4
+ where practical. Run only exact reviewed worker commands plus the static
5
+ allow-list. Do not perform remote actions. Complete with `ready` when
6
+ implementation and focused checks are complete; include the exact fenced JSON
7
+ contract in the summary for verification. Complete with `blocked` if the
8
+ harness, configuration, or repository must be fixed first.
@@ -0,0 +1,5 @@
1
+ Inspect the merge request described by:
2
+
3
+ {{workflow.input}}
4
+
5
+ Read the relevant discussion and repository state. Separate facts from assumptions. Do not modify files. When the requested work is clear, complete with `ready`. If identity, access, or requirements are unresolved, complete with `blocked`.
@@ -0,0 +1,13 @@
1
+ Create a concrete implementation plan from the inspected feedback.
2
+
3
+ Include scope, exact files or symbols, risks, and verification. Account for prior review feedback:
4
+
5
+ {{gate.feedback}}
6
+
7
+ Include one fenced `json` verification contract with a top-level
8
+ `repositories` array. Put exact standalone implementation commands under
9
+ `worker[].command` and independent commands under `reviewer[].command`.
10
+
11
+ When the plan is ready, call `workflow_complete_step` with outcome `submit` and
12
+ place the full Markdown plan in `artifact`. The Plannotator gate decides the
13
+ next transition; its reviewed artifact becomes the next step's handoff.
@@ -0,0 +1,7 @@
1
+ Review the implementation against the requested merge-request feedback and approved plan.
2
+
3
+ Inspect the diff and run the exact reviewed reviewer commands plus the static
4
+ allow-list. Complete with `passed` only when evidence supports completion.
5
+ Complete with `failed` to return to implementation and preserve the exact
6
+ fenced JSON contract in the summary, or `blocked` when a human must repair the
7
+ workflow or environment.
@@ -0,0 +1,19 @@
1
+ # yaml-language-server: $schema=../schemas/settings.schema.json
2
+ version: 1
3
+ allowProjectWorkflows: false
4
+ permissionCeiling:
5
+ tools: [read, grep, bash]
6
+ mcp: []
7
+ extensions: []
8
+ skills: []
9
+ bash:
10
+ mode: read-only
11
+ subagent:
12
+ agents: [pi-workflows.step, scout, worker, reviewer]
13
+ contexts: [fresh]
14
+ models: []
15
+ maxTimeoutMs: 900000
16
+ maxTurns: 40
17
+ maxGraceTurns: 3
18
+ maxToolCalls: 100
19
+ artifacts: false
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@wichayutdew/pi-workflows",
3
+ "version": "0.1.1",
4
+ "description": "A declarative, pauseable workflow harness for Pi",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/wichayutdew/pi-workflows.git"
9
+ },
10
+ "homepage": "https://github.com/wichayutdew/pi-workflows#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/wichayutdew/pi-workflows/issues"
13
+ },
14
+ "type": "module",
15
+ "keywords": [
16
+ "pi-package",
17
+ "pi",
18
+ "workflow",
19
+ "agent"
20
+ ],
21
+ "files": [
22
+ "dist",
23
+ "src",
24
+ "agents",
25
+ "examples",
26
+ "schemas",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "pi": {
31
+ "extensions": [
32
+ "./src/index.ts"
33
+ ],
34
+ "subagents": {
35
+ "agents": [
36
+ "./agents"
37
+ ]
38
+ }
39
+ },
40
+ "scripts": {
41
+ "build": "bun build ./src/index.ts --outdir=dist --target=node --format=esm --packages=external",
42
+ "format": "bunx --bun prettier . --write",
43
+ "format:check": "bunx --bun prettier . --check",
44
+ "lint": "bun --bun eslint .",
45
+ "lint:fix": "bun --bun eslint . --fix",
46
+ "test": "bun test",
47
+ "typecheck": "tsc --noEmit",
48
+ "check": "bun run lint && bun run format:check && bun run typecheck && bun test && bun run build"
49
+ },
50
+ "dependencies": {
51
+ "yaml": "^2.8.3"
52
+ },
53
+ "peerDependencies": {
54
+ "@earendil-works/pi-coding-agent": "*",
55
+ "@earendil-works/pi-tui": "*",
56
+ "pi-subagents": ">=0.35.1",
57
+ "typebox": "*"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "pi-subagents": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@earendil-works/pi-coding-agent": "^0.81.1",
66
+ "@earendil-works/pi-tui": "^0.81.1",
67
+ "@eslint/js": "^10.0.1",
68
+ "@types/node": "^24.0.0",
69
+ "eslint": "^10.7.0",
70
+ "globals": "^17.7.0",
71
+ "pi-subagents": "^0.35.1",
72
+ "prettier": "^3.9.5",
73
+ "typebox": "^1.1.38",
74
+ "typescript": "^5.9.3",
75
+ "typescript-eslint": "^8.64.0"
76
+ },
77
+ "packageManager": "bun@1.3.14",
78
+ "engines": {
79
+ "node": ">=22.19.0"
80
+ }
81
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Pi workflows settings",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["version"],
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string"
10
+ },
11
+ "version": {
12
+ "const": 1
13
+ },
14
+ "allowProjectWorkflows": {
15
+ "type": "boolean",
16
+ "default": false
17
+ },
18
+ "permissionCeiling": {
19
+ "$ref": "workflow.schema.json#/$defs/permissionCeiling"
20
+ }
21
+ }
22
+ }