@scanton/phase2s 1.0.0 → 1.8.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.
Files changed (65) hide show
  1. package/README.md +18 -1
  2. package/dist/src/cli/doctor.d.ts +39 -0
  3. package/dist/src/cli/doctor.d.ts.map +1 -0
  4. package/dist/src/cli/doctor.js +244 -0
  5. package/dist/src/cli/doctor.js.map +1 -0
  6. package/dist/src/cli/goal.d.ts +38 -1
  7. package/dist/src/cli/goal.d.ts.map +1 -1
  8. package/dist/src/cli/goal.js +274 -23
  9. package/dist/src/cli/goal.js.map +1 -1
  10. package/dist/src/cli/index.d.ts.map +1 -1
  11. package/dist/src/cli/index.js +116 -9
  12. package/dist/src/cli/index.js.map +1 -1
  13. package/dist/src/cli/init.d.ts +73 -0
  14. package/dist/src/cli/init.d.ts.map +1 -0
  15. package/dist/src/cli/init.js +366 -0
  16. package/dist/src/cli/init.js.map +1 -0
  17. package/dist/src/cli/lint.d.ts +32 -0
  18. package/dist/src/cli/lint.d.ts.map +1 -0
  19. package/dist/src/cli/lint.js +140 -0
  20. package/dist/src/cli/lint.js.map +1 -0
  21. package/dist/src/cli/report.d.ts +62 -0
  22. package/dist/src/cli/report.d.ts.map +1 -0
  23. package/dist/src/cli/report.js +188 -0
  24. package/dist/src/cli/report.js.map +1 -0
  25. package/dist/src/cli/upgrade.d.ts +35 -0
  26. package/dist/src/cli/upgrade.d.ts.map +1 -0
  27. package/dist/src/cli/upgrade.js +126 -0
  28. package/dist/src/cli/upgrade.js.map +1 -0
  29. package/dist/src/core/config.d.ts +60 -8
  30. package/dist/src/core/config.d.ts.map +1 -1
  31. package/dist/src/core/config.js +31 -1
  32. package/dist/src/core/config.js.map +1 -1
  33. package/dist/src/core/notify.d.ts +41 -0
  34. package/dist/src/core/notify.d.ts.map +1 -0
  35. package/dist/src/core/notify.js +153 -0
  36. package/dist/src/core/notify.js.map +1 -0
  37. package/dist/src/core/run-logger.d.ts +83 -0
  38. package/dist/src/core/run-logger.d.ts.map +1 -0
  39. package/dist/src/core/run-logger.js +70 -0
  40. package/dist/src/core/run-logger.js.map +1 -0
  41. package/dist/src/core/state.d.ts +74 -0
  42. package/dist/src/core/state.d.ts.map +1 -0
  43. package/dist/src/core/state.js +132 -0
  44. package/dist/src/core/state.js.map +1 -0
  45. package/dist/src/mcp/server.d.ts +17 -0
  46. package/dist/src/mcp/server.d.ts.map +1 -1
  47. package/dist/src/mcp/server.js +243 -4
  48. package/dist/src/mcp/server.js.map +1 -1
  49. package/dist/src/providers/gemini.d.ts +29 -0
  50. package/dist/src/providers/gemini.d.ts.map +1 -0
  51. package/dist/src/providers/gemini.js +47 -0
  52. package/dist/src/providers/gemini.js.map +1 -0
  53. package/dist/src/providers/index.d.ts +2 -0
  54. package/dist/src/providers/index.d.ts.map +1 -1
  55. package/dist/src/providers/index.js +8 -0
  56. package/dist/src/providers/index.js.map +1 -1
  57. package/dist/src/providers/openrouter.d.ts +25 -0
  58. package/dist/src/providers/openrouter.d.ts.map +1 -0
  59. package/dist/src/providers/openrouter.js +43 -0
  60. package/dist/src/providers/openrouter.js.map +1 -0
  61. package/dist/src/tools/registry.d.ts +5 -3
  62. package/dist/src/tools/registry.d.ts.map +1 -1
  63. package/dist/src/tools/registry.js +35 -12
  64. package/dist/src/tools/registry.js.map +1 -1
  65. package/package.json +1 -1
package/README.md CHANGED
@@ -228,7 +228,7 @@ phase2s skills --json # machine-readable for scripts
228
228
  - [x] Codex CLI provider (ChatGPT subscription, no API key required)
229
229
  - [x] 29 built-in skills across 6 categories
230
230
  - [x] File sandbox: tools reject paths outside project directory, including symlink escapes
231
- - [x] 399 tests covering all tools, core modules, agent integration, and goal executor
231
+ - [x] 582 tests covering all tools, core modules, agent integration, goal executor, state server, run logs, MCP goal tool, notification gateway, run report viewer, onboarding wizard, glob tool filtering, OpenRouter provider, Gemini provider, installation health checks, self-update, skills search, and spec linting
232
232
  - [x] CI: runs `npm test` on every push and PR
233
233
  - [x] OpenAI API provider with live tool calling
234
234
  - [x] Anthropic API provider — Claude 3.5 Sonnet and family
@@ -254,6 +254,23 @@ phase2s skills --json # machine-readable for scripts
254
254
  - [x] `phase2s goal <spec.md>` — dark factory: spec in, feature out
255
255
  - [x] 5-pillar spec format — `/deep-specify` output feeds directly into `phase2s goal`
256
256
  - [x] Real Codex streaming (JSONL stdout parsing) — step-by-step feedback for multi-step tasks
257
+ - [x] MCP state server — `state_read`/`state_write`/`state_clear` as Claude Code tools
258
+ - [x] `phase2s goal --resume` — dark factory continuity: resumes from last completed sub-task after interruption
259
+ - [x] `phase2s__goal` MCP tool — Claude Code can trigger the dark factory directly, no terminal needed
260
+ - [x] Structured JSONL run logs — per-sub-task observability at `.phase2s/runs/<timestamp>.jsonl`
261
+ - [x] `--review-before-run` — adversarial pre-execution review before the dark factory starts
262
+ - [x] Notification gateway — `phase2s goal --notify` sends macOS system notification + optional Slack webhook on completion
263
+ - [x] `phase2s report <log.jsonl>` — chalk-colored run summary: sub-task timeline, durations, criteria verdicts, total time
264
+ - [x] `phase2s__report` MCP tool — Claude Code can summarize a run log after triggering the dark factory
265
+ - [x] `phase2s init` — interactive onboarding wizard: provider choice, API key, model tiers, Slack/Discord/Teams webhooks, pre-fills from existing config
266
+ - [x] Discord + Microsoft Teams notification channels for dark factory runs (`--notify`)
267
+ - [x] Glob/wildcard patterns in `tools` and `deny` config (`file_*` matches `file_read` and `file_write`)
268
+ - [x] OpenRouter provider — 50+ models (GPT-4o, Claude, Gemini, Llama) under a single `OPENROUTER_API_KEY`
269
+ - [x] `phase2s doctor` — installation health check: Node version, provider binary, auth, config, working dir
270
+ - [x] `phase2s upgrade` — self-update: checks npm registry, prompts to install, `--check` for CI
271
+ - [x] `phase2s skills [query]` — filter the skill list by name or description (`phase2s skills security`)
272
+ - [x] Google Gemini provider — free tier, `gemini-2.0-flash` default, OpenAI-compatible endpoint, no new SDK dependency
273
+ - [x] `phase2s lint <spec.md>` — validate a spec before a dark factory run: catches structural errors before the 20-minute agent loop begins
257
274
 
258
275
  ---
259
276
 
@@ -0,0 +1,39 @@
1
+ /**
2
+ * phase2s doctor — installation health check.
3
+ *
4
+ * Runs a set of diagnostic checks and reports pass/fail with fix instructions.
5
+ * Designed to answer "why isn't phase2s working?" without reading source code.
6
+ *
7
+ * Pure check functions are exported for testing. runDoctor() handles all IO.
8
+ */
9
+ export interface CheckResult {
10
+ name: string;
11
+ ok: boolean;
12
+ detail: string;
13
+ /** Printed below the ✗ line when ok is false. */
14
+ fix?: string;
15
+ }
16
+ /**
17
+ * Check that Node.js >= 20 is running.
18
+ */
19
+ export declare function checkNodeVersion(): CheckResult;
20
+ /**
21
+ * Check that the provider binary is available in PATH (codex-cli and ollama only).
22
+ * Returns ok:true immediately for providers that don't need a binary.
23
+ */
24
+ export declare function checkProviderBinary(provider: string, codexPath?: string): CheckResult;
25
+ /**
26
+ * Check authentication / API key availability for the configured provider.
27
+ */
28
+ export declare function checkAuth(provider: string, config?: Record<string, unknown>): CheckResult;
29
+ /**
30
+ * Check that .phase2s.yaml exists and contains a valid provider value.
31
+ * Returns ok:true if the file is absent (config is optional).
32
+ */
33
+ export declare function checkConfigFile(configPath: string): CheckResult;
34
+ /**
35
+ * Check that the .phase2s/ working directory is writable (or can be created).
36
+ */
37
+ export declare function checkWorkDir(dirPath: string): CheckResult;
38
+ export declare function runDoctor(): Promise<void>;
39
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAU9C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAU,GAAG,WAAW,CA2BtF;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,WAAW,CAyEb;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAgC/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAezD;AAMD,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAoD/C"}
@@ -0,0 +1,244 @@
1
+ /**
2
+ * phase2s doctor — installation health check.
3
+ *
4
+ * Runs a set of diagnostic checks and reports pass/fail with fix instructions.
5
+ * Designed to answer "why isn't phase2s working?" without reading source code.
6
+ *
7
+ * Pure check functions are exported for testing. runDoctor() handles all IO.
8
+ */
9
+ import { spawnSync } from "node:child_process";
10
+ import { existsSync, accessSync, mkdirSync, constants } from "node:fs";
11
+ import { resolve, join } from "node:path";
12
+ import chalk from "chalk";
13
+ import { parse as parseYaml } from "yaml";
14
+ import { readFileSync } from "node:fs";
15
+ // ---------------------------------------------------------------------------
16
+ // Pure check functions (exported for testing)
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Check that Node.js >= 20 is running.
20
+ */
21
+ export function checkNodeVersion() {
22
+ const version = process.version; // e.g. "v22.1.0"
23
+ const major = parseInt(version.slice(1).split(".")[0], 10);
24
+ const ok = major >= 20;
25
+ return {
26
+ name: "Node.js version",
27
+ ok,
28
+ detail: `${version} (required: >= 20)`,
29
+ fix: ok ? undefined : `Upgrade Node.js to v20 or later: https://nodejs.org`,
30
+ };
31
+ }
32
+ /**
33
+ * Check that the provider binary is available in PATH (codex-cli and ollama only).
34
+ * Returns ok:true immediately for providers that don't need a binary.
35
+ */
36
+ export function checkProviderBinary(provider, codexPath = "codex") {
37
+ if (provider === "codex-cli") {
38
+ const result = spawnSync(codexPath, ["--version"], { stdio: "pipe" });
39
+ const ok = !result.error && result.status === 0;
40
+ return {
41
+ name: "codex CLI",
42
+ ok,
43
+ detail: ok ? `found (${codexPath})` : "not found in PATH",
44
+ fix: ok ? undefined : "npm install -g @openai/codex",
45
+ };
46
+ }
47
+ if (provider === "ollama") {
48
+ const result = spawnSync("ollama", ["list"], { stdio: "pipe" });
49
+ const ok = !result.error && result.status === 0;
50
+ return {
51
+ name: "ollama",
52
+ ok,
53
+ detail: ok ? "found" : "not found in PATH",
54
+ fix: ok
55
+ ? undefined
56
+ : "Install from https://ollama.com then run: ollama serve",
57
+ };
58
+ }
59
+ // Other providers need no binary
60
+ return { name: "provider binary", ok: true, detail: "N/A" };
61
+ }
62
+ /**
63
+ * Check authentication / API key availability for the configured provider.
64
+ */
65
+ export function checkAuth(provider, config = {}) {
66
+ switch (provider) {
67
+ case "codex-cli": {
68
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
69
+ const codexDir = join(home, ".codex");
70
+ const ok = existsSync(codexDir);
71
+ return {
72
+ name: "codex authentication",
73
+ ok,
74
+ detail: ok ? `~/.codex/ found` : "~/.codex/ not found",
75
+ fix: ok ? undefined : "Run: codex auth",
76
+ };
77
+ }
78
+ case "openai-api": {
79
+ const key = config.apiKey ?? process.env.OPENAI_API_KEY;
80
+ const ok = Boolean(key);
81
+ return {
82
+ name: "OpenAI API key",
83
+ ok,
84
+ detail: ok ? "set" : "missing",
85
+ fix: ok ? undefined : "Set OPENAI_API_KEY or run phase2s init",
86
+ };
87
+ }
88
+ case "anthropic": {
89
+ const key = config.anthropicApiKey ?? process.env.ANTHROPIC_API_KEY;
90
+ const ok = Boolean(key);
91
+ return {
92
+ name: "Anthropic API key",
93
+ ok,
94
+ detail: ok ? "set" : "missing",
95
+ fix: ok ? undefined : "Set ANTHROPIC_API_KEY or run phase2s init",
96
+ };
97
+ }
98
+ case "openrouter": {
99
+ const key = config.openrouterApiKey ?? process.env.OPENROUTER_API_KEY;
100
+ const ok = Boolean(key);
101
+ return {
102
+ name: "OpenRouter API key",
103
+ ok,
104
+ detail: ok ? "set" : "missing",
105
+ fix: ok ? undefined : "Set OPENROUTER_API_KEY or run phase2s init",
106
+ };
107
+ }
108
+ case "gemini": {
109
+ const key = config.geminiApiKey ?? process.env.GEMINI_API_KEY;
110
+ const present = Boolean(key);
111
+ const validPrefix = !key || key.startsWith("AIza");
112
+ return {
113
+ name: "Gemini API key",
114
+ ok: present,
115
+ detail: !present
116
+ ? "missing"
117
+ : !validPrefix
118
+ ? "set (note: Gemini keys normally start with AIza — verify key is correct)"
119
+ : "set",
120
+ fix: !present
121
+ ? "Set GEMINI_API_KEY or run phase2s init. Get a free key at https://aistudio.google.com/apikey"
122
+ : !validPrefix
123
+ ? "Verify you are using a Gemini API key from https://aistudio.google.com/apikey"
124
+ : undefined,
125
+ };
126
+ }
127
+ case "ollama":
128
+ return { name: "auth", ok: true, detail: "N/A (no auth required)" };
129
+ default:
130
+ return { name: "auth", ok: true, detail: "unknown provider" };
131
+ }
132
+ }
133
+ /**
134
+ * Check that .phase2s.yaml exists and contains a valid provider value.
135
+ * Returns ok:true if the file is absent (config is optional).
136
+ */
137
+ export function checkConfigFile(configPath) {
138
+ if (!existsSync(configPath)) {
139
+ return {
140
+ name: ".phase2s.yaml",
141
+ ok: true,
142
+ detail: "not present (using defaults — run phase2s init to create one)",
143
+ };
144
+ }
145
+ try {
146
+ const raw = readFileSync(configPath, "utf8");
147
+ const parsed = parseYaml(raw);
148
+ const provider = parsed?.provider;
149
+ const knownProviders = ["codex-cli", "openai-api", "anthropic", "ollama", "openrouter", "gemini"];
150
+ if (provider && !knownProviders.includes(provider)) {
151
+ return {
152
+ name: ".phase2s.yaml",
153
+ ok: false,
154
+ detail: `unknown provider: ${provider}`,
155
+ fix: `Valid providers: ${knownProviders.join(", ")}`,
156
+ };
157
+ }
158
+ const providerStr = provider ? `provider: ${provider}` : "no provider set (using default)";
159
+ return { name: ".phase2s.yaml", ok: true, detail: providerStr };
160
+ }
161
+ catch {
162
+ return {
163
+ name: ".phase2s.yaml",
164
+ ok: false,
165
+ detail: "could not be parsed",
166
+ fix: "Run phase2s init to regenerate it, or check for YAML syntax errors",
167
+ };
168
+ }
169
+ }
170
+ /**
171
+ * Check that the .phase2s/ working directory is writable (or can be created).
172
+ */
173
+ export function checkWorkDir(dirPath) {
174
+ try {
175
+ if (!existsSync(dirPath)) {
176
+ mkdirSync(dirPath, { recursive: true });
177
+ }
178
+ accessSync(dirPath, constants.W_OK);
179
+ return { name: ".phase2s/", ok: true, detail: "writable" };
180
+ }
181
+ catch {
182
+ return {
183
+ name: ".phase2s/",
184
+ ok: false,
185
+ detail: "not writable",
186
+ fix: `Check permissions on ${dirPath}`,
187
+ };
188
+ }
189
+ }
190
+ // ---------------------------------------------------------------------------
191
+ // runDoctor — entry point
192
+ // ---------------------------------------------------------------------------
193
+ export async function runDoctor() {
194
+ console.log(chalk.bold("\n Phase2S doctor\n"));
195
+ // Load existing config to inform checks (best-effort — errors are surfaced by checkConfigFile)
196
+ const configPath = resolve(".phase2s.yaml");
197
+ let existingConfig = {};
198
+ let provider = "codex-cli";
199
+ try {
200
+ if (existsSync(configPath)) {
201
+ const raw = readFileSync(configPath, "utf8");
202
+ const parsed = parseYaml(raw);
203
+ if (parsed && typeof parsed === "object") {
204
+ existingConfig = parsed;
205
+ provider = parsed.provider ?? "codex-cli";
206
+ }
207
+ }
208
+ }
209
+ catch {
210
+ // checkConfigFile will report this; we continue with defaults
211
+ }
212
+ const checks = [
213
+ checkNodeVersion(),
214
+ checkProviderBinary(provider, existingConfig.codexPath ?? "codex"),
215
+ checkAuth(provider, existingConfig),
216
+ checkConfigFile(configPath),
217
+ checkWorkDir(resolve(".phase2s")),
218
+ ];
219
+ // Filter out N/A checks (provider binary for non-binary providers)
220
+ const relevant = checks.filter((c) => c.detail !== "N/A");
221
+ let failCount = 0;
222
+ for (const check of relevant) {
223
+ if (check.ok) {
224
+ console.log(chalk.green(` ✓ ${check.name}`) + chalk.dim(` ${check.detail}`));
225
+ }
226
+ else {
227
+ failCount++;
228
+ console.log(chalk.red(` ✗ ${check.name}`) + chalk.dim(` ${check.detail}`));
229
+ if (check.fix) {
230
+ console.log(chalk.dim(` ${check.fix}`));
231
+ }
232
+ }
233
+ }
234
+ console.log("");
235
+ if (failCount === 0) {
236
+ console.log(chalk.green(" All checks passed. Phase2S is ready."));
237
+ }
238
+ else {
239
+ const plural = failCount === 1 ? "issue" : "issues";
240
+ console.log(chalk.yellow(` ${failCount} ${plural} found. Run phase2s init to reconfigure.`));
241
+ }
242
+ console.log("");
243
+ }
244
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAcvC,8EAA8E;AAC9E,8CAA8C;AAC9C,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,MAAM,EAAE,GAAG,KAAK,IAAI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AAC,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,SAAS,IAAI,MAAM,0CAA0C,CAAC,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
@@ -6,19 +6,56 @@
6
6
  * output, retries failed sub-tasks with failure context, and loops until all
7
7
  * criteria pass or max attempts are exhausted.
8
8
  *
9
- * Usage: phase2s goal <spec-file> [--max-attempts <n>]
9
+ * Usage: phase2s goal <spec-file> [--max-attempts <n>] [--resume] [--review-before-run]
10
+ *
11
+ * With --resume: reads existing state from .phase2s/state/<hash>.json
12
+ * (relative to the spec file directory), skips completed sub-tasks, and
13
+ * injects saved failure context for failed ones. Starts fresh if no state
14
+ * exists.
15
+ *
16
+ * With --review-before-run: runs the spec through adversarial review (fresh
17
+ * Agent instance, adversarial SKILL.md template) before execution begins.
18
+ * Halts and returns challenged: true if verdict is CHALLENGED or
19
+ * NEEDS_CLARIFICATION.
10
20
  */
11
21
  import { Agent } from "../core/agent.js";
12
22
  import { type Spec, type SubTask } from "../core/spec-parser.js";
23
+ import { type NotifyOptions } from "../core/notify.js";
13
24
  export interface GoalOptions {
14
25
  maxAttempts?: string;
26
+ resume?: boolean;
27
+ reviewBeforeRun?: boolean;
28
+ /**
29
+ * If true, use notification config from loadConfig().
30
+ * If a NotifyOptions object, override with those settings.
31
+ * Notification is sent after the run completes (success, failure, or challenge).
32
+ */
33
+ notify?: boolean | NotifyOptions;
15
34
  }
16
35
  export interface GoalResult {
17
36
  success: boolean;
18
37
  attempts: number;
19
38
  criteriaResults: Record<string, boolean>;
39
+ /** Absolute path to the structured JSONL run log. */
40
+ runLogPath: string;
41
+ /** One-liner summary for MCP response text. */
42
+ summary: string;
43
+ /** Total wall-clock duration of the run in milliseconds. */
44
+ durationMs: number;
45
+ /** true if pre-execution adversarial review halted the run. */
46
+ challenged?: boolean;
47
+ /** Full adversarial review text when challenged is true. */
48
+ challengeResponse?: string;
20
49
  }
21
50
  export declare function runGoal(specFile: string, options?: GoalOptions): Promise<GoalResult>;
51
+ /**
52
+ * Build a pre-execution adversarial review prompt.
53
+ *
54
+ * Injects the spec's decomposition and acceptance criteria as the "plan" to
55
+ * challenge, then appends the adversarial SKILL.md template which instructs
56
+ * the model to review what came before it and emit a structured verdict.
57
+ */
58
+ export declare function buildAdversarialPrompt(spec: Spec, adversarialTemplate: string): string;
22
59
  export declare function buildSatoriContext(subtask: SubTask, constraints: Spec["constraints"], failureContext?: string): string;
23
60
  export declare function checkCriteria(criteria: string[], evalOutput: string, agent: Agent): Promise<Record<string, boolean>>;
24
61
  export declare function analyzeFailures(failing: string[], evalOutput: string, spec: Spec, agent: Agent): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/cli/goal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAa,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAI5E,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;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