@cloverleaf/reference-impl 0.8.2 → 0.8.4
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/VERSION +1 -1
- package/dist/discovery-config.mjs +12 -1
- package/dist/prep-worktree.mjs +14 -0
- package/dist/qa-report.mjs +4 -1
- package/lib/discovery-config.ts +13 -1
- package/lib/prep-worktree.ts +15 -0
- package/lib/qa-report.ts +4 -2
- package/package.json +1 -1
- package/skills/cloverleaf-breakdown/SKILL.md +2 -0
- package/skills/cloverleaf-document/SKILL.md +2 -0
- package/skills/cloverleaf-draft-rfc/SKILL.md +2 -0
- package/skills/cloverleaf-implement/SKILL.md +2 -0
- package/skills/cloverleaf-qa/SKILL.md +2 -0
- package/skills/cloverleaf-review/SKILL.md +2 -0
- package/skills/cloverleaf-security-review/SKILL.md +3 -0
- package/skills/cloverleaf-spike/SKILL.md +2 -0
- package/skills/cloverleaf-ui-review/SKILL.md +2 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.4
|
|
@@ -5,7 +5,15 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
5
5
|
const PACKAGE_DEFAULT = join(here, '..', 'config', 'discovery.json');
|
|
6
6
|
export function loadDiscoveryConfig(repoRoot) {
|
|
7
7
|
const override = join(repoRoot, '.cloverleaf', 'config', 'discovery.json');
|
|
8
|
-
const
|
|
8
|
+
const rawFallback = JSON.parse(readFileSync(PACKAGE_DEFAULT, 'utf-8'));
|
|
9
|
+
const fallback = {
|
|
10
|
+
docContextUri: typeof rawFallback.docContextUri === 'string' ? rawFallback.docContextUri : '',
|
|
11
|
+
projectId: typeof rawFallback.projectId === 'string' ? rawFallback.projectId : '',
|
|
12
|
+
idStart: typeof rawFallback.idStart === 'number' ? rawFallback.idStart : 1,
|
|
13
|
+
prep_copy_dirs: Array.isArray(rawFallback.prep_copy_dirs)
|
|
14
|
+
? rawFallback.prep_copy_dirs.filter((p) => typeof p === 'string')
|
|
15
|
+
: [],
|
|
16
|
+
};
|
|
9
17
|
if (existsSync(override)) {
|
|
10
18
|
try {
|
|
11
19
|
const doc = JSON.parse(readFileSync(override, 'utf-8'));
|
|
@@ -22,5 +30,8 @@ function normalise(doc, fallback) {
|
|
|
22
30
|
docContextUri: typeof doc.docContextUri === 'string' ? doc.docContextUri : fallback.docContextUri,
|
|
23
31
|
projectId: typeof doc.projectId === 'string' ? doc.projectId : fallback.projectId,
|
|
24
32
|
idStart: typeof doc.idStart === 'number' ? doc.idStart : fallback.idStart,
|
|
33
|
+
prep_copy_dirs: Array.isArray(doc.prep_copy_dirs)
|
|
34
|
+
? doc.prep_copy_dirs.filter((p) => typeof p === 'string')
|
|
35
|
+
: fallback.prep_copy_dirs,
|
|
25
36
|
};
|
|
26
37
|
}
|
package/dist/prep-worktree.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cpSync, existsSync, rmSync } from 'node:fs';
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
|
+
import { loadDiscoveryConfig } from './discovery-config.mjs';
|
|
4
5
|
/**
|
|
5
6
|
* Prepare a freshly-created git worktree of the cloverleaf monorepo for running reference-impl
|
|
6
7
|
* tests. Addresses the v0.5 dogfood finding (CLV-16, CLV-17 Delivery runs) where Reviewer/QA
|
|
@@ -116,6 +117,19 @@ export function prepWorktree(mainRoot, worktreePath) {
|
|
|
116
117
|
primeCopy(mainStandardNm, wtStandardNm);
|
|
117
118
|
primeCopy(mainRefImplNm, wtRefImplNm);
|
|
118
119
|
primeCopy(join(resolvedMain, 'reference-impl', 'dist'), join(worktreePath, 'reference-impl', 'dist'));
|
|
120
|
+
// Honor discovery_config.prep_copy_dirs: copy each listed gitignored directory
|
|
121
|
+
// (e.g., docs/superpowers) from mainRoot into the worktree. Walker briefs reference
|
|
122
|
+
// these paths but git checkouts of main don't carry gitignored content.
|
|
123
|
+
const discoveryConfig = loadDiscoveryConfig(resolvedMain);
|
|
124
|
+
for (const dir of discoveryConfig.prep_copy_dirs) {
|
|
125
|
+
const srcPath = join(resolvedMain, dir);
|
|
126
|
+
const dstPath = join(worktreePath, dir);
|
|
127
|
+
if (!existsSync(srcPath)) {
|
|
128
|
+
process.stderr.write(`prep-worktree: prep_copy_dirs entry '${dir}' not found at ${srcPath} — skipping.\n`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
primeCopy(srcPath, dstPath);
|
|
132
|
+
}
|
|
119
133
|
execSync('npm run build', {
|
|
120
134
|
cwd: join(worktreePath, 'standard'),
|
|
121
135
|
stdio: 'pipe',
|
package/dist/qa-report.mjs
CHANGED
package/lib/discovery-config.ts
CHANGED
|
@@ -9,11 +9,20 @@ export interface DiscoveryConfig {
|
|
|
9
9
|
docContextUri: string;
|
|
10
10
|
projectId: string;
|
|
11
11
|
idStart: number;
|
|
12
|
+
prep_copy_dirs: string[];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function loadDiscoveryConfig(repoRoot: string): DiscoveryConfig {
|
|
15
16
|
const override = join(repoRoot, '.cloverleaf', 'config', 'discovery.json');
|
|
16
|
-
const
|
|
17
|
+
const rawFallback = JSON.parse(readFileSync(PACKAGE_DEFAULT, 'utf-8')) as Partial<DiscoveryConfig>;
|
|
18
|
+
const fallback: DiscoveryConfig = {
|
|
19
|
+
docContextUri: typeof rawFallback.docContextUri === 'string' ? rawFallback.docContextUri : '',
|
|
20
|
+
projectId: typeof rawFallback.projectId === 'string' ? rawFallback.projectId : '',
|
|
21
|
+
idStart: typeof rawFallback.idStart === 'number' ? rawFallback.idStart : 1,
|
|
22
|
+
prep_copy_dirs: Array.isArray(rawFallback.prep_copy_dirs)
|
|
23
|
+
? (rawFallback.prep_copy_dirs as unknown[]).filter((p): p is string => typeof p === 'string')
|
|
24
|
+
: [],
|
|
25
|
+
};
|
|
17
26
|
|
|
18
27
|
if (existsSync(override)) {
|
|
19
28
|
try {
|
|
@@ -31,5 +40,8 @@ function normalise(doc: Partial<DiscoveryConfig>, fallback: DiscoveryConfig): Di
|
|
|
31
40
|
docContextUri: typeof doc.docContextUri === 'string' ? doc.docContextUri : fallback.docContextUri,
|
|
32
41
|
projectId: typeof doc.projectId === 'string' ? doc.projectId : fallback.projectId,
|
|
33
42
|
idStart: typeof doc.idStart === 'number' ? doc.idStart : fallback.idStart,
|
|
43
|
+
prep_copy_dirs: Array.isArray(doc.prep_copy_dirs)
|
|
44
|
+
? (doc.prep_copy_dirs as unknown[]).filter((p): p is string => typeof p === 'string')
|
|
45
|
+
: fallback.prep_copy_dirs,
|
|
34
46
|
};
|
|
35
47
|
}
|
package/lib/prep-worktree.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cpSync, existsSync, rmSync } from 'node:fs';
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
|
+
import { loadDiscoveryConfig } from './discovery-config.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Prepare a freshly-created git worktree of the cloverleaf monorepo for running reference-impl
|
|
@@ -130,6 +131,20 @@ export function prepWorktree(mainRoot: string, worktreePath: string): void {
|
|
|
130
131
|
primeCopy(mainRefImplNm, wtRefImplNm);
|
|
131
132
|
primeCopy(join(resolvedMain, 'reference-impl', 'dist'), join(worktreePath, 'reference-impl', 'dist'));
|
|
132
133
|
|
|
134
|
+
// Honor discovery_config.prep_copy_dirs: copy each listed gitignored directory
|
|
135
|
+
// (e.g., docs/superpowers) from mainRoot into the worktree. Walker briefs reference
|
|
136
|
+
// these paths but git checkouts of main don't carry gitignored content.
|
|
137
|
+
const discoveryConfig = loadDiscoveryConfig(resolvedMain);
|
|
138
|
+
for (const dir of discoveryConfig.prep_copy_dirs) {
|
|
139
|
+
const srcPath = join(resolvedMain, dir);
|
|
140
|
+
const dstPath = join(worktreePath, dir);
|
|
141
|
+
if (!existsSync(srcPath)) {
|
|
142
|
+
process.stderr.write(`prep-worktree: prep_copy_dirs entry '${dir}' not found at ${srcPath} — skipping.\n`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
primeCopy(srcPath, dstPath);
|
|
146
|
+
}
|
|
147
|
+
|
|
133
148
|
execSync('npm run build', {
|
|
134
149
|
cwd: join(worktreePath, 'standard'),
|
|
135
150
|
stdio: 'pipe',
|
package/lib/qa-report.ts
CHANGED
|
@@ -8,8 +8,10 @@ export interface QaRunResult {
|
|
|
8
8
|
stderrTail: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function escape(s:
|
|
12
|
-
return
|
|
11
|
+
function escape(s: unknown): string {
|
|
12
|
+
if (s === undefined || s === null) return '';
|
|
13
|
+
const str = typeof s === 'string' ? s : String(s);
|
|
14
|
+
return str
|
|
13
15
|
.replace(/&/g, '&')
|
|
14
16
|
.replace(/</g, '<')
|
|
15
17
|
.replace(/>/g, '>')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloverleaf/reference-impl",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Reference implementation of the Cloverleaf methodology as Claude Code skills. Implements the Tight Loop (Implementer + Reviewer).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,6 +46,8 @@ The user has invoked this skill with an RFC-ID (e.g., `CLV-009`).
|
|
|
46
46
|
|
|
47
47
|
In the subagent context, also supply a hint that `next_id_base === $PLAN_ID`, so task IDs in `tasks[]` start at `PLAN_ID + 1`. The Plan agent allocates its own ID as `next_id_base` and task IDs sequentially after.
|
|
48
48
|
|
|
49
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
50
|
+
|
|
49
51
|
7. Parse subagent response — expected JSON conforming to `plan.schema.json`. Required fields: `id, type: "plan", status: "drafting", owner, project, parent_rfc, task_dag (edge-based), tasks (inline Task docs, status=pending)`. 3-bounce budget per invocation.
|
|
50
52
|
|
|
51
53
|
8. Ensure output `plan.id === $PLAN_ID`, `project === $PROJECT_ID`, `parent_rfc === { project: <rfc.project>, id: $RFC_ID }`. If the subagent drifted, override these before save.
|
|
@@ -43,6 +43,8 @@ description: Run the Documenter agent on a task in the `implementing` state (ful
|
|
|
43
43
|
- `{{base_branch}}` → `main`
|
|
44
44
|
- `{{repo_root}}` → absolute path
|
|
45
45
|
|
|
46
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
47
|
+
|
|
46
48
|
6. Parse the subagent's response. Expect JSON of the form `{"commits_added": N, "files_changed": [...], "summary": "..."}`.
|
|
47
49
|
|
|
48
50
|
7. On failure to parse or response with invalid shape: report the response and stop without advancing state.
|
|
@@ -41,6 +41,8 @@ The user has invoked this skill with an RFC-ID (e.g., `CLV-009`).
|
|
|
41
41
|
- `{{completed_spikes}}` → `COMPLETED_SPIKES` JSON array (or `[]`)
|
|
42
42
|
- `{{spike}}` → (unused for draftRfc; substitute `null`)
|
|
43
43
|
|
|
44
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
45
|
+
|
|
44
46
|
6. Parse subagent's response: expected JSON conforming to `rfc.schema.json`. Required fields: `id`, `type: "rfc"`, `status: "drafting"`, `owner`, `project`, `title`, `problem`, `solution`, `unknowns` (array of strings), `acceptance_criteria`, `out_of_scope`.
|
|
45
47
|
|
|
46
48
|
If output fails schema validation: bounce. Budget: 3 bounces per invocation. On budget exhaustion: report and stop without advancing state.
|
|
@@ -32,6 +32,8 @@ The user has invoked this skill with a TASK-ID (e.g., `DEMO-001`).
|
|
|
32
32
|
- `{{repo_root}}` → absolute path to the current repo
|
|
33
33
|
- `{{base_branch}}` → `main` (or the current default branch)
|
|
34
34
|
|
|
35
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
36
|
+
|
|
35
37
|
5. Parse the subagent's response. Expect JSON of the form `{"status": "done", "branch": "...", "files_changed": [...], "summary": "..."}` or `{"status": "blocked", "reason": "..."}`.
|
|
36
38
|
|
|
37
39
|
6. On `blocked`: report the reason and stop. Do NOT advance status.
|
|
@@ -49,6 +49,8 @@ description: Run the QA agent on a task in the `qa` state (full pipeline only).
|
|
|
49
49
|
- `model`: `sonnet`
|
|
50
50
|
- Prompt: contents of `$(cloverleaf-cli plugin-root)/prompts/qa.md` with substitutions for `{{task}}`, `{{diff}}`, `{{branch}}`, `{{base_branch}}`, `{{repo_root}}`, `{{qa_rules}}` (the JSON loaded in step 5).
|
|
51
51
|
|
|
52
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
53
|
+
|
|
52
54
|
8. Parse response: expect `{"verdict": "pass"|"bounce"|"escalate", "summary", "findings", "results"}`.
|
|
53
55
|
|
|
54
56
|
9. Branch on verdict:
|
|
@@ -42,6 +42,8 @@ description: Run the Reviewer agent on a task in the `review` state. Emits a fee
|
|
|
42
42
|
- `model`: `sonnet`
|
|
43
43
|
- Prompt: contents of `$(cloverleaf-cli plugin-root)/prompts/reviewer.md` with substitutions for `{{task}}`, `{{branch}}`, `{{base_branch}}`, `{{repo_root}}`, `{{diff}}`.
|
|
44
44
|
|
|
45
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
46
|
+
|
|
45
47
|
6. Parse the subagent's response. Expect a feedback envelope JSON of the form `{"verdict": "pass"|"bounce", "summary": "...", "findings": [...]}`. Validate shape: verdict must be `pass` or `bounce`; if `bounce`, findings must have at least one entry with `severity` (one of `blocker|error|warning|info`) and `message`.
|
|
46
48
|
|
|
47
49
|
7. Branch on verdict:
|
|
@@ -28,6 +28,9 @@ description: Run the Security Reviewer agent on a task in the `security-review`
|
|
|
28
28
|
- `subagent_type`: `general-purpose`
|
|
29
29
|
- `model`: `sonnet`
|
|
30
30
|
- Prompt: contents of `$(cloverleaf-cli plugin-root)/prompts/security-reviewer.md` with substitutions for `{{task}}`, `{{branch}}`, `{{base_branch}}`, `{{repo_root}}`, `{{diff}}`.
|
|
31
|
+
|
|
32
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
33
|
+
|
|
31
34
|
Parse the subagent's feedback envelope (`verdict` + `findings[]`).
|
|
32
35
|
|
|
33
36
|
6. **Merge + derive verdict.** Concatenate Pass A findings + Pass B findings into one `findings[]`. Derive the final verdict from the max severity across ALL findings:
|
|
@@ -38,6 +38,8 @@ The user has invoked this skill with a SPIKE-ID (e.g., `CLV-010`).
|
|
|
38
38
|
- `{{brief}}` → `null` (unused for runSpike)
|
|
39
39
|
- `{{prior_rfc}}`, `{{completed_spikes}}` → `null`
|
|
40
40
|
|
|
41
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
42
|
+
|
|
41
43
|
6. Parse subagent response. Expected: the spike JSON with `status: "completed"`, `findings: string`, `recommendation: string`. Schema: `spike.schema.json` (validated by save-spike).
|
|
42
44
|
|
|
43
45
|
If output fails schema validation: bounce. Budget: 3 bounces. On exhaustion: report and stop without advancing to completed.
|
|
@@ -72,6 +72,8 @@ description: Run the UI Reviewer agent on a task in the `ui-review` state (full
|
|
|
72
72
|
- `{{affected_routes}}` → the value of `$AFFECTED` (verbatim — may be `"all"`, a JSON array, or `[]` but step 6 handled `[]` already)
|
|
73
73
|
- `{{ui_review_config}}` → JSON-stringified result of `cloverleaf-cli ui-review-config <repo_root>` (used by the subagent to scope viewport sizes, thresholds, and axe rule overrides)
|
|
74
74
|
|
|
75
|
+
**Dispatch conventions:** invoke the Task tool in foreground mode (its default — do NOT pass `run_in_background: true`). The Task tool returns the subagent's final message as a string in the result. Do NOT use Bash `sleep` to poll an output file — the harness blocks foreground `sleep`, and background dispatch is unnecessary here because the foreground Task tool already blocks until the subagent finishes.
|
|
76
|
+
|
|
75
77
|
11. Parse the subagent's response. Expect `{"verdict": "pass"|"bounce"|"escalate", "summary": "...", "findings": [...]}`.
|
|
76
78
|
|
|
77
79
|
12. **Read the baseline-approval sidecar** (after the subagent completes, regardless of verdict):
|