@gr8ful/spf 0.1.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/LICENSE +21 -0
- package/README.md +321 -0
- package/assets/defaults/spf.config.yaml +141 -0
- package/assets/prompts/builder/system.md +13 -0
- package/assets/prompts/builder/user.md +34 -0
- package/assets/prompts/documenter/system.md +17 -0
- package/assets/prompts/documenter/user.md +48 -0
- package/assets/prompts/planner/system.md +21 -0
- package/assets/prompts/planner/user.md +45 -0
- package/assets/prompts/reviewer/system.md +16 -0
- package/assets/prompts/reviewer/user.md +44 -0
- package/assets/prompts/scout/system.md +20 -0
- package/assets/prompts/scout/user.md +34 -0
- package/assets/skill/SKILL.md +80 -0
- package/assets/skill/cookbooks/authoring_chains.md +193 -0
- package/assets/skill/cookbooks/how_to_prompt_for_the_eng.md +109 -0
- package/assets/skill/cookbooks/roster.md +197 -0
- package/assets/skill/cookbooks/run_adw.md +92 -0
- package/assets/skill/cookbooks/spf_overview.md +111 -0
- package/assets/skill/references/config.md +188 -0
- package/assets/skill/references/handoff.md +162 -0
- package/assets/skill/references/observability.md +184 -0
- package/dist/chains/adw_build.d.ts +12 -0
- package/dist/chains/adw_build.js +27 -0
- package/dist/chains/adw_build_review.d.ts +21 -0
- package/dist/chains/adw_build_review.js +55 -0
- package/dist/chains/adw_build_test.d.ts +21 -0
- package/dist/chains/adw_build_test.js +67 -0
- package/dist/chains/adw_document.d.ts +23 -0
- package/dist/chains/adw_document.js +59 -0
- package/dist/chains/adw_plan.d.ts +12 -0
- package/dist/chains/adw_plan.js +27 -0
- package/dist/chains/adw_plan_build.d.ts +12 -0
- package/dist/chains/adw_plan_build.js +30 -0
- package/dist/chains/adw_plan_build_test.d.ts +16 -0
- package/dist/chains/adw_plan_build_test.js +65 -0
- package/dist/chains/adw_plan_build_test_quality.d.ts +18 -0
- package/dist/chains/adw_plan_build_test_quality.js +66 -0
- package/dist/chains/adw_prompt.d.ts +12 -0
- package/dist/chains/adw_prompt.js +25 -0
- package/dist/chains/adw_quality.d.ts +12 -0
- package/dist/chains/adw_quality.js +32 -0
- package/dist/chains/adw_scout.d.ts +12 -0
- package/dist/chains/adw_scout.js +27 -0
- package/dist/chains/adw_simple_sdlc.d.ts +43 -0
- package/dist/chains/adw_simple_sdlc.js +147 -0
- package/dist/chains/context.d.ts +19 -0
- package/dist/chains/context.js +1 -0
- package/dist/chains/index.d.ts +19 -0
- package/dist/chains/index.js +116 -0
- package/dist/cli/bin.d.ts +15 -0
- package/dist/cli/bin.js +24 -0
- package/dist/cli/commands/abort.d.ts +1 -0
- package/dist/cli/commands/abort.js +42 -0
- package/dist/cli/commands/doctor.d.ts +1 -0
- package/dist/cli/commands/doctor.js +165 -0
- package/dist/cli/commands/eject.d.ts +1 -0
- package/dist/cli/commands/eject.js +55 -0
- package/dist/cli/commands/events.d.ts +1 -0
- package/dist/cli/commands/events.js +49 -0
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.js +62 -0
- package/dist/cli/commands/install-skill.d.ts +1 -0
- package/dist/cli/commands/install-skill.js +122 -0
- package/dist/cli/commands/list.d.ts +1 -0
- package/dist/cli/commands/list.js +13 -0
- package/dist/cli/commands/migrate.d.ts +1 -0
- package/dist/cli/commands/migrate.js +167 -0
- package/dist/cli/commands/phases.d.ts +1 -0
- package/dist/cli/commands/phases.js +25 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.js +27 -0
- package/dist/cli/commands/sessions.d.ts +1 -0
- package/dist/cli/commands/sessions.js +20 -0
- package/dist/cli/commands/trace.d.ts +8 -0
- package/dist/cli/commands/trace.js +10 -0
- package/dist/cli/commands/ui.d.ts +1 -0
- package/dist/cli/commands/ui.js +35 -0
- package/dist/cli/commands/version.d.ts +1 -0
- package/dist/cli/commands/version.js +8 -0
- package/dist/cli/commands/watch.d.ts +8 -0
- package/dist/cli/commands/watch.js +210 -0
- package/dist/cli/gitignore.d.ts +1 -0
- package/dist/cli/gitignore.js +14 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +156 -0
- package/dist/core/agent_cc.d.ts +75 -0
- package/dist/core/agent_cc.js +322 -0
- package/dist/core/agent_flue.d.ts +66 -0
- package/dist/core/agent_flue.js +321 -0
- package/dist/core/agents.d.ts +64 -0
- package/dist/core/agents.js +456 -0
- package/dist/core/changes.d.ts +35 -0
- package/dist/core/changes.js +98 -0
- package/dist/core/console.d.ts +36 -0
- package/dist/core/console.js +156 -0
- package/dist/core/data_types.d.ts +562 -0
- package/dist/core/data_types.js +382 -0
- package/dist/core/gates.d.ts +33 -0
- package/dist/core/gates.js +144 -0
- package/dist/core/git_helper.d.ts +59 -0
- package/dist/core/git_helper.js +115 -0
- package/dist/core/issues/github_provider.d.ts +52 -0
- package/dist/core/issues/github_provider.js +211 -0
- package/dist/core/issues/provider.d.ts +90 -0
- package/dist/core/issues/provider.js +14 -0
- package/dist/core/paths.d.ts +78 -0
- package/dist/core/paths.js +108 -0
- package/dist/core/permissions.d.ts +78 -0
- package/dist/core/permissions.js +187 -0
- package/dist/core/prompts.d.ts +4 -0
- package/dist/core/prompts.js +17 -0
- package/dist/core/quality.d.ts +65 -0
- package/dist/core/quality.js +194 -0
- package/dist/core/runner.d.ts +72 -0
- package/dist/core/runner.js +168 -0
- package/dist/core/session.d.ts +16 -0
- package/dist/core/session.js +60 -0
- package/dist/core/sqlite.d.ts +55 -0
- package/dist/core/sqlite.js +106 -0
- package/dist/core/tracer.d.ts +56 -0
- package/dist/core/tracer.js +246 -0
- package/dist/core/utils.d.ts +40 -0
- package/dist/core/utils.js +108 -0
- package/dist/core/watch.d.ts +44 -0
- package/dist/core/watch.js +194 -0
- package/dist/test/agent_cc.test.d.ts +1 -0
- package/dist/test/agent_cc.test.js +95 -0
- package/dist/test/agent_flue.test.d.ts +1 -0
- package/dist/test/agent_flue.test.js +83 -0
- package/dist/test/data_types.test.d.ts +10 -0
- package/dist/test/data_types.test.js +49 -0
- package/dist/test/ui_server.test.d.ts +1 -0
- package/dist/test/ui_server.test.js +119 -0
- package/dist/test/watch.test.d.ts +1 -0
- package/dist/test/watch.test.js +227 -0
- package/dist/ui/server/app.d.ts +3 -0
- package/dist/ui/server/app.js +98 -0
- package/dist/ui/server/db.d.ts +82 -0
- package/dist/ui/server/db.js +333 -0
- package/dist/ui/server/serve.d.ts +13 -0
- package/dist/ui/server/serve.js +80 -0
- package/dist/ui/server/static.d.ts +5 -0
- package/dist/ui/server/static.js +55 -0
- package/dist/ui/shared/types.d.ts +263 -0
- package/dist/ui/shared/types.js +8 -0
- package/package.json +52 -0
- package/web/assets/index-C7nF068F.css +1 -0
- package/web/assets/index-mzSArcnQ.js +11 -0
- package/web/assets/play-latin-400-normal-GKW-4YV7.woff2 +0 -0
- package/web/assets/play-latin-700-normal-DyPlLDbb.woff2 +0 -0
- package/web/index.html +14 -0
- package/web/logo.svg +6 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console reporter: one narrative, two destinations.
|
|
3
|
+
*
|
|
4
|
+
* Every line an ADW prints ALSO lands in the db as a `log` event, so the swim-lane
|
|
5
|
+
* UI reads the same story the terminal does. Both go through `emit` — print and
|
|
6
|
+
* trace cannot drift. Plain sequential lines only: no spinners, no live displays,
|
|
7
|
+
* so a CI log reads exactly like a terminal.
|
|
8
|
+
*/
|
|
9
|
+
import { makeEventRecord } from "./data_types.js";
|
|
10
|
+
const KIND_COLOR = { engineer: "cyan", agent: "magenta", code: "yellow" };
|
|
11
|
+
const MAX_LINE = 160; // dynamic text (summaries, violations, errors) is clipped
|
|
12
|
+
const RESET = "\x1b[0m";
|
|
13
|
+
const CODES = {
|
|
14
|
+
bold: "1",
|
|
15
|
+
dim: "2",
|
|
16
|
+
red: "31",
|
|
17
|
+
green: "32",
|
|
18
|
+
yellow: "33",
|
|
19
|
+
blue: "34",
|
|
20
|
+
magenta: "35",
|
|
21
|
+
cyan: "36",
|
|
22
|
+
white: "37",
|
|
23
|
+
};
|
|
24
|
+
function paint(style, text) {
|
|
25
|
+
const codes = style.split(" ").map((s) => CODES[s]).filter(Boolean);
|
|
26
|
+
if (codes.length === 0)
|
|
27
|
+
return text;
|
|
28
|
+
return `\x1b[${codes.join(";")}m${text}${RESET}`;
|
|
29
|
+
}
|
|
30
|
+
function stripAnsi(text) {
|
|
31
|
+
return text.replace(/\x1b\[[0-9;]*m/g, "");
|
|
32
|
+
}
|
|
33
|
+
function clip(text, limit = MAX_LINE) {
|
|
34
|
+
const joined = String(text).split(/\s+/).filter(Boolean).join(" ");
|
|
35
|
+
return joined.length <= limit ? joined : joined.slice(0, limit - 1) + "…";
|
|
36
|
+
}
|
|
37
|
+
function panel(lines, title, borderColor) {
|
|
38
|
+
const contentWidth = Math.max(...lines.map((l) => stripAnsi(l).length), stripAnsi(title).length + 2);
|
|
39
|
+
const top = paint(`bold ${borderColor}`, `╭─ ${title} ${"─".repeat(Math.max(0, contentWidth - title.length - 1))}╮`);
|
|
40
|
+
const bottom = paint(`bold ${borderColor}`, `╰${"─".repeat(contentWidth + 3)}╯`);
|
|
41
|
+
const body = lines.map((l) => `${paint(borderColor, "│")} ${l}${" ".repeat(Math.max(0, contentWidth - stripAnsi(l).length))} ${paint(borderColor, "│")}`);
|
|
42
|
+
return [top, ...body, bottom].join("\n");
|
|
43
|
+
}
|
|
44
|
+
/** Bound to one run's tracer. Reachable as `run.console` everywhere. */
|
|
45
|
+
export class Console {
|
|
46
|
+
tracer;
|
|
47
|
+
adwId;
|
|
48
|
+
phaseId = ""; // current lane — log events attach to it
|
|
49
|
+
phaseName = "";
|
|
50
|
+
results = []; // phase statuses, for the summary
|
|
51
|
+
finished = false; // the summary panel prints once
|
|
52
|
+
constructor(tracer, adwId) {
|
|
53
|
+
this.tracer = tracer;
|
|
54
|
+
this.adwId = adwId;
|
|
55
|
+
}
|
|
56
|
+
// ── the one helper: print AND trace, always together ────────────────────
|
|
57
|
+
emit(line, level = "info") {
|
|
58
|
+
console.log(line);
|
|
59
|
+
this.tracer.event(makeEventRecord({
|
|
60
|
+
adw_id: this.adwId,
|
|
61
|
+
phase_id: this.phaseId,
|
|
62
|
+
type: "log",
|
|
63
|
+
name: this.phaseName || "console",
|
|
64
|
+
payload: { message: stripAnsi(line), level },
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
// ── session ─────────────────────────────────────────────────────────────
|
|
68
|
+
sessionStarted(adwId, engineer) {
|
|
69
|
+
this.emit(`${paint("bold cyan", "adw_id:")} ${paint("bold", adwId)} ${paint("dim", "engineer")} ${engineer}`);
|
|
70
|
+
}
|
|
71
|
+
sessionFinished(ok, tokens, cost, dbPath) {
|
|
72
|
+
if (this.finished)
|
|
73
|
+
return;
|
|
74
|
+
this.finished = true;
|
|
75
|
+
const passed = this.results.filter((r) => r === "success").length;
|
|
76
|
+
const status = ok ? paint("green", "✓ success") : paint("red", "✗ fail");
|
|
77
|
+
const rows = [
|
|
78
|
+
` ${paint("dim", "status")} ${status}`,
|
|
79
|
+
` ${paint("dim", "phases")} ${passed}/${this.results.length} passed`,
|
|
80
|
+
` ${paint("dim", "tokens")} ${tokens.toLocaleString()}`,
|
|
81
|
+
` ${paint("dim", "cost")} $${cost.toFixed(4)}`,
|
|
82
|
+
` ${paint("dim", "adw_id")} ${this.adwId}`,
|
|
83
|
+
` ${paint("dim", "db")} ${dbPath}`,
|
|
84
|
+
` ${paint("dim", "next")} ${paint("bold", `just phases ${this.adwId}`)}`,
|
|
85
|
+
];
|
|
86
|
+
const rendered = panel(rows, "ADW complete", ok ? "green" : "red");
|
|
87
|
+
console.log(rendered);
|
|
88
|
+
const plain = `session ${this.adwId} ${ok ? "success" : "fail"} · ${passed}/${this.results.length} phases · ${tokens.toLocaleString()} tokens · $${cost.toFixed(4)}`;
|
|
89
|
+
this.tracer.event(makeEventRecord({
|
|
90
|
+
adw_id: this.adwId,
|
|
91
|
+
phase_id: this.phaseId,
|
|
92
|
+
type: "log",
|
|
93
|
+
name: this.phaseName || "console",
|
|
94
|
+
payload: { message: plain, level: ok ? "info" : "error" },
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
// ── phases ──────────────────────────────────────────────────────────────
|
|
98
|
+
phaseStarted(phase) {
|
|
99
|
+
this.phaseId = phase.phase_id;
|
|
100
|
+
this.phaseName = phase.params.name;
|
|
101
|
+
const p = phase.params;
|
|
102
|
+
const color = KIND_COLOR[p.kind] || "white";
|
|
103
|
+
let line = paint(`bold ${color}`, `▶ ${String(phase.seq).padStart(2, "0")} ${p.name}`) +
|
|
104
|
+
` ${paint(color, p.kind)} ${paint("dim", `· ${p.owner}`)}`;
|
|
105
|
+
if (p.description)
|
|
106
|
+
line += ` ${paint("dim", clip(p.description))}`;
|
|
107
|
+
this.emit(line);
|
|
108
|
+
}
|
|
109
|
+
phaseEnded(phase, seconds) {
|
|
110
|
+
const ok = phase.status === "success";
|
|
111
|
+
this.results.push(phase.status);
|
|
112
|
+
let line = ` ${ok ? paint("green", "✓") : paint("red", "✗")} ${phase.params.name} ${paint("dim", `${seconds.toFixed(1)}s`)}`;
|
|
113
|
+
if (!ok && phase.error)
|
|
114
|
+
line += ` ${paint("red", clip(phase.error))}`;
|
|
115
|
+
this.emit(line, ok ? "info" : "error");
|
|
116
|
+
this.phaseId = "";
|
|
117
|
+
this.phaseName = "";
|
|
118
|
+
}
|
|
119
|
+
/** Free-form detail inside the current phase — what `ph.log()` recorded. */
|
|
120
|
+
note(message) {
|
|
121
|
+
this.emit(` ${paint("dim", `· ${clip(message)}`)}`);
|
|
122
|
+
}
|
|
123
|
+
// ── agents ──────────────────────────────────────────────────────────────
|
|
124
|
+
agentStarted(name, model, sessionId) {
|
|
125
|
+
this.emit(` ${paint("magenta", "▸")} ${name} ${paint("dim", model)} ${paint("dim", `session ${sessionId}`)}`);
|
|
126
|
+
}
|
|
127
|
+
agentFinished(name, tokens, cost) {
|
|
128
|
+
this.emit(` ${paint("dim", `└ ${name} used ${tokens.toLocaleString()} tokens · $${cost.toFixed(4)}`)}`);
|
|
129
|
+
}
|
|
130
|
+
retry(name, attempt, limit, reason) {
|
|
131
|
+
this.emit(` ${paint("yellow", "⟳")} ${name} retry ${attempt}/${limit} ${paint("dim", `— same session · ${clip(reason)}`)}`, "warn");
|
|
132
|
+
}
|
|
133
|
+
// ── verification ────────────────────────────────────────────────────────
|
|
134
|
+
/** A gate reports WHAT it checked, not just whether it passed. */
|
|
135
|
+
gateResult(name, report) {
|
|
136
|
+
const ok = report.passed;
|
|
137
|
+
const mark = ok ? paint("green", "✓") : paint("red", "✗");
|
|
138
|
+
const summary = ok
|
|
139
|
+
? `${report.checks.length} checked`
|
|
140
|
+
: paint("red", `${report.violations.length} of ${report.checks.length} failed`);
|
|
141
|
+
this.emit(` ${mark} gate ${paint("dim", name)} ${paint("dim", summary)}`, ok ? "info" : "error");
|
|
142
|
+
for (const check of report.checks) {
|
|
143
|
+
const style = check.ok ? "dim" : "dim red";
|
|
144
|
+
const detail = check.note ? ` — ${clip(check.note)}` : "";
|
|
145
|
+
this.emit(` ${paint(style, `${check.ok ? "·" : "✗"} ${clip(check.item)}${detail}`)}`, check.ok ? "info" : "error");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
envelopeSummary(envelope, typeName) {
|
|
149
|
+
const ok = envelope.status === "success";
|
|
150
|
+
const line = ` ${ok ? paint("green", "✓") : paint("red", "✗")} ${typeName} ${paint("dim", clip(envelope.summary))}`;
|
|
151
|
+
this.emit(line, ok ? "info" : "error");
|
|
152
|
+
if (envelope.artifacts.length > 0) {
|
|
153
|
+
this.emit(` ${paint("dim", `artifacts: ${clip(envelope.artifacts.join(", "))}`)}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|