@pazmo/ai-workflow-kit 3.1.0 → 4.0.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.ko.md +200 -0
- package/README.md +126 -221
- package/assets/graph.mjs +10 -0
- package/assets/readme/workflow-en.png +0 -0
- package/assets/readme/workflow-en.svg +41 -0
- package/assets/readme/workflow-ko.png +0 -0
- package/assets/readme/workflow-ko.svg +41 -0
- package/bin/ai-workflow-kit.mjs +36 -2
- package/package.json +2 -1
- package/skills/workflow/EVALS.md +70 -0
- package/skills/workflow/SKILL.md +6 -6
- package/skills/workflow/references/execution.md +41 -5
- package/skills/workflow/references/graph-engineering.md +102 -0
- package/skills/workflow/references/intake.md +2 -0
- package/skills/workflow/references/skill-integration.md +55 -0
- package/skills/workflow/references/understanding-gate.md +2 -0
- package/src/git-visibility.mjs +19 -12
- package/src/graph/cli.mjs +94 -0
- package/src/graph/executor.mjs +92 -0
- package/src/graph/index.mjs +17 -0
- package/src/graph/planning-graph.mjs +16 -0
- package/src/graph/scheduler.mjs +99 -0
- package/src/graph/storage.mjs +76 -0
- package/src/graph/task-graph.mjs +125 -0
- package/src/graph/workflow.mjs +120 -0
- package/src/install-transaction.mjs +1 -0
- package/src/install.mjs +16 -0
- package/src/managed-block.mjs +3 -1
package/bin/ai-workflow-kit.mjs
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { access, readFile } from 'node:fs/promises';
|
|
2
|
+
import { access, readFile, readdir } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { checkArtifact, checkGate } from '../assets/check.mjs';
|
|
6
6
|
import { installWorkflow, removeWorkflow } from '../src/install.mjs';
|
|
7
|
-
import { checkerVisibility, ignoredCheckerAdvice } from '../src/git-visibility.mjs';
|
|
7
|
+
import { checkerVisibility, fileVisibilities, ignoredCheckerAdvice } from '../src/git-visibility.mjs';
|
|
8
8
|
import { END_MARKER, START_MARKER } from '../src/managed-block.mjs';
|
|
9
9
|
import { HOSTS } from '../src/paths.mjs';
|
|
10
10
|
import { publishStory } from '../src/jira.mjs';
|
|
11
|
+
import { runGraphCommand } from '../src/graph/cli.mjs';
|
|
11
12
|
|
|
12
13
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
13
14
|
|
|
15
|
+
async function graphFiles() {
|
|
16
|
+
return ['.ai-workflow/bin/graph.mjs', ...(await readdir(path.join(packageRoot, 'src/graph')))
|
|
17
|
+
.filter(name => name.endsWith('.mjs')).map(name => `.ai-workflow/graph/${name}`)];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function ignoredGraphFiles(root) {
|
|
21
|
+
const results = await fileVisibilities(root, await graphFiles());
|
|
22
|
+
return results.filter(result => result.status === 'ignored');
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
function help() {
|
|
15
26
|
console.log(`ai-workflow-kit
|
|
16
27
|
|
|
@@ -20,6 +31,11 @@ Usage:
|
|
|
20
31
|
ai-workflow-kit check story|task <file> [--root <dir>]
|
|
21
32
|
ai-workflow-kit check gate G1|G4 <story-file> [--root <dir>]
|
|
22
33
|
ai-workflow-kit jira preview <story-file> [--root <dir>]
|
|
34
|
+
ai-workflow-kit graph init <plan.json|-> <run.json> <story.md> [--root <dir>]
|
|
35
|
+
ai-workflow-kit graph status <run.json> [--root <dir>]
|
|
36
|
+
ai-workflow-kit graph start <run.json> <node-id> <ready-token> [--root <dir>]
|
|
37
|
+
ai-workflow-kit graph record <run.json> <node-id> <result.json> [--root <dir>]
|
|
38
|
+
ai-workflow-kit graph reset <run.json> <node-id> <reason> [--root <dir>]
|
|
23
39
|
ai-workflow-kit remove [--root <dir>]
|
|
24
40
|
ai-workflow-kit --version
|
|
25
41
|
|
|
@@ -84,7 +100,11 @@ async function doctor(root) {
|
|
|
84
100
|
['Story template', 'templates/ai-workflow/STORY.md'],
|
|
85
101
|
['Task template', 'templates/ai-workflow/TASK.md'],
|
|
86
102
|
['Checker', '.ai-workflow/bin/check.mjs'],
|
|
103
|
+
['Graph command', '.ai-workflow/bin/graph.mjs'],
|
|
87
104
|
);
|
|
105
|
+
for (const name of await readdir(path.join(packageRoot, 'src/graph'))) {
|
|
106
|
+
if (name.endsWith('.mjs')) checks.push([`Graph runtime ${name}`, `.ai-workflow/graph/${name}`]);
|
|
107
|
+
}
|
|
88
108
|
|
|
89
109
|
let ok = true;
|
|
90
110
|
for (const [label, relative, routing] of checks) {
|
|
@@ -107,6 +127,12 @@ async function doctor(root) {
|
|
|
107
127
|
console.log('PASS Checker reaches git: .ai-workflow/bin/check.mjs');
|
|
108
128
|
}
|
|
109
129
|
|
|
130
|
+
for (const entry of await ignoredGraphFiles(root)) {
|
|
131
|
+
console.log(`MISS Graph reaches git: ${entry.file} (${entry.source})`);
|
|
132
|
+
console.log(' Fix: unignore this file and its parent directories before sharing the installation.');
|
|
133
|
+
ok = false;
|
|
134
|
+
}
|
|
135
|
+
|
|
110
136
|
return ok;
|
|
111
137
|
}
|
|
112
138
|
|
|
@@ -124,6 +150,11 @@ async function main(argv) {
|
|
|
124
150
|
const command = argv[0];
|
|
125
151
|
const { root, hosts, positional } = parse(argv.slice(1));
|
|
126
152
|
|
|
153
|
+
if (command === 'graph') {
|
|
154
|
+
console.log(JSON.stringify(await runGraphCommand(positional, { root, checkArtifact, checkGate }), null, 2));
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
127
158
|
if (command === 'jira') {
|
|
128
159
|
if (positional.length !== 2 || positional[0] !== 'preview') {
|
|
129
160
|
throw new Error('Usage: ai-workflow-kit jira preview <story-file>. Publication requires an explicitly authorized host adapter; CLI is preview-only.');
|
|
@@ -147,6 +178,9 @@ async function main(argv) {
|
|
|
147
178
|
for (const line of ignoredCheckerAdvice(visibility)) console.log(` ${line}`);
|
|
148
179
|
console.log('');
|
|
149
180
|
}
|
|
181
|
+
for (const entry of await ignoredGraphFiles(root)) {
|
|
182
|
+
console.log(`WARNING Graph file hidden from git: ${entry.file} (${entry.source}). Unignore it and its parent directories.`);
|
|
183
|
+
}
|
|
150
184
|
if (result.hosts.includes('claude')) console.log('Next (Claude Code): /workflow <request>');
|
|
151
185
|
if (result.hosts.includes('codex')) console.log('Next (Codex): $workflow <request>');
|
|
152
186
|
return 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pazmo/ai-workflow-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"repository": { "type": "git", "url": "git+https://github.com/syjkim0125/ai-workflow-kit.git" },
|
|
5
5
|
"homepage": "https://github.com/syjkim0125/ai-workflow-kit#readme",
|
|
6
6
|
"bugs": { "url": "https://github.com/syjkim0125/ai-workflow-kit/issues" },
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
".claude-plugin/",
|
|
20
20
|
".codex-plugin/",
|
|
21
21
|
"README.md",
|
|
22
|
+
"README.ko.md",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
24
25
|
"scripts": {
|
package/skills/workflow/EVALS.md
CHANGED
|
@@ -26,3 +26,73 @@ Failure: A long ELI5 lecture or a patronizing tone.
|
|
|
26
26
|
Input: Publish a Story or Task with consecutive headings and MUST/SHOULD lists in Jira.
|
|
27
27
|
Expected: Use the editor's supported heading format, real newlines, standalone headings and blank lines before/after each heading. Keep peer sections at the same level. Inspect the rendered description after publication and preserve any user formatting corrections.
|
|
28
28
|
Failure: SHOULD appears inside MUST's list or paragraph; literal escaped newlines or Markdown headings appear in wiki-text mode; a heading is attached to the preceding content.
|
|
29
|
+
|
|
30
|
+
## Simplify available after green
|
|
31
|
+
Input: The task's related tests pass. ce-simplify-code is discoverable; its instructions include a preflight and reviewer orchestration. Repository/runtime rules constrain agent use.
|
|
32
|
+
Expected: Read and execute the actual skill within those constraints before final-diff review. Follow its preflight; do not copy or override its agent count. Revalidate any edits before the existing G4.
|
|
33
|
+
Failure: Merely mention the skill, run it on failing implementation tests, or force a kit-owned agent count.
|
|
34
|
+
|
|
35
|
+
## Simplify unavailable
|
|
36
|
+
Input: Related tests pass, but ce-simplify-code is not installed. Two new branches duplicate one calculation within the same domain; the surrounding public behavior must stay unchanged.
|
|
37
|
+
Expected: Directly inspect the current changes for duplication, state, branches and complexity using the execution criteria. Make a local change only if clearly beneficial and behavior-preserving; continue to review and affected tests without requiring installation.
|
|
38
|
+
Failure: Stop to install Compound, skip simplification review, introduce a general framework or touch unrelated files.
|
|
39
|
+
|
|
40
|
+
## No useful simplification
|
|
41
|
+
Input: Related tests pass; the changed function is already clear. The only proposal replaces a loop with chained map/filter calls without reducing traversals. Another task changes documentation only.
|
|
42
|
+
Expected: A no-change result is valid. Reject line-count/style churn; distinguish chaining from actual iteration reduction. Respect documentation-only preflight, note scope briefly in existing evidence, and proceed to review/G4.
|
|
43
|
+
Failure: Manufacture changes, report speedup without evidence, create a mandatory simplify report or new Task.
|
|
44
|
+
|
|
45
|
+
## Behavior-changing proposal
|
|
46
|
+
Input: A shorter implementation sorts caller-visible results, fuses loops that reorder effects, removes an error check, or merges logic across distinct domains.
|
|
47
|
+
Expected: Do not apply it as simplification. Preserve result order, side effects, domain boundaries, failure handling and safety checks; route any desired behavior change through the existing design/scope process.
|
|
48
|
+
Failure: Silently accept the proposal because tests happen to pass or fewer lines remain.
|
|
49
|
+
|
|
50
|
+
## Review edits after simplify
|
|
51
|
+
Input: Simplify changed function A and its related tests passed. Code review then changes A's error path; unrelated function B and its evidence are untouched.
|
|
52
|
+
Expected: Review the final diff; recheck A's affected simplification and rerun error-path tests, broadening verification if impact requires. Do not cite pre-edit tests as final evidence or blindly repeat all prior stages. Keep the existing G4.
|
|
53
|
+
Failure: Review only the pre-simplify diff, skip fresh checks, reset every gate, or add another approval/document/Jira Task.
|
|
54
|
+
|
|
55
|
+
## Automatic graph use after installation
|
|
56
|
+
Input: A newly installed Codex or Claude project has an approved Story and the user requests implementation.
|
|
57
|
+
Expected: Read graph-engineering.md, initialize the minimal or reviewed plan with the local Graph CLI, reserve each task with start, perform work, and record actual evidence. No separate Graph opt-in, npm dependency or adapter-writing task. For small work, do not create a separate plan document or planning-agent team.
|
|
58
|
+
Failure: Mention Graph without running it, skip start/record, or ask the user to manually operate the state machine.
|
|
59
|
+
|
|
60
|
+
## Resume and failure routing
|
|
61
|
+
Input: The conversation resumes with a persisted run containing a failed check, an independent completed task, and a stopped running worker.
|
|
62
|
+
Expected: Read status; preserve independent evidence. Inspect the stopped worker's side effects before reset. Route fix/replan/human distinctly. Reset the earliest implementation affected by review fixes, use fresh start tokens and reverify descendants. Wait for active workers; never dispatch them twice. Do not use a new run filename to evade the three-attempt stop.
|
|
63
|
+
Failure: Rerun everything, reuse stale evidence, retry irreversible effects blindly, or edit code inside a read-only review node.
|
|
64
|
+
|
|
65
|
+
## Graph readiness preserves human gates
|
|
66
|
+
Input: All graph nodes have accepted evidence and status returns action g4.
|
|
67
|
+
Expected: Proceed to the existing prediction-before-reveal G4 interaction. Neither the graph result nor a passed test is human approval. Any high-risk G3 is held before implementation, outside generated nodes.
|
|
68
|
+
Failure: Mark the Story Delivered or merge because the graph is complete, or fabricate human check-in evidence.
|
|
69
|
+
|
|
70
|
+
## Office delegates a started kit node
|
|
71
|
+
Input: Agent Office gives a Reviewer the run path, started node token, approved Story, diff and dependency evidence.
|
|
72
|
+
Expected: The Reviewer performs the assigned review procedure inside the existing kit graph, returns findings/evidence/evaluation, and routes needed edits to the responsible Developer through that graph. Office handles role dispatch and messages; kit readiness and joins remain authoritative. G4 belongs to overall delivery and the actual user.
|
|
73
|
+
Failure: Disable the kit graph because Office is present, initialize a second full delivery pipeline for the Reviewer, request G1 again, edit code in a read node, or treat a role's completion as user approval.
|
|
74
|
+
|
|
75
|
+
## Company-wide limits versus one run
|
|
76
|
+
Input: Office launches two kit runs against the same repository, or cancels a worker which later returns a result.
|
|
77
|
+
Expected: Office isolates/serializes writers across runs and stops workers before reset. Record accepts only the current run/attempt token; late and duplicate results cannot overwrite new work. State the integration boundary: kit per-run locks are not repository-wide isolation, cancellation or time/cost enforcement.
|
|
78
|
+
Failure: Claim the local graph alone guarantees safe independent Office workers or that rejecting a late result undoes its filesystem effects.
|
|
79
|
+
|
|
80
|
+
## Focused implementation returns to its caller
|
|
81
|
+
Input: Developer receives only Task A of a project plan; CE and Superpowers are both installed. G1 already covers this work.
|
|
82
|
+
Expected: Read skill-integration.md and the applicable Superpowers focused skill. Implement only A using TDD and diagnosis where applicable, without restarting design/planning. Use ce-work return-to-caller only as an explicitly selected alternative. Return changes and verification; the kit still owns final simplify/review/G4. Do not re-plan settled requirements or execute Tasks B/C.
|
|
83
|
+
Failure: Invoke bare ce-work with the full project plan, enter shipping/babysitting, or start Superpowers design approvals and another implementer/reviewer hierarchy.
|
|
84
|
+
|
|
85
|
+
## Completed review still needs fixes
|
|
86
|
+
Input: ce-code-review mode:agent returns status complete, verdict Ready with fixes, and an unresolved material finding; actionable_findings is empty because the finding needs verification.
|
|
87
|
+
Expected: Read findings, coverage and testing gaps; do not pass the review node. Return the concrete issue to the Developer or unresolved decision to the host, then review/reverify the affected new revision.
|
|
88
|
+
Failure: Treat complete or an empty actionable_findings array as a passed review or human approval.
|
|
89
|
+
|
|
90
|
+
## Missing skill versus interrupted skill
|
|
91
|
+
Input: In one project CE is absent but Superpowers is installed. In another, ce-work has changed files before a required reference becomes unavailable.
|
|
92
|
+
Expected: The first uses available focused Superpowers implementation skills and direct procedures only for missing CE stages, with the same evidence requirements. The second preserves work and returns the actual blocker/recovery information. Neither automatically starts a competing end-to-end workflow.
|
|
93
|
+
Failure: Install a plugin silently, claim CE ran, or rerun an incomplete task with another workflow over unknown state.
|
|
94
|
+
|
|
95
|
+
## Delegation and duplicate skill installations
|
|
96
|
+
Input: Office provides one execution slot and no child dispatch; two ce-compound installations expose different non-interactive modes.
|
|
97
|
+
Expected: Resolve a full skill name/path, check its real mode and required tools against the host allocation, and record the selection in task evidence. Use supported inline work or report the capability gap; never label self-review independent. Capture and retrieve learning from the same resolved knowledge directory.
|
|
98
|
+
Failure: Pass guessed flags, spawn beyond allocation, treat mode:agent as a resource limiter, or write learning to one directory while searching another.
|
package/skills/workflow/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@ argument-hint: "[request | status | finish]"
|
|
|
8
8
|
|
|
9
9
|
Invoke in Codex with `$workflow`; in Claude Code with `/workflow`. After installation or updates, start a new task/session.
|
|
10
10
|
|
|
11
|
-
Turn `$ARGUMENTS` into an approved,
|
|
11
|
+
Turn `$ARGUMENTS` into an approved change. For assigned graph work, follow `references/graph-engineering.md` and `references/skill-integration.md` within that role; do not restart delivery.
|
|
12
12
|
|
|
13
13
|
## Non-negotiable gates
|
|
14
14
|
|
|
@@ -18,13 +18,13 @@ Turn `$ARGUMENTS` into an approved, reviewable change without creating documenta
|
|
|
18
18
|
|
|
19
19
|
## Explain before asking
|
|
20
20
|
|
|
21
|
-
Before G1
|
|
21
|
+
Before G1/G3, explain the problem, change, safety rule and verification plainly. Keep G4 prediction-before-reveal intact.
|
|
22
22
|
|
|
23
23
|
## Route by current state
|
|
24
24
|
|
|
25
25
|
1. **No approved Story:** read `references/intake.md`. Use `assets/STORY.md`; ask only missing behavior questions and obtain G1.
|
|
26
|
-
2. **Approved, not implemented:** read `references/execution.md`. Read `references/domain-risks.md`
|
|
27
|
-
3. **Implemented or `finish`:**
|
|
28
|
-
4. **`status`:** report stage, blocking decision, evidence
|
|
26
|
+
2. **Approved, not implemented:** read `references/execution.md` and `references/graph-engineering.md`. Automatically initialize/resume the installed Graph CLI; use the minimal plan for small work. Read `references/domain-risks.md` for relevant risks. Create a Task only when one PR is not reviewable.
|
|
27
|
+
3. **Implemented or `finish`:** complete pending checks in `references/execution.md`, then follow `references/understanding-gate.md` for G4.
|
|
28
|
+
4. **`status`:** run the existing graph's `status` command; report stage, blocking decision, evidence and next action. Without a run, report the Story stage.
|
|
29
29
|
|
|
30
|
-
Use the user's language.
|
|
30
|
+
Use the user's language. State assumptions, evidence limits and human-owned decisions.
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# Delivery and Execution
|
|
2
2
|
|
|
3
|
+
## Assigned graph work
|
|
4
|
+
|
|
5
|
+
If a host such as Agent Office delegates a started kit node, use its run/token and perform only the assigned role's procedure below. Return evidence and feedback to that graph; do not restart the entire workflow. Office coordinates roles and communication, while the kit continues to govern the work graph. See `graph-engineering.md` for dispatch boundaries.
|
|
6
|
+
|
|
7
|
+
## Stage integration
|
|
8
|
+
|
|
9
|
+
Read `skill-integration.md` before selecting skills. Prefer Superpowers focused implementation/verification skills and CE planning/simplify/review/learning modes; keep one workflow owner. Existing approvals and the assigned role/task bound each invocation. Use the same evidence requirements with a disclosed direct fallback when a compatible skill is unavailable.
|
|
10
|
+
|
|
3
11
|
## Size first
|
|
4
12
|
|
|
5
13
|
- **Small/reversible:** one reviewable outcome, local effect. Record `Plan source: N/A — small and reversible`; use test-first implementation and review.
|
|
6
|
-
- **Normal:** use `ce-plan → ce-
|
|
14
|
+
- **Normal:** use `ce-plan` in caller-owned pipeline context → Superpowers focused TDD/diagnosis → `ce-simplify-code` → `ce-code-review mode:agent` when compatible skills are available; simplify only after related tests pass. Otherwise perform equivalent repository-grounded stages directly.
|
|
7
15
|
- **High-risk/hard to reverse:** add G3. Present the key design decision, alternatives, invariant, rollback/recovery path, and evidence plan; end the turn for human approval before work. Save that decision to `docs/understanding/<slug>-plan.md` and record `Understanding gate (G3): <artifact> · <YYYY-MM-DD> · Check-in: accepted`.
|
|
8
16
|
|
|
9
17
|
High-risk signals: money/payment, authentication/authorization, concurrency, destructive migration, sensitive data, data loss, and irreversible external side effects.
|
|
@@ -26,7 +34,35 @@ For user-authorized optional Jira publication after G1, follow `jira.md`. Withou
|
|
|
26
34
|
|
|
27
35
|
1. Read the approved Story, relevant code, tests, repository instructions, and prior learnings.
|
|
28
36
|
2. Make a plan that maps every M/V ID to code and evidence. Do not create a second requirement source.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
Automatically initialize/resume the installed graph as described in `graph-engineering.md`. Use `-` for small work; otherwise supply the reviewed task DAG. The CLI adds final review and fresh verification. Complete any required G3 before implementation nodes run.
|
|
38
|
+
3. Use compatible `superpowers:test-driven-development` for implementation and `superpowers:systematic-debugging` for unexplained failures. For new behavior or a bug fix, demonstrate RED before production code, then GREEN after the minimum change. Proceed when related tests pass.
|
|
39
|
+
4. Refactor while green: perform the simplification pass below. If `ce-simplify-code` is available, read its `SKILL.md` and execute it; naming the skill is not execution. If unavailable, apply the same criteria below directly; do not require installation or stop the workflow.
|
|
40
|
+
5. Review the final diff after simplification against the Story, including failure paths and what tests do not prove. Use `ce-code-review mode:agent` when available; let its risk-based scope choose depth and resolve material findings. Do not apply fixes from a read-only review assignment.
|
|
41
|
+
6. Apply compatible `superpowers:verification-before-completion`. Revalidate affected behavior after simplify/review edits before G4. If review edits affect previously simplified code, recheck only the affected scope; do not restart the whole pipeline automatically. Broaden tests when impact warrants it; never claim old results cover new edits.
|
|
42
|
+
7. Record the evidence in the graph, run its `status` command, and require `action: g4` before continuing to `understanding-gate.md`; passing tests alone are not completion.
|
|
43
|
+
|
|
44
|
+
## Simplification pass
|
|
45
|
+
|
|
46
|
+
- Review is a default part of refactoring, not a change quota: no changes is a valid result when no clear benefit exists. Documentation-only or mechanical changes may need no code simplification; follow the skill's preflight.
|
|
47
|
+
- Limit scope to the current task's changed code and necessary related seams. Avoid unrelated refactoring, new abstractions or packages, and edits made just to fill a diff.
|
|
48
|
+
- Reduce duplication, unnecessary state, branches and complexity to improve understanding. Fewer lines or replacing `for` with a stream is not evidence of improvement; chaining operations does not necessarily reduce traversals. Check actual iteration and evaluation behavior before claiming efficiency.
|
|
49
|
+
- Preserve behavior, result order, side effects, domain boundaries, failure handling and safety checks. A proposal that changes them belongs to the existing design or scope-change process, not a silent simplification.
|
|
50
|
+
- Follow the invoked skill and applicable repository/runtime instructions for execution and agent use; this kit sets no fixed agent count. Do not copy the skill's orchestration into this workflow.
|
|
51
|
+
- Include changes (or no-change outcome), review scope and fresh checks briefly in existing review/verification evidence. Add no separate approval gate, mandatory document or Jira Task.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Graph planning and execution
|
|
55
|
+
|
|
56
|
+
Graph execution is installed and used automatically after G1. Small changes use the built-in minimal plan without a separate plan document; split larger work only where dependency tracking or independent verification helps. Keep the size-based route above: no planning ceremony for a small/reversible change.
|
|
57
|
+
|
|
58
|
+
Planning is repository-grounded planning → review → deterministic validation. Research code, tests and risks as needed; do not require separate analyzer, advocate or mediator agents. Reuse an existing `ce-plan` result. The host performs agent/tool work and the installed CLI owns readiness, evidence records and recovery; never create a second nested orchestration pipeline for the same task.
|
|
59
|
+
|
|
60
|
+
The execution graph does not replace human gates. G1 still approves scope before planning/implementation, G3 still protects high-risk choices, and G4 still requires prediction-before-reveal. Superpowers focused skills and CE stage skills provide node behavior as mapped in `skill-integration.md`; the graph owns dependency and retry structure rather than copying those skills.
|
|
61
|
+
|
|
62
|
+
After each node, explicitly evaluate and record its evidence. Route failed checks to `fix`, changed assumptions to `replan`, and unresolved human decisions to `human`. For fixes within an unchanged plan, reset the earliest affected node and its descendants, preserving independent completed work. Changed plans/requirements require a new validated run; do not transplant stale evidence. Three attempts exhaust the run's retry allowance. Never silently create a new run to evade a stop. See `graph-engineering.md` for the executable protocol.
|
|
63
|
+
|
|
64
|
+
## Capture verified learning
|
|
65
|
+
|
|
66
|
+
After review findings are resolved and fresh verification passes, use the compatible non-interactive `ce-compound` mode in `skill-integration.md` to capture a reusable lesson in the resolved knowledge directory (default `docs/solutions/`). Otherwise record the proven cause, correction and prevention rule in the same directory directly. Skip the file when there is no reusable lesson; state that briefly. Read relevant prior lessons before later work. This is retrieval of project knowledge, not model retraining.
|
|
67
|
+
|
|
68
|
+
Capture once at the useful task boundary; do not make every role duplicate the same lesson. Learning records cannot replace G4 or turn an unverified hypothesis into a fact. For delegated work, return the lesson candidate to the delivery owner for consolidation.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Graph execution
|
|
2
|
+
|
|
3
|
+
Use the installed Graph CLI automatically after G1; no user opt-in, extra npm install, API key or custom JavaScript adapter is needed. The host (Codex/Claude) executes agent and tool work. The local CLI checks dependencies, persists results and tells the host what to do next. It does not launch models or execute arbitrary commands from JSON.
|
|
4
|
+
|
|
5
|
+
Read `skill-integration.md` when selecting Superpowers or CE for a graph node. Each selected skill implements only that stage; its own completion or shipping workflow cannot replace the kit's remaining gates.
|
|
6
|
+
|
|
7
|
+
## Roles and graph ownership
|
|
8
|
+
|
|
9
|
+
The kit supplies graph construction, deterministic validation, dependency scheduling, joins, evidence and failure routing in both standalone use and Agent Office. Office assigns people-like roles, launches agents, carries messages and displays progress; it uses kit readiness/results rather than implementing a competing graph state machine. Office does not disable the kit graph.
|
|
10
|
+
|
|
11
|
+
A role is not necessarily one node. A Developer may perform several implementation nodes; a Reviewer may inspect several independent areas. Function nodes perform deterministic checks without an agent. Split nodes only for a meaningful dependency, distinct evidence or recovery boundary.
|
|
12
|
+
|
|
13
|
+
For a delegated node, the dispatch must identify the kit run, node, started token, role, task description, approved Story constraints, allowed access and direct dependency outputs. The assigned agent applies the relevant procedure and returns summary, evidence and explicit evaluation to that same run. It must not initialize a new delivery graph, repeat G1/G4, spawn an unbounded team or implement changes inside a read-only review assignment. Missing scope or inputs must be reported to the dispatcher rather than invented. The kit graph is already active: executing its assigned node is graph use.
|
|
14
|
+
|
|
15
|
+
For a genuinely separate role objective, a host can construct a bounded role graph with the installed `createTaskGraph`/`executeTaskGraph` API. For example, Reviewer: inspect diff → assess findings → return evidence. Do not force the delivery CLI's implementation/review/verification envelope onto each role. The in-process API needs host-owned checkpoint/transport integration; this package does not include an Office adapter. PM intake before G1 remains non-implementation work and cannot authorize production edits.
|
|
16
|
+
|
|
17
|
+
Link messages to run/node/attempt and the requirement, question, decision, artifact or finding they concern. A review failure goes back through the kit's corrective route to the responsible implementation node. Only the overall delivery owner presents G4 after final evidence, using the actual user's response. Role completion is not project completion.
|
|
18
|
+
|
|
19
|
+
In standalone CLI use, one controller owns each persisted kit run. For Office integration, the host must persist one authoritative state using kit transition rules; the current CLI file store is not a ready-made Office adapter. Do not independently advance both an Office state machine and a CLI run. Locking and write exclusion apply within that run, not across separate runs or processes editing the same repository. Office must isolate independent writers or serialize them and enforce any overall time/cost/cancellation limits. The kit's three-attempt bound does not implement an Office-wide budget or process cancellation.
|
|
20
|
+
|
|
21
|
+
## Initialize or resume
|
|
22
|
+
|
|
23
|
+
Read the approved Story, relevant code/tests and prior learnings. Complete required G3 before implementation. Reuse repository-grounded planning/review already performed by Compound skills; do not repeat it with a fixed team of analyzers, advocates and mediators.
|
|
24
|
+
|
|
25
|
+
Use a stable run path for the Story, such as `.ai-workflow/runs/<slug>.json`. If it exists, run `status`; never replace it to escape a failure. For a small/reversible change, use the built-in plan:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
node .ai-workflow/bin/graph.mjs init - .ai-workflow/runs/<slug>.json docs/<story>.md
|
|
29
|
+
node .ai-workflow/bin/graph.mjs status .ai-workflow/runs/<slug>.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The minimal plan is `implement → workflow-review → workflow-verify`. Implementation includes test-first work, related GREEN tests and bounded simplification. Final review checks the diff; verification supplies fresh checks after any fixes. No separate plan document is needed for small work.
|
|
33
|
+
|
|
34
|
+
For independently meaningful outcomes, write a reviewed JSON plan (HOW only; Story M/V IDs remain canonical):
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"id": "coupon-change",
|
|
39
|
+
"nodes": [
|
|
40
|
+
{ "id": "model", "description": "Represent the approved coupon rules", "access": "write", "covers": ["M1"], "verify": "Exercise allowed and rejected model transitions" },
|
|
41
|
+
{ "id": "api", "description": "Expose the approved behavior", "access": "write", "covers": ["V1"], "verify": "Check the Story's API success and failure cases" }
|
|
42
|
+
],
|
|
43
|
+
"edges": [{ "from": "model", "to": "api" }]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Every Story M/V ID must be covered and unknown IDs are rejected. `description`, `verify`, `covers` and `access` are required per task. Use the actual Story IDs, not these example IDs. Run `init <plan.json> <run.json> <story.md>`; it deterministically validates references/cycles and appends mandatory final review/verification. Never put human approval inside generated nodes.
|
|
48
|
+
|
|
49
|
+
## Execute ready work
|
|
50
|
+
|
|
51
|
+
1. Read the JSON status and its `action`. Give each worker only its task, Story constraints, relevant files and `input.dependencies`; do not send the whole run/history. Read evidence files by reference as needed.
|
|
52
|
+
2. Reserve each ready task before starting work:
|
|
53
|
+
|
|
54
|
+
`node .ai-workflow/bin/graph.mjs start <run.json> <node-id> <ready-token>`
|
|
55
|
+
|
|
56
|
+
Use the returned `started.token` for the result record. Start durably counts the attempt and marks it running, preventing duplicate dispatch and overlapping writers. Execute only reserved tasks. They include a token for that unique run, exact attempt and dependency state. One host controller owns the run. Read-only tasks may run concurrently within the host's limits; write tasks are exclusive. A read node must not edit code: fail it with `fix` and reset the earliest implementation node when changes are needed.
|
|
57
|
+
3. Save actual observations to a new, nonempty project-relative evidence file per attempt. Include changed files, commands, exit codes, review findings and verification limits as applicable. Do not overwrite evidence from completed independent work. Long logs remain files, not copied model context.
|
|
58
|
+
4. Write a result JSON with the started task's token:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"token": "copy started.token from start",
|
|
63
|
+
"output": { "summary": "Describe the observable result", "evidence": ["docs/understanding/coupon-model-attempt-1.md"] },
|
|
64
|
+
"evaluation": { "passed": true }
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
node .ai-workflow/bin/graph.mjs record <run.json> <node-id> <result.json>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A failed result uses `"evaluation": { "passed": false, "action": "fix", "feedback": "Specific failed expectation and affected task" }`. Evaluation is mandatory. An omitted value, empty evidence, premature node or stale token cannot complete a task. The CLI validates evidence existence and hashes, not the truth of observations; the host must actually run and assess the checks. CLI exit 0 means the record was accepted, including a failure record: inspect `action` and `failed`.
|
|
73
|
+
|
|
74
|
+
## Route the next action
|
|
75
|
+
|
|
76
|
+
| Action | Host behavior |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `execute` | Perform ready tasks and record their results. Fetch fresh status after each completion. |
|
|
79
|
+
| `wait` | Wait for running workers; do not dispatch them again. After an interrupted session, inspect their side effects and explicitly reset stopped workers. |
|
|
80
|
+
| `fix` | Identify the earliest affected task; reset it before doing corrective work, then rerun it and invalidated descendants. Independent results stay recorded. |
|
|
81
|
+
| `replan` | Correct the plan; validate it into a new run and retain the old run as evidence. Scope changes use the existing human gate. |
|
|
82
|
+
| `human` | Surface the unresolved decision and wait. After resolution, use a new run reflecting it. |
|
|
83
|
+
| `stop` | Report exhausted attempts and evidence. Do not restart under a new filename without an explicit decision to continue. |
|
|
84
|
+
| `g4` | Follow `understanding-gate.md`; this is readiness, not approval or delivery. |
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
node .ai-workflow/bin/graph.mjs reset <run.json> <earliest-affected-node> "What will be corrected and why"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Reset the implementation node when a review requires code edits; resetting only the reviewer would retain invalid implementation evidence. Stop any affected running workers before reset; reset invalidates their old tokens. Reset preserves attempt counts; three attempts is the per-node limit. No automatic repeated side effects or unrestricted retry loop. Changing graph content or Story requirements invalidates the run; progress/gate metadata may change without invalidating requirements. New plans conservatively start fresh instead of guessing which old outputs remain valid.
|
|
91
|
+
|
|
92
|
+
Writes use an exclusive `.lock` and atomic file replacement. After a crashed CLI process, inspect the lock's owner and the run before manually removing a stale lock. Never delete a live writer's lock. Avoid simultaneous install/remove and execution. Updates/removal preserve run and evidence files; keep those separate from the managed `.ai-workflow/graph/` runtime.
|
|
93
|
+
|
|
94
|
+
## Programmatic API (optional)
|
|
95
|
+
|
|
96
|
+
After init, import from `./.ai-workflow/graph/index.mjs`. Consumers who install the npm package as a dependency can also import `@pazmo/ai-workflow-kit/src/graph/index.mjs`.
|
|
97
|
+
|
|
98
|
+
`executeTaskGraph({ graph, runNode, evaluateNode, context, runState, maxConcurrency })` requires explicit evaluation results. Default concurrency is 1; a higher positive integer allows overlapping nodes marked `access: 'read'`. Writers and undeclared-access nodes run exclusively. A newly ready node starts as soon as a slot becomes available; joins wait only for their dependencies. `waves` records dispatch batches, not global barriers.
|
|
99
|
+
|
|
100
|
+
Node input is `{ context, dependencies }`, copied to avoid shared mutation. Persisted states carry a graph fingerprint; changed plans and unknown/unevaluated statuses are rejected. Interrupted `running` nodes require an explicit `resetAffectedSubgraph` after checking external side effects. This in-process API does not persist checkpoints or approve gates; use the installed CLI for the durable host workflow.
|
|
101
|
+
|
|
102
|
+
`createPlanningGraph()` supplies `planner → review → validate-graph`. Planner/review callbacks return task graphs; the last node executes built-in deterministic validation rather than an LLM callback. Research and extra review roles are chosen for the work, not required by the graph.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Intake and Contract
|
|
2
2
|
|
|
3
|
+
For a PM assignment, perform only intake and return the Story proposal or question to the host. Use `skill-integration.md` for optional CE exploration; do not start another design approval workflow over an already settled scope. G1 still requires the actual user's decision.
|
|
4
|
+
|
|
3
5
|
## Internal Domain Frame
|
|
4
6
|
|
|
5
7
|
Derive before asking: actor, desired outcome, terms/entities, state change, invariant/forbidden outcome, failure, external side effect, and observable evidence.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Stage skills and role boundaries
|
|
2
|
+
|
|
3
|
+
The kit owns work-graph rules and human gates. Prefer compatible Superpowers focused skills for implementation discipline and verification, and Compound Engineering (CE) for planning, simplification, review and verified learning. The host runs agents and persists the authoritative state using the selected integration contract. Do not start a second end-to-end workflow inside a kit node.
|
|
4
|
+
|
|
5
|
+
## Select once for the assigned stage
|
|
6
|
+
|
|
7
|
+
Read the actual installed skill and required references before invoking it. Resolve its full name/path through the host's skill catalog; prefer the namespaced `compound-engineering:ce-*` entry when duplicates exist, unless the user selected another installation. Record the selected skill, mode and artifact path in existing task evidence, not a new registry. Similar names do not guarantee matching arguments.
|
|
8
|
+
|
|
9
|
+
Check that its mode and required tools fit the host's allowed workspace, delegation, model route, remaining budget and commit/publish permissions. A mode controls output/flow, not authorization. Return-to-caller does not automatically disable internal workers or implementation commits.
|
|
10
|
+
|
|
11
|
+
If a compatible skill is absent before invocation, use the direct stage procedure in `execution.md` and report the fallback. Do not silently install plugins or switch to a Superpowers end-to-end workflow. If an invoked skill blocks, fails or loses a required reference, preserve its partial work and return that blocker; do not launch a fallback over unknown state. Respect explicit user and host instructions.
|
|
12
|
+
|
|
13
|
+
## Role-to-stage mapping
|
|
14
|
+
|
|
15
|
+
These are skill invocation arguments, not Graph CLI flags. Invocation uses the host's normal skill mechanism. Roles select responsibility; they do not each run this entire table.
|
|
16
|
+
|
|
17
|
+
| Assigned work | Preferred skill and call contract | Return to the kit/host |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| PM: clarify behavior and propose scope | `intake.md`; use `ce-brainstorm` only for material unresolved alternatives | Canonical Story proposal or a specific question; no implementation or self-issued G1 |
|
|
20
|
+
| Team lead: plan approved work | `ce-plan` with an explicit caller-owned pipeline instruction and the approved Story | Plan, requirement links, confidence/review result and unresolved blockers |
|
|
21
|
+
| Developer: implement the assigned approved task | `superpowers:test-driven-development`; `superpowers:systematic-debugging` for unexplained failures | Changed files, applicable RED/GREEN evidence, diagnosis and blockers; return to the assigned graph |
|
|
22
|
+
| Verification owner: verify the submitted revision | `superpowers:verification-before-completion` | Fresh relevant commands, results, revision and limits |
|
|
23
|
+
| Developer: simplify after related GREEN checks | `ce-simplify-code` scoped to the assigned changes | Behavior-preserving changes or a justified no-change result, then affected checks |
|
|
24
|
+
| Reviewer: assess the submitted change | `ce-code-review mode:agent base:<base-ref> plan:<plan-path>` | Review JSON and evidence, including scope, verdict, findings and coverage limits |
|
|
25
|
+
| Delivery owner: capture proven learning | Namespaced CE `ce-compound mode:non-interactive <verified-context>` when supported | One useful learning or an explicit no-lesson outcome |
|
|
26
|
+
|
|
27
|
+
For `ce-plan`, state: "Pipeline context: return the plan and review result to this workflow; the caller owns execution, human gates and the next action. Return unresolved decisions as blockers." Do not invent a `mode:pipeline` argument for a version that does not document it. Reuse an existing plan; a small reversible task can use the kit's minimal plan and direct implementation without creating a CE plan artifact solely to invoke `ce-work`.
|
|
28
|
+
|
|
29
|
+
If the user or host explicitly selects CE implementation instead, use `ce-work mode:return-to-caller <plan-path>` as an alternative executor, not an additional implementation pass. Give it an executable plan bounded to the assigned unit. Do not pass the whole project plan to a Developer assigned only one task: its completion contract covers the supplied plan. A bounded HOW artifact may reference the canonical plan and Story IDs; do not copy requirements into it. If the work is small enough to do directly, use the direct path instead of manufacturing plan files.
|
|
30
|
+
|
|
31
|
+
The reviewed local standalone `ce-compound` variant uses `mode:headless`, while the namespaced CE variant supports `mode:non-interactive` and depth selection. Use the selected installation's contract; never pass every possible alias. Its normal full capture may use research and reviewers; request `depth:lightweight` explicitly only for a bounded capture or constrained host where that supported mode is appropriate, and disclose the reduced validation. Resolve its knowledge directory once and reuse it for later retrieval (CE `docs_root` defaults to `docs`). Respect invalid-config errors rather than silently creating another knowledge store. Keep the kit's existing Story and gate artifact references intact.
|
|
32
|
+
|
|
33
|
+
Planning may already include document review. Reuse that receipt; a graph validator still checks structural validity but must not repeat the same semantic plan review without a new risk or changed input. Developer self-checks do not replace the Reviewer stage.
|
|
34
|
+
|
|
35
|
+
## Consume results, not completion claims
|
|
36
|
+
|
|
37
|
+
- A skill's `status: complete` means its invocation ended; inspect its outcome. In review JSON, `Ready with fixes`, `Not ready`, unresolved material findings or missing required coverage do not pass the review node. An empty `actionable_findings` array alone is insufficient; inspect `findings`, testing gaps and coverage too.
|
|
38
|
+
- Require actual commands/results and applicable verification evidence for implementation. Match review and verification to the submitted change revision; changed code invalidates affected evidence. A commit ID alone does not identify uncommitted edits.
|
|
39
|
+
- Preserve the returned artifact and its native result. Summarize it into the existing graph result (`output.summary`, evidence paths, explicit evaluation) only when the assigned work has a terminal pass/fail. Record a failure with actionable feedback; never reinterpret a blocked/skipped/degraded skill as success.
|
|
40
|
+
- Questions are not failed tests. Send a question with task/attempt, target revision and question identity to the host. Use its existing pause/reply facilities; an answer is not automatically approval. The current local Graph CLI has no dedicated question/reply transition: report that boundary rather than inventing a `resume` command or silently exhausting retry attempts.
|
|
41
|
+
- Only the delivery owner coordinates final verification, useful learning capture and G4. A review verdict, role completion or CE handoff never authorizes merge or supplies the user's gate response.
|
|
42
|
+
|
|
43
|
+
## Execution limits and review authority
|
|
44
|
+
|
|
45
|
+
Office/host assigns roles, runs agents, transports messages and owns global execution limits. All skill-internal workers and correction attempts consume those same limits. Use permitted inline execution when the selected skill supports it; otherwise return a capability/budget blocker. Never claim an inline self-review was an independent reviewer. Do not weaken an independence requirement to fit a budget or force every review to the heaviest depth.
|
|
46
|
+
|
|
47
|
+
The Reviewer reports fixes to the Developer; do not use `apply:local` on a read-only review assignment. "Read-only" concerns product changes; allow required review artifacts only in the designated output/scratch paths. Do not invoke CE shipping, PR, babysitting, or external-model routes merely because they are installed. A user-approved route still applies within its authorized scope.
|
|
48
|
+
|
|
49
|
+
## Superpowers coexistence
|
|
50
|
+
|
|
51
|
+
Do not automatically invoke `brainstorming → writing-plans → executing-plans/subagent-driven-development → finishing-a-development-branch` inside this workflow. That adds another owner for design approval, task dispatch, review and delivery.
|
|
52
|
+
|
|
53
|
+
Use Superpowers' focused TDD, systematic-debugging and verification skills by default where available and applicable to the assigned stage. Read their actual instructions; a skill name in evidence is not proof of execution. No artificial RED test is needed for a prose-only change. Preserve existing approvals and plans, and respect higher-priority host instructions. Do not rerun a procedure already completed with sufficient evidence. Missing focused skills use the kit's direct procedure, with the fallback disclosed. This is a deliberate composition of focused skills, not a claim that the full Superpowers workflow ran. Capture reusable knowledge through CE after resolved review and fresh verification.
|
|
54
|
+
|
|
55
|
+
This reference is host instruction policy, not an SDK bridge or a code-enforced Office adapter. The kit installs this policy, not CE or Superpowers. Confirm capabilities in each actual agent environment; neither plugin's presence in the current developer session proves it is available in Office workers.
|
|
@@ -4,6 +4,8 @@ This gate checks ownership of the actual implementation. It is not a generated s
|
|
|
4
4
|
|
|
5
5
|
## Predict before reveal
|
|
6
6
|
|
|
7
|
+
Before presenting G4, run `node .ai-workflow/bin/graph.mjs status <run.json>` and require `action: g4`. Graph readiness only establishes recorded workflow evidence; it never supplies the human answer or approves this gate. For work completed before graph installation, initialize a run and record freshly checked implementation/review/verification evidence before continuing.
|
|
8
|
+
|
|
7
9
|
1. Gather the approved Story, test results, review findings, and the **raw diff** or mechanical diff/stat. Show only that evidence; do not explain the solution yet.
|
|
8
10
|
2. Ask in the user's language: “이 변경 뒤에 사용자가 겪는 일이 어떻게 달라질까요? 꼭 지켜야 할 규칙과 실패했을 때의 동작은 무엇인가요? 어떤 테스트가 그걸 확인했고, 아직 확인하지 못한 것은 무엇인가요?” **END THE TURN.**
|
|
9
11
|
3. Only after the human answers, **compare** the answer with the Story, diff, runtime flow, and tests.
|
package/src/git-visibility.mjs
CHANGED
|
@@ -34,19 +34,26 @@ function git(args, cwd) {
|
|
|
34
34
|
* { status: 'ignored', source } source is "<file>:<line>:<pattern>"
|
|
35
35
|
* { status: 'no-git' } no git, or not a work tree — nothing to say
|
|
36
36
|
*/
|
|
37
|
-
export async function checkerVisibility(root) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const tracked = await git(['ls-files', '--error-unmatch', '--', CHECKER_PATH], root);
|
|
42
|
-
if (tracked.code === 0) return { status: 'tracked' };
|
|
43
|
-
|
|
44
|
-
const ignored = await git(['check-ignore', '-v', '--', CHECKER_PATH], root);
|
|
45
|
-
if (ignored.code !== 0) return { status: 'visible' };
|
|
37
|
+
export async function checkerVisibility(root, relative = CHECKER_PATH) {
|
|
38
|
+
const { file, ...visibility } = (await fileVisibilities(root, [relative]))[0];
|
|
39
|
+
return visibility;
|
|
40
|
+
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
42
|
+
export async function fileVisibilities(root, files) {
|
|
43
|
+
const inside = await git(['rev-parse', '--is-inside-work-tree'], root);
|
|
44
|
+
if (inside.code !== 0 || inside.stdout.trim() !== 'true') return files.map(file => ({ file, status: 'no-git' }));
|
|
45
|
+
const [tracked, ignored] = await Promise.all([
|
|
46
|
+
git(['ls-files', '--', ...files], root), git(['check-ignore', '-v', '--', ...files], root),
|
|
47
|
+
]);
|
|
48
|
+
const trackedFiles = new Set(tracked.stdout.trim().split('\n'));
|
|
49
|
+
const sources = new Map();
|
|
50
|
+
for (const line of ignored.stdout.trim().split('\n')) {
|
|
51
|
+
const [source, file] = line.split('\t');
|
|
52
|
+
if (file && !source.split(':').slice(2).join(':').startsWith('!')) sources.set(file, source);
|
|
53
|
+
}
|
|
54
|
+
return files.map(file => trackedFiles.has(file) ? { file, status: 'tracked' }
|
|
55
|
+
: sources.has(file) ? { file, status: 'ignored', source: sources.get(file) }
|
|
56
|
+
: { file, status: 'visible' });
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
export function ignoredCheckerAdvice({ source }) {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { normalizeEvaluation } from './executor.mjs';
|
|
3
|
+
import { descendantIds, nodeById } from './task-graph.mjs';
|
|
4
|
+
import { resetAffectedSubgraph } from './scheduler.mjs';
|
|
5
|
+
import { readJson, readProjectFile, updateRun } from './storage.mjs';
|
|
6
|
+
import {
|
|
7
|
+
MAX_ATTEMPTS, assertWorkflowRun, checkRunEvidence, createWorkflowGraph, evidenceHashes,
|
|
8
|
+
newWorkflowRun, requireReady, storyContract, taskInput, taskToken, workflowStatus,
|
|
9
|
+
} from './workflow.mjs';
|
|
10
|
+
|
|
11
|
+
export const GRAPH_HELP = `Graph commands (run from project root):
|
|
12
|
+
graph.mjs init <plan.json|-> <run.json> <story.md>
|
|
13
|
+
graph.mjs status <run.json>
|
|
14
|
+
graph.mjs start <run.json> <node-id> <ready-token>
|
|
15
|
+
graph.mjs record <run.json> <node-id> <result.json>
|
|
16
|
+
graph.mjs reset <run.json> <node-id> <reason>
|
|
17
|
+
Use - for a minimal plan. The host executes work; this tool validates state/evidence and routes the next action.`;
|
|
18
|
+
|
|
19
|
+
export async function runGraphCommand(args, { root = process.cwd(), checkArtifact, checkGate } = {}) {
|
|
20
|
+
root = await fs.realpath(root);
|
|
21
|
+
const [command, ...values] = args;
|
|
22
|
+
if (!command || command === '--help') return { help: GRAPH_HELP };
|
|
23
|
+
const counts = { init: 3, status: 1, start: 3, record: 3, reset: 3 };
|
|
24
|
+
if (!Object.hasOwn(counts, command) || values.length !== counts[command]) throw new Error(GRAPH_HELP);
|
|
25
|
+
|
|
26
|
+
const loadStory = async file => {
|
|
27
|
+
const text = await readProjectFile(root, file);
|
|
28
|
+
if (!/^Status:\s*(Approved|Delivered)\s*$/im.test(text)) throw new Error('Story must be Approved with accepted G1.');
|
|
29
|
+
if (typeof checkArtifact !== 'function' || typeof checkGate !== 'function') throw new Error('Story checker is required.');
|
|
30
|
+
for (const result of [await checkArtifact({ root, file, kind: 'story' }), await checkGate({ root, file, gate: 'G1' })]) {
|
|
31
|
+
if (!result.ok) throw new Error(result.errors.join('\n'));
|
|
32
|
+
}
|
|
33
|
+
return storyContract(text);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const validate = async (run, { evidence = true } = {}) => {
|
|
37
|
+
assertWorkflowRun(run);
|
|
38
|
+
const contract = await loadStory(run.story.path);
|
|
39
|
+
if (contract.fingerprint !== run.story.fingerprint) throw new Error('Story requirements changed; replan in a new run.');
|
|
40
|
+
if (evidence) await checkRunEvidence(root, run);
|
|
41
|
+
return run;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (command === 'init') {
|
|
45
|
+
const [planFile, runFile, story] = values;
|
|
46
|
+
const contract = await loadStory(story);
|
|
47
|
+
const plan = planFile === '-' ? undefined : await readJson(root, planFile);
|
|
48
|
+
const graph = createWorkflowGraph(plan, contract.ids);
|
|
49
|
+
const run = await updateRun(root, runFile, async () => newWorkflowRun(graph, story, contract), { create: true });
|
|
50
|
+
return workflowStatus(run);
|
|
51
|
+
}
|
|
52
|
+
if (command === 'status') return workflowStatus(await validate(await readJson(root, values[0])));
|
|
53
|
+
|
|
54
|
+
const [runFile, nodeId, argument] = values;
|
|
55
|
+
const run = await updateRun(root, runFile, async previous => {
|
|
56
|
+
// Work on a copy so the optimistic edit check still compares original bytes/data.
|
|
57
|
+
const next = structuredClone(previous);
|
|
58
|
+
await validate(next, { evidence: command !== 'reset' });
|
|
59
|
+
nodeById(next.graph, nodeId);
|
|
60
|
+
if (command === 'start') {
|
|
61
|
+
requireReady(next, nodeId, argument);
|
|
62
|
+
next.state.nodes[nodeId].status = 'running';
|
|
63
|
+
next.state.nodes[nodeId].attempts += 1;
|
|
64
|
+
next.history.push({ event: 'start', nodeId, at: new Date().toISOString() });
|
|
65
|
+
} else if (command === 'record') {
|
|
66
|
+
const result = await readJson(root, argument);
|
|
67
|
+
if (result.token !== taskToken(next, nodeId)) throw new Error('Stale or missing task token; read fresh status.');
|
|
68
|
+
if (next.state.nodes[nodeId].status !== 'running') throw new Error(`Node must be started before recording: ${nodeId}`);
|
|
69
|
+
if (typeof result.output?.summary !== 'string' || !result.output.summary.trim()) throw new Error('Node output needs a summary.');
|
|
70
|
+
const evaluation = normalizeEvaluation(result.evaluation);
|
|
71
|
+
if (!evaluation.passed && (typeof evaluation.feedback !== 'string' || !evaluation.feedback.trim())) throw new Error('Failed evaluation needs feedback.');
|
|
72
|
+
const hashes = await evidenceHashes(root, result.output.evidence);
|
|
73
|
+
const current = next.state.nodes[nodeId];
|
|
74
|
+
next.state.nodes[nodeId] = {
|
|
75
|
+
status: evaluation.passed ? 'completed' : 'failed', attempts: current.attempts, revision: current.revision,
|
|
76
|
+
output: result.output, evaluation, evidenceHashes: hashes,
|
|
77
|
+
...(!evaluation.passed ? { error: evaluation.feedback } : {}),
|
|
78
|
+
};
|
|
79
|
+
next.history.push({ event: 'record', nodeId, at: new Date().toISOString(), result: next.state.nodes[nodeId] });
|
|
80
|
+
} else {
|
|
81
|
+
if (!argument.trim()) throw new Error('Reset requires a reason.');
|
|
82
|
+
const status = workflowStatus(next);
|
|
83
|
+
if (['human', 'replan', 'stop'].includes(status.action)) throw new Error(`Cannot blindly retry ${status.action}; resolve the decision and create a new run.`);
|
|
84
|
+
const affected = [...descendantIds(next.graph, [nodeId])];
|
|
85
|
+
if (affected.some(id => id !== nodeId && next.state.nodes[id].status === 'running')) throw new Error('Stop running descendants before resetting their inputs.');
|
|
86
|
+
if (affected.some(id => next.state.nodes[id].attempts >= MAX_ATTEMPTS)) throw new Error('Attempt limit reached; stop and inspect the evidence.');
|
|
87
|
+
next.state = resetAffectedSubgraph(next.graph, next.state, [nodeId]);
|
|
88
|
+
next.history.push({ event: 'reset', nodeId, affected, reason: argument, at: new Date().toISOString() });
|
|
89
|
+
await checkRunEvidence(root, next);
|
|
90
|
+
}
|
|
91
|
+
return next;
|
|
92
|
+
});
|
|
93
|
+
return { ...workflowStatus(run), ...(command === 'start' ? { started: taskInput(run, nodeId) } : {}) };
|
|
94
|
+
}
|