@davidorex/pi-workflows 0.2.0 → 0.3.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/CHANGELOG.md +7 -4
- package/README.md +12 -2
- package/agents/architecture-designer.agent.yaml +58 -0
- package/agents/architecture-inferrer.agent.yaml +60 -0
- package/agents/gap-identifier.agent.yaml +66 -0
- package/agents/handoff-writer.agent.yaml +64 -0
- package/agents/plan-creator.agent.yaml +63 -0
- package/agents/project-definer.agent.yaml +53 -0
- package/agents/project-inferrer.agent.yaml +63 -0
- package/agents/requirements-gatherer.agent.yaml +58 -0
- package/dist/agent-spec.d.ts +27 -0
- package/dist/agent-spec.d.ts.map +1 -0
- package/dist/agent-spec.js +112 -0
- package/dist/agent-spec.js.map +1 -0
- package/dist/checkpoint.d.ts +50 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +109 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/completion.d.ts +18 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +58 -0
- package/dist/completion.js.map +1 -0
- package/dist/dag.d.ts +56 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +178 -0
- package/dist/dag.js.map +1 -0
- package/dist/dispatch.d.ts +35 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +311 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/expression.d.ts +64 -0
- package/dist/expression.d.ts.map +1 -0
- package/dist/expression.js +294 -0
- package/dist/expression.js.map +1 -0
- package/dist/format.d.ts +19 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +42 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +724 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +12 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +59 -0
- package/dist/output.js.map +1 -0
- package/dist/state.d.ts +66 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +227 -0
- package/dist/state.js.map +1 -0
- package/dist/step-agent.d.ts +35 -0
- package/dist/step-agent.d.ts.map +1 -0
- package/dist/step-agent.js +171 -0
- package/dist/step-agent.js.map +1 -0
- package/dist/step-command.d.ts +21 -0
- package/dist/step-command.d.ts.map +1 -0
- package/dist/step-command.js +150 -0
- package/dist/step-command.js.map +1 -0
- package/dist/step-foreach.d.ts +33 -0
- package/dist/step-foreach.d.ts.map +1 -0
- package/dist/step-foreach.js +112 -0
- package/dist/step-foreach.js.map +1 -0
- package/dist/step-gate.d.ts +18 -0
- package/dist/step-gate.d.ts.map +1 -0
- package/dist/step-gate.js +137 -0
- package/dist/step-gate.js.map +1 -0
- package/dist/step-loop.d.ts +32 -0
- package/dist/step-loop.d.ts.map +1 -0
- package/dist/step-loop.js +278 -0
- package/dist/step-loop.js.map +1 -0
- package/dist/step-monitor.d.ts +56 -0
- package/dist/step-monitor.d.ts.map +1 -0
- package/dist/step-monitor.js +317 -0
- package/dist/step-monitor.js.map +1 -0
- package/dist/step-parallel.d.ts +43 -0
- package/dist/step-parallel.d.ts.map +1 -0
- package/dist/step-parallel.js +122 -0
- package/dist/step-parallel.js.map +1 -0
- package/{src/step-pause.ts → dist/step-pause.d.ts} +3 -13
- package/dist/step-pause.d.ts.map +1 -0
- package/dist/step-pause.js +22 -0
- package/dist/step-pause.js.map +1 -0
- package/dist/step-shared.d.ts +63 -0
- package/dist/step-shared.d.ts.map +1 -0
- package/dist/step-shared.js +136 -0
- package/dist/step-shared.js.map +1 -0
- package/dist/step-transform.d.ts +11 -0
- package/dist/step-transform.d.ts.map +1 -0
- package/dist/step-transform.js +41 -0
- package/dist/step-transform.js.map +1 -0
- package/dist/template.d.ts +51 -0
- package/dist/template.d.ts.map +1 -0
- package/{src/template.ts → dist/template.js} +32 -38
- package/dist/template.js.map +1 -0
- package/dist/test-helpers.d.ts +17 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +46 -0
- package/dist/test-helpers.js.map +1 -0
- package/dist/tui.d.ts +47 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +143 -0
- package/dist/tui.js.map +1 -0
- package/dist/types.d.ts +165 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/workflow-discovery.d.ts +23 -0
- package/dist/workflow-discovery.d.ts.map +1 -0
- package/dist/workflow-discovery.js +103 -0
- package/dist/workflow-discovery.js.map +1 -0
- package/dist/workflow-executor.d.ts +50 -0
- package/dist/workflow-executor.d.ts.map +1 -0
- package/dist/workflow-executor.js +738 -0
- package/dist/workflow-executor.js.map +1 -0
- package/dist/workflow-sdk.d.ts +44 -0
- package/dist/workflow-sdk.d.ts.map +1 -0
- package/dist/workflow-sdk.js +457 -0
- package/dist/workflow-sdk.js.map +1 -0
- package/dist/workflow-spec.d.ts +33 -0
- package/dist/workflow-spec.d.ts.map +1 -0
- package/dist/workflow-spec.js +476 -0
- package/dist/workflow-spec.js.map +1 -0
- package/dist/workflows-dir.d.ts +3 -0
- package/dist/workflows-dir.d.ts.map +1 -0
- package/{src/workflows-dir.ts → dist/workflows-dir.js} +1 -0
- package/dist/workflows-dir.js.map +1 -0
- package/package.json +53 -38
- package/schemas/decomposition-specs.schema.json +48 -48
- package/schemas/execution-results.schema.json +48 -48
- package/schemas/investigation-findings.schema.json +43 -43
- package/schemas/pattern-analysis.schema.json +41 -41
- package/schemas/phase.schema.json +48 -0
- package/schemas/plan-breakdown.schema.json +20 -20
- package/schemas/quality-analysis.schema.json +33 -33
- package/schemas/research-findings.schema.json +42 -42
- package/schemas/structure-analysis.schema.json +40 -40
- package/schemas/synthesis.schema.json +31 -31
- package/schemas/verifier-output.schema.json +94 -94
- package/skill-narrative.md +107 -0
- package/skills/pi-workflows/SKILL.md +185 -0
- package/skills/pi-workflows/references/bundled-resources.md +87 -0
- package/templates/architecture-designer/task.md +117 -0
- package/templates/architecture-inferrer/task.md +61 -0
- package/templates/gap-identifier/task.md +103 -0
- package/templates/handoff-writer/task.md +91 -0
- package/templates/plan-creator/task.md +143 -0
- package/templates/project-definer/task.md +67 -0
- package/templates/project-inferrer/task.md +56 -0
- package/templates/requirements-gatherer/task.md +90 -0
- package/workflows/analyze-existing-project.workflow.yaml +94 -0
- package/workflows/create-handoff.workflow.yaml +66 -0
- package/workflows/create-phase.workflow.yaml +1 -1
- package/workflows/do-gap.workflow.yaml +4 -4
- package/workflows/fix-audit.workflow.yaml +1 -1
- package/workflows/gap-to-phase.workflow.yaml +1 -1
- package/workflows/init-new-project.workflow.yaml +81 -0
- package/workflows/plan-from-requirements.workflow.yaml +59 -0
- package/workflows/self-implement.workflow.yaml +3 -3
- package/workflows/typed-analysis.workflow.yaml +4 -4
- package/src/agent-spec.test.ts +0 -289
- package/src/agent-spec.ts +0 -122
- package/src/block-validation.test.ts +0 -350
- package/src/checkpoint.test.ts +0 -237
- package/src/checkpoint.ts +0 -140
- package/src/completion.test.ts +0 -143
- package/src/completion.ts +0 -68
- package/src/dag.test.ts +0 -350
- package/src/dag.ts +0 -219
- package/src/dispatch.test.ts +0 -475
- package/src/dispatch.ts +0 -353
- package/src/expression.test.ts +0 -353
- package/src/expression.ts +0 -332
- package/src/format.test.ts +0 -80
- package/src/format.ts +0 -41
- package/src/graduated-failure.test.ts +0 -556
- package/src/index.test.ts +0 -114
- package/src/index.ts +0 -516
- package/src/loop.test.ts +0 -551
- package/src/output.test.ts +0 -213
- package/src/output.ts +0 -70
- package/src/parallel-integration.test.ts +0 -175
- package/src/resume.test.ts +0 -192
- package/src/state.test.ts +0 -192
- package/src/state.ts +0 -254
- package/src/step-agent.test.ts +0 -327
- package/src/step-agent.ts +0 -178
- package/src/step-command.test.ts +0 -330
- package/src/step-command.ts +0 -132
- package/src/step-foreach.test.ts +0 -647
- package/src/step-foreach.ts +0 -148
- package/src/step-gate.test.ts +0 -185
- package/src/step-gate.ts +0 -116
- package/src/step-loop.test.ts +0 -626
- package/src/step-loop.ts +0 -323
- package/src/step-parallel.test.ts +0 -475
- package/src/step-parallel.ts +0 -168
- package/src/step-pause.test.ts +0 -30
- package/src/step-shared.test.ts +0 -355
- package/src/step-shared.ts +0 -157
- package/src/step-transform.test.ts +0 -155
- package/src/step-transform.ts +0 -47
- package/src/template-integration.test.ts +0 -72
- package/src/template.test.ts +0 -162
- package/src/test-helpers.ts +0 -51
- package/src/tui.test.ts +0 -355
- package/src/tui.ts +0 -182
- package/src/types.ts +0 -195
- package/src/verifier-schema.test.ts +0 -226
- package/src/workflow-discovery.test.ts +0 -105
- package/src/workflow-discovery.ts +0 -114
- package/src/workflow-executor.test.ts +0 -1532
- package/src/workflow-executor.ts +0 -810
- package/src/workflow-sdk.test.ts +0 -238
- package/src/workflow-sdk.ts +0 -262
- package/src/workflow-spec.test.ts +0 -576
- package/src/workflow-spec.ts +0 -471
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import assert from "node:assert";
|
|
3
|
-
import { discoverWorkflows, findWorkflow } from "./workflow-discovery.ts";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import os from "node:os";
|
|
7
|
-
|
|
8
|
-
// Use a nonexistent dir as builtinDir so tests don't pick up real demo workflows
|
|
9
|
-
const NO_BUILTINS = path.join(os.tmpdir(), "wf-no-builtins-nonexistent");
|
|
10
|
-
|
|
11
|
-
describe("discoverWorkflows", () => {
|
|
12
|
-
it("discovers workflows from project directory", () => {
|
|
13
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
14
|
-
const wfDir = path.join(tmpDir, ".workflows");
|
|
15
|
-
fs.mkdirSync(wfDir, { recursive: true });
|
|
16
|
-
fs.writeFileSync(
|
|
17
|
-
path.join(wfDir, "test.workflow.yaml"),
|
|
18
|
-
"name: test\nsteps:\n s:\n agent: a",
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const specs = discoverWorkflows(tmpDir, NO_BUILTINS);
|
|
22
|
-
assert.strictEqual(specs.length, 1);
|
|
23
|
-
assert.strictEqual(specs[0].name, "test");
|
|
24
|
-
assert.strictEqual(specs[0].source, "project");
|
|
25
|
-
|
|
26
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("returns empty array when no workflow directories exist", () => {
|
|
30
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
31
|
-
const specs = discoverWorkflows(tmpDir, NO_BUILTINS);
|
|
32
|
-
assert.strictEqual(specs.length, 0);
|
|
33
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("skips invalid specs with warning (no throw)", () => {
|
|
37
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
38
|
-
const wfDir = path.join(tmpDir, ".workflows");
|
|
39
|
-
fs.mkdirSync(wfDir, { recursive: true });
|
|
40
|
-
fs.writeFileSync(path.join(wfDir, "bad.workflow.yaml"), "not: valid: workflow");
|
|
41
|
-
fs.writeFileSync(
|
|
42
|
-
path.join(wfDir, "good.workflow.yaml"),
|
|
43
|
-
"name: good\nsteps:\n s:\n agent: a",
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const specs = discoverWorkflows(tmpDir, NO_BUILTINS);
|
|
47
|
-
assert.strictEqual(specs.length, 1);
|
|
48
|
-
assert.strictEqual(specs[0].name, "good");
|
|
49
|
-
|
|
50
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("project specs shadow user specs with same name", () => {
|
|
54
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
55
|
-
const projectDir = path.join(tmpDir, ".workflows");
|
|
56
|
-
fs.mkdirSync(projectDir, { recursive: true });
|
|
57
|
-
fs.writeFileSync(
|
|
58
|
-
path.join(projectDir, "shared.workflow.yaml"),
|
|
59
|
-
"name: shared\ndescription: project version\nsteps:\n s:\n agent: a",
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const specs = discoverWorkflows(tmpDir, NO_BUILTINS);
|
|
63
|
-
assert.strictEqual(specs.length, 1);
|
|
64
|
-
assert.strictEqual(specs[0].source, "project");
|
|
65
|
-
|
|
66
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("discovers builtin demo workflows", () => {
|
|
70
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
71
|
-
const demoDir = path.resolve(import.meta.dirname, "..", "workflows");
|
|
72
|
-
|
|
73
|
-
const specs = discoverWorkflows(tmpDir, demoDir);
|
|
74
|
-
assert.ok(specs.length > 0, "should find at least one demo workflow");
|
|
75
|
-
|
|
76
|
-
const names = specs.map((s) => s.name);
|
|
77
|
-
assert.ok(names.includes("typed-analysis"), "should find typed-analysis demo");
|
|
78
|
-
|
|
79
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("findWorkflow", () => {
|
|
84
|
-
it("finds a workflow by name", () => {
|
|
85
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
86
|
-
const wfDir = path.join(tmpDir, ".workflows");
|
|
87
|
-
fs.mkdirSync(wfDir, { recursive: true });
|
|
88
|
-
fs.writeFileSync(
|
|
89
|
-
path.join(wfDir, "bugfix.workflow.yaml"),
|
|
90
|
-
"name: bugfix\nsteps:\n s:\n agent: a",
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const spec = findWorkflow("bugfix", tmpDir, NO_BUILTINS);
|
|
94
|
-
assert.ok(spec);
|
|
95
|
-
assert.strictEqual(spec.name, "bugfix");
|
|
96
|
-
|
|
97
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("returns undefined for unknown workflow", () => {
|
|
101
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "wf-test-"));
|
|
102
|
-
assert.strictEqual(findWorkflow("nonexistent", tmpDir, NO_BUILTINS), undefined);
|
|
103
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import type { WorkflowSpec } from "./types.ts";
|
|
5
|
-
import { parseWorkflowSpec } from "./workflow-spec.ts";
|
|
6
|
-
import { WORKFLOWS_DIR } from "./workflows-dir.ts";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Discover all workflow specs from project, user, and builtin directories.
|
|
10
|
-
*
|
|
11
|
-
* Scans (highest priority first):
|
|
12
|
-
* 1. .workflows/ (project-level, source: "project")
|
|
13
|
-
* 2. ~/.pi/agent/workflows/ (user-level, source: "user")
|
|
14
|
-
* 3. <package>/workflows/ (builtin workflows, source: "user")
|
|
15
|
-
*
|
|
16
|
-
* Higher-priority specs shadow lower-priority specs with the same name.
|
|
17
|
-
*
|
|
18
|
-
* @param cwd - current working directory (project root)
|
|
19
|
-
* @param builtinDir - optional path to builtin workflows (defaults to workflows/ relative to package root)
|
|
20
|
-
* @returns Array of parsed WorkflowSpec objects. Specs that fail parsing are
|
|
21
|
-
* skipped with a warning (logged to stderr), not thrown.
|
|
22
|
-
*/
|
|
23
|
-
export function discoverWorkflows(cwd: string, builtinDir?: string): WorkflowSpec[] {
|
|
24
|
-
const projectDir = path.join(cwd, WORKFLOWS_DIR);
|
|
25
|
-
const userDir = path.join(os.homedir(), ".pi", "agent", "workflows");
|
|
26
|
-
const demoDir = builtinDir ?? path.resolve(import.meta.dirname, "..", "workflows");
|
|
27
|
-
|
|
28
|
-
const projectSpecs = scanDirectory(projectDir, "project");
|
|
29
|
-
const userSpecs = scanDirectory(userDir, "user");
|
|
30
|
-
const builtinSpecs = scanDirectory(demoDir, "user");
|
|
31
|
-
|
|
32
|
-
// Deduplicate: project > user > builtin (last write wins, so add lowest priority first)
|
|
33
|
-
const byName = new Map<string, WorkflowSpec>();
|
|
34
|
-
|
|
35
|
-
for (const spec of builtinSpecs) {
|
|
36
|
-
byName.set(spec.name, spec);
|
|
37
|
-
}
|
|
38
|
-
for (const spec of userSpecs) {
|
|
39
|
-
byName.set(spec.name, spec);
|
|
40
|
-
}
|
|
41
|
-
for (const spec of projectSpecs) {
|
|
42
|
-
byName.set(spec.name, spec);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Return sorted by name
|
|
46
|
-
const result = Array.from(byName.values());
|
|
47
|
-
result.sort((a, b) => a.name.localeCompare(b.name));
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Find a workflow by name from discovered workflows.
|
|
53
|
-
* Returns undefined if not found.
|
|
54
|
-
*/
|
|
55
|
-
export function findWorkflow(name: string, cwd: string, builtinDir?: string): WorkflowSpec | undefined {
|
|
56
|
-
const specs = discoverWorkflows(cwd, builtinDir);
|
|
57
|
-
return specs.find((s) => s.name === name);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Scan a directory for *.workflow.yaml files and parse them.
|
|
62
|
-
* Non-recursive. Returns parsed specs; logs warnings for parse failures.
|
|
63
|
-
*/
|
|
64
|
-
function scanDirectory(dirPath: string, source: "user" | "project"): WorkflowSpec[] {
|
|
65
|
-
if (!fs.existsSync(dirPath)) {
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let entries: string[];
|
|
70
|
-
try {
|
|
71
|
-
entries = fs.readdirSync(dirPath);
|
|
72
|
-
} catch {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const specs: WorkflowSpec[] = [];
|
|
77
|
-
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
if (!entry.endsWith(".workflow.yaml")) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const filePath = path.join(dirPath, entry);
|
|
84
|
-
|
|
85
|
-
// Only process files, not directories
|
|
86
|
-
let stat: fs.Stats;
|
|
87
|
-
try {
|
|
88
|
-
stat = fs.statSync(filePath);
|
|
89
|
-
} catch {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (!stat.isFile()) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let content: string;
|
|
97
|
-
try {
|
|
98
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
99
|
-
} catch {
|
|
100
|
-
console.error(`[pi-workflows] Warning: skipping ${filePath}: could not read file`);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const spec = parseWorkflowSpec(content, filePath, source);
|
|
106
|
-
specs.push(spec);
|
|
107
|
-
} catch (err) {
|
|
108
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
109
|
-
console.error(`[pi-workflows] Warning: skipping ${filePath}: ${msg}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return specs;
|
|
114
|
-
}
|