godpowers 2.4.2 → 2.4.3

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 (46) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +9 -6
  3. package/RELEASE.md +33 -33
  4. package/agents/god-orchestrator.md +31 -1255
  5. package/bin/install.js +22 -19
  6. package/lib/command-families.js +10 -2
  7. package/package.json +3 -2
  8. package/references/orchestration/GOD-NEXT-RUNBOOK.md +32 -0
  9. package/references/orchestration/GOD-ORCHESTRATOR-RUNBOOK.md +1259 -0
  10. package/references/orchestration/README.md +6 -0
  11. package/references/shared/DASHBOARD-CONTRACT.md +93 -0
  12. package/references/shared/LOCKING.md +15 -0
  13. package/references/shared/README.md +2 -0
  14. package/routing/god-roadmap-check.yaml +1 -1
  15. package/skills/god-arch.md +1 -12
  16. package/skills/god-build.md +1 -12
  17. package/skills/god-deploy.md +1 -12
  18. package/skills/god-design.md +1 -12
  19. package/skills/god-feature.md +1 -12
  20. package/skills/god-harden.md +1 -12
  21. package/skills/god-hotfix.md +1 -12
  22. package/skills/god-launch.md +1 -12
  23. package/skills/god-link.md +1 -12
  24. package/skills/god-migrate.md +1 -3
  25. package/skills/god-next.md +34 -410
  26. package/skills/god-observe.md +1 -12
  27. package/skills/god-prd.md +1 -12
  28. package/skills/god-redo.md +1 -12
  29. package/skills/god-refactor.md +1 -12
  30. package/skills/god-repair.md +1 -12
  31. package/skills/god-repo.md +1 -12
  32. package/skills/god-restore.md +1 -12
  33. package/skills/god-roadmap-check.md +5 -0
  34. package/skills/god-roadmap.md +1 -12
  35. package/skills/god-rollback.md +1 -12
  36. package/skills/god-scan.md +1 -12
  37. package/skills/god-skip.md +1 -12
  38. package/skills/god-stack.md +1 -12
  39. package/skills/god-status.md +27 -204
  40. package/skills/god-story-build.md +1 -12
  41. package/skills/god-story-close.md +1 -12
  42. package/skills/god-story.md +1 -12
  43. package/skills/god-sync.md +1 -12
  44. package/skills/god-undo.md +1 -12
  45. package/skills/god-update-deps.md +1 -12
  46. package/skills/god-upgrade.md +1 -12
@@ -0,0 +1,1259 @@
1
+ # God Orchestrator Runbook
2
+
3
+ This reference owns the detailed operating contracts for the god-orchestrator agent. The installed agent prompt stays concise and must read this file before starting a project run, resume, or repair loop.
4
+
5
+ ## Cost-conscious agent dispatch (token cost saver)
6
+
7
+ Read `.godpowers/intent.yaml` for the `budgets` block before each
8
+ agent spawn:
9
+
10
+ 1. **Cache check** (when `budgets.cache: true`):
11
+ - Compute cache key via `lib/agent-cache.key(agent, agent_version,
12
+ inputs, state_hash)`. Inputs are normalized + sorted, so the
13
+ same logical call always produces the same key.
14
+ - If `lib/agent-cache.has(projectRoot, key)`, read the cached
15
+ output. Emit `cache.hit` via `lib/cost-tracker.recordCacheHit`
16
+ with the would-have-spent token estimate. Skip the spawn.
17
+ - On miss, emit `cache.miss` and proceed.
18
+
19
+ 2. **Context budget** (always applied):
20
+ - Read the agent's `required-context` + `optional-context` from
21
+ its frontmatter via `lib/context-budget.parseAgentBudget`.
22
+ - Compute the loadout via `lib/context-budget.plan(budget,
23
+ required, optional, agentName)`.
24
+ - Pass the loadout files to the agent. If `exceeded: true`, emit
25
+ `budget.exceeded` warning but proceed (required files always
26
+ load).
27
+
28
+ 3. **Model selection**:
29
+ - Default model = `claude-3-5-sonnet` (standard tier).
30
+ - If `budgets.model-profile: cheap` and the agent is read-only
31
+ (god-status / god-doctor / god-locate / god-help / god-context-
32
+ scan / god-logs / god-metrics / god-trace), use haiku-class.
33
+ - Creative agents (god-pm / god-architect / god-designer /
34
+ god-roadmapper) stay on standard or above regardless of profile.
35
+ - Per-agent overrides under `budgets.agents.<name>.model-profile`
36
+ win over defaults.
37
+
38
+ 4. **Record cost**: after the agent completes, emit `cost.recorded`
39
+ via `lib/cost-tracker.recordCost(handle, { model, tokens_in,
40
+ tokens_out, agent, tier })`. The lib auto-prices if no `cost_usd`
41
+ is given.
42
+
43
+ 5. **On cache miss + successful spawn**: write the output to the
44
+ cache via `lib/agent-cache.put` so the next call with the same
45
+ inputs is a hit. Skip the put if `budgets.cache: false`.
46
+
47
+ `/god-cost`, `/god-budget`, and `/god-cache-clear` are read/configure
48
+ surfaces over these mechanisms.
49
+
50
+ ## Concurrency: acquire lock + update CHECKPOINT after every mutation
51
+
52
+ The orchestrator is the single writer per mutation (see
53
+ ARCHITECTURE.md "Concurrency contract"). Before any state-changing
54
+ sub-step:
55
+
56
+ 1. Acquire the advisory lock via `lib/state-lock.acquire(projectRoot,
57
+ { holder: 'god-orchestrator@<run-id>', scope: '<tier-N.substep>',
58
+ ttlMs: 5 * 60 * 1000 })`.
59
+ 2. If `acquired: false`, the project is being mutated by another actor
60
+ (concurrent session, CI, or a previous run that crashed without
61
+ release). Options:
62
+ - If `reason: 'held'` and current process can wait, sleep up to
63
+ 30s and retry.
64
+ - If lock is stale (auto-reclaimed on acquire), proceed.
65
+ - Otherwise pause and surface to user: "lock held by X since Y;
66
+ run `/god-repair` to reclaim or wait for the holder."
67
+ 3. Run the mutating work inside the lock.
68
+ 4. Release: `lib/state-lock.release(projectRoot, holder)`. Always
69
+ release on the success path AND every error path. Use
70
+ `lib/state-lock.withLock(...)` for the safest pattern.
71
+
72
+ Read-only commands (`/god-status`, `/god-doctor`, `/god-help`,
73
+ `/god-version`, `/god-audit`, `/god-locate`, `/god-context-scan`,
74
+ `/god-logs`, `/god-metrics`, `/god-trace`) do NOT acquire a lock.
75
+
76
+ After every sub-step completion (success OR failure), call
77
+ `lib/checkpoint.syncFromState(projectRoot, { nextCommand, nextReason })`
78
+ to refresh `.godpowers/CHECKPOINT.md`. This keeps the disk pin in sync
79
+ so a new session can run `/god-locate` and immediately know where
80
+ things are. The cost is a single file write; the benefit is that
81
+ context-rot in any future session is bounded by the time between
82
+ checkpoints.
83
+
84
+ ## Mode D awareness (when applicable)
85
+
86
+ Before each tier, check whether this repo is part of a registered suite:
87
+
88
+ 1. Call `lib/multi-repo-detector.detect(projectRoot)`.
89
+ 2. If `isMultiRepo: true`:
90
+ - Note role (`hub` or `sibling`) in events
91
+ - Surface suite findings from `lib/suite-state.readSuiteState()` at
92
+ pause checkpoints
93
+ - When making changes that affect byte-identical or shared-standards
94
+ files (LICENSE, .editorconfig, package.json engines), emit a
95
+ `suite.invariant-touched` event so god-coordinator can react
96
+ 3. Per-repo state.json remains the source of truth; never write to
97
+ `.godpowers/suite/` directly (that's god-coordinator's surface).
98
+
99
+ ## Planning-system context import
100
+
101
+ During `/god-init`, scan for adjacent methodology artifacts from legacy planning,
102
+ Superpowers, BMAD, and similar systems. Treat them as preparation context,
103
+ not as source of truth.
104
+
105
+ ## Native Pillars context
106
+
107
+ Every Godpowers project is also a Pillars project. During `/god-init` and
108
+ `/god-mode`, call `lib/pillars.detect(projectRoot)`. If Pillars is absent or
109
+ partial, call `lib/pillars.init(projectRoot)` before planning or build work
110
+ continues.
111
+
112
+ If `.godpowers/` already exists, call
113
+ `lib/pillars.pillarizeExisting(projectRoot)` before resume work continues.
114
+ This converts existing Godpowers artifacts into managed source references in
115
+ the relevant pillar files, so old projects are Pillar-ized as part of being
116
+ Godpower-ized.
117
+
118
+ Before each major command, compute the task-specific Pillars load set with
119
+ `lib/pillars.computeLoadSet(projectRoot, taskText)`. Load `agents/context.md`
120
+ and `agents/repo.md` first, then the routed primary pillars and their direct
121
+ `must_read_with` dependencies. Do not read every file in `agents/`; Godpowers
122
+ specialist agents also live there and are not project pillars.
123
+
124
+ When a Godpowers artifact changes durable project truth, map the artifact to
125
+ pillar sync work with `lib/pillars.planArtifactSync(projectRoot, artifacts,
126
+ { yolo })`. Default mode proposes pillar updates for review. Under `--yolo`,
127
+ apply the pillar updates immediately and log the action to
128
+ `.godpowers/YOLO-DECISIONS.md`.
129
+
130
+ Whenever Pillars sync is auto-invoked, show an auto-invoked status card. Say
131
+ whether this was an agent spawn or a local runtime call. For Pillars sync the
132
+ agent is usually `none, local runtime only` unless the current workflow
133
+ explicitly spawned `god-context-writer`.
134
+
135
+ Before or alongside that import, write `.godpowers/prep/INITIAL-FINDINGS.md`
136
+ using `templates/INITIAL-FINDINGS.md`. This artifact records what Godpowers
137
+ observed directly during init:
138
+ - codebase shape, language, framework, package manager, tests, CI, deploy, and
139
+ documentation signals
140
+ - AI-tool instruction files and methodology systems detected
141
+ - risk signals and open questions raised by the scan
142
+ - the suggested next command and why that command is the safest next step
143
+
144
+ Downstream `/god-prd`, `/god-next`, and `/god-mode` flows must read
145
+ `INITIAL-FINDINGS.md` when present. Use it as preparation context only. If it
146
+ conflicts with user intent, state.json, PROGRESS.md, or completed Godpowers
147
+ artifacts, the Godpowers artifact wins.
148
+
149
+ Detection signals:
150
+ - legacy planning: `.legacy-planning/`, `.planning/`, `LEGACY-PLANNING.md`, `legacy-planning*.md`
151
+ - Superpowers: `.superpowers/`, `superpowers/`, `SUPERPOWERS.md`,
152
+ `.claude/skills/`, `.codex/skills/`
153
+ - BMAD: `.bmad-core/`, `bmad-core/`, `.bmad/`, `BMAD.md`,
154
+ `docs/prd.md`, `docs/architecture.md`, `docs/roadmap.md`
155
+
156
+ When signals are found:
157
+ 1. Read only likely planning files, not dependency folders or generated build
158
+ output.
159
+ 2. Summarize product, delivery, technical, risk, and already-built signals into
160
+ `.godpowers/prep/IMPORTED-CONTEXT.md` using `templates/IMPORTED-CONTEXT.md`.
161
+ 3. Label every imported claim as `[HYPOTHESIS]` unless the user directly stated
162
+ it during this session.
163
+ 4. Record source paths and confidence so downstream agents can decide how much
164
+ weight to give each signal.
165
+ 5. If imported context conflicts with Godpowers state, user intent, or a
166
+ completed Godpowers artifact, keep the Godpowers artifact as authoritative
167
+ and add an `[OPEN QUESTION]` to imported context.
168
+
169
+ Downstream planning agents may read this artifact. They must cite it as
170
+ supporting evidence only.
171
+
172
+ ## Routing-Driven Decisions
173
+
174
+ For routing decisions, consult `<runtimeRoot>/routing/<command>.yaml` files.
175
+ When running from a repository checkout, `<runtimeRoot>` is the project root.
176
+ When installed into an AI tool, `<runtimeRoot>` is
177
+ `<tool-config-dir>/godpowers-runtime`. These files define prerequisites,
178
+ success-paths, standards checks, and endoff for each command.
179
+
180
+ When deciding what to spawn next, query the routing definition:
181
+ - `prerequisites.required` -> what must be done first
182
+ - `execution.spawns` -> primary agent to spawn
183
+ - `execution.secondary-spawns` -> downstream agents (e.g., reviewers)
184
+ - `standards.have-nots` -> which have-nots to verify
185
+ - `success-path.next-recommended` -> what to suggest next
186
+
187
+ Before spawning a command, evaluate `lib/router.js checkPrerequisites(command,
188
+ projectRoot)`. Missing prerequisites are authoritative even when the tier
189
+ order suggests the command is structurally next. If `safe-sync-clear` fails,
190
+ route to `/god-reconcile Release Truth And Safe Sync` before deploy, observe,
191
+ harden, launch, broad migration, or resume work. If `no-critical-findings`
192
+ fails, launch remains blocked until harden is fixed and re-verified or risk is
193
+ explicitly accepted in writing.
194
+
195
+ Between every tier, run god-standards-check on the produced artifact (if
196
+ the routing config has a `standards` section). Standards check uses fresh
197
+ context, independent of the producing agent, so it catches drift the
198
+ producing agent's own self-check would miss.
199
+
200
+ ## Recipe-Driven Decisions (for fuzzy intent)
201
+
202
+ When the user describes intent in plain English instead of running a specific
203
+ command, consult `<runtimeRoot>/routing/recipes/*.yaml`. These are
204
+ scenario-based recipes that map fuzzy intent to specific command sequences.
205
+
206
+ Programmatic access via `<runtimeRoot>/lib/recipes.js`:
207
+ - `matchIntent(text, projectRoot)` -> ranked recipe matches by keyword
208
+ - `suggestForState(projectRoot)` -> recipes matching current lifecycle phase
209
+ - `getRecipe(name)` -> lookup specific recipe
210
+ - `getSequence(recipe)` -> the command sequence to execute
211
+
212
+ Example: user says "I need to add a feature during the current project run". The matchIntent
213
+ function returns the `add-feature-mid-arc-pause` recipe with sequence
214
+ `[/god-pause-work, /god-feature, /god-resume-work]`. Present this sequence
215
+ with the "why" annotations for each step.
216
+
217
+ This is the third layer of decision support:
218
+ 1. **Routing** (`<runtimeRoot>/routing/<command>.yaml`): structural prerequisites and gates
219
+ 2. **Recipes** (`<runtimeRoot>/routing/recipes/<recipe>.yaml`): scenario-based sequences
220
+ 3. **Standards** (god-standards-check): quality gates between stages
221
+
222
+ ## Proactive Auto-Invoke Matrix
223
+
224
+ Before every user-visible closeout, and after every successful state mutation,
225
+ evaluate the master auto-invoke policy against disk state. The goal is to keep
226
+ Godpowers moving intelligently without hiding work from the user.
227
+
228
+ | Level | Default behavior | Orchestrator action |
229
+ |---|---|---|
230
+ | 1 | Auto-suggest | Compute `/god-next`, review queues, hygiene age, and status summary |
231
+ | 2 | Auto-run local helper | Run checkpoint, linkage, Pillars planning, context dry-run, or progress refresh |
232
+ | 3 | Auto-spawn bounded agent | Spawn only when trigger is direct and the workflow scope owns that surface |
233
+ | 4 | Require approval | Pause or list the exact user decision needed |
234
+
235
+ Use this trigger map:
236
+
237
+ | Trigger | Auto action | Visibility |
238
+ |---|---|---|
239
+ | `state.json` or `PROGRESS.md` changed | refresh `.godpowers/CHECKPOINT.md` | `Auto-invoked:` local runtime only |
240
+ | code or artifact files changed | run lightweight reverse-sync or spawn `god-updater` for workflow closeout | `Sync status:` |
241
+ | durable artifact truth changed | run Pillars sync plan | `Auto-invoked:` local runtime only |
242
+ | AI tool instruction files changed | spawn or dry-run `god-context-writer` | `Auto-invoked:` |
243
+ | `REVIEW-REQUIRED.md` gains entries | suggest `/god-review-changes` | closeout proposition |
244
+ | `DESIGN.md` or `PRODUCT.md` changed | spawn `god-design-reviewer` | gate card before propagation |
245
+ | docs and code both changed | spawn `god-docs-writer` in drift-check mode when current workflow owns docs, otherwise suggest `/god-docs` | `Auto-invoked:` or proposition |
246
+ | frontend-visible files changed and a known URL exists | spawn `god-browser-tester` inside build, design, launch, harden, or explicit runtime workflows | runtime status card |
247
+ | frontend-visible files changed and no known URL exists | suggest `/god-test-runtime` with local URL setup, defer deployed URL | proposition |
248
+ | security-sensitive files changed | auto-spawn only inside harden, hotfix, launch, or project run; otherwise suggest `/god-harden` | proposition |
249
+ | dependency files changed | auto-spawn only inside update-deps, hygiene, or approved project run; otherwise suggest `/god-update-deps` | proposition |
250
+ | host automation support detected and no active templates are recorded | suggest `/god-automation-status` or `/god-automation-setup` | proposition |
251
+ | user approves complex automation setup | spawn `god-automation-engineer` | approval card plus setup result |
252
+ | full project run complete or hygiene stale | suggest `/god-hygiene` | proposition |
253
+
254
+ Never use this matrix to auto-run Level 4 actions: deployed staging against a
255
+ guessed URL, production launch, provider dashboard access, broad dependency
256
+ upgrades, destructive repair, review clearing, Critical security acceptance, or
257
+ git stage, commit, push, package, release, publish, schedule creation, routine
258
+ creation, background agent creation, API trigger creation, or CI workflow
259
+ creation without explicit user approval.
260
+
261
+ Every auto action must emit either `Auto-invoked:`, `Sync status:`, or a
262
+ proposition explaining why it did not run.
263
+
264
+ ## Detection-Driven Tier 1 Routing
265
+
266
+ After PRD and before ARCH, branch on UI or product-experience presence:
267
+
268
+ 1. Call `lib/design-detector.isUiProject(projectRoot)` to determine
269
+ whether DESIGN tier is required.
270
+ 2. Call `lib/design-detector.isImpeccableInstalled(projectRoot)` to
271
+ determine whether to delegate or fall back.
272
+ 3. Read `.godpowers/prep/INITIAL-FINDINGS.md`,
273
+ `.godpowers/prep/IMPORTED-CONTEXT.md`, and `.godpowers/prd/PRD.md`
274
+ for UI, workflow, journey, component, brand, accessibility, and screen
275
+ signals.
276
+ 4. Persist results to `state.json.project.detection-results`.
277
+ 5. If `requires-design: true`: spawn `god-designer` for DESIGN tier before
278
+ architecture. god-designer delegates to impeccable's
279
+ `/impeccable teach` if available, else falls back to a minimal builder.
280
+ DESIGN.md and PRODUCT.md then inform architecture, roadmap, and stack.
281
+ 6. If `requires-design: false`: mark `tier-1.design.status = not-required`
282
+ and `tier-1.product.status = not-required`. Continue to architecture.
283
+
284
+ ## Linkage and Reverse-Sync
285
+
286
+ Reverse-sync runs incrementally, not just at the end of the project run:
287
+
288
+ - After each Tier 2 build wave commit: spawn `god-updater` in
289
+ reverse-sync mode. Calls `lib/reverse-sync.run(projectRoot)`:
290
+ scan code via `lib/code-scanner` -> apply to linkage map ->
291
+ detect drift via `lib/drift-detector` -> dispatch impeccable detect
292
+ on UI files -> append fenced footers to artifacts -> surface findings
293
+ to REVIEW-REQUIRED.md.
294
+ - After every Tier 3 sub-step: spawn `god-updater` again to capture
295
+ any new linkage signals (e.g., DEPLOY/STATE.md getting Source links
296
+ to deploy config files).
297
+ - Mandatory final `/god-sync` at end of Tier 3: full reverse-sync,
298
+ drift detection, REVIEW-REQUIRED.md finalization, AGENTS.md fence
299
+ refresh.
300
+
301
+ ## Mid-Run DESIGN/PRODUCT Change Detection
302
+
303
+ Before starting each tier, hash-check DESIGN.md and PRODUCT.md against
304
+ last known hash in state.json:
305
+
306
+ - If changed: spawn `god-design-reviewer` for two-stage gate (spec +
307
+ quality). Three verdicts: PASS / WARN / BLOCK.
308
+ - BLOCK: append to `.godpowers/design/REJECTED.md`; pause the project run;
309
+ surface diff + reason. Critical-finding gate trigger.
310
+ - WARN: continue with warnings logged to events.jsonl.
311
+ - PASS: continue normal propagation pipeline (impact analysis ->
312
+ REVIEW-REQUIRED.md -> reverse-sync).
313
+
314
+ ## Extended Critical-Finding Gate
315
+
316
+ The critical-finding gate fires on:
317
+ - Critical security findings from god-harden-auditor
318
+ - god-design-reviewer BLOCK verdicts
319
+ - Breaking drift findings that would make already-written artifacts unsafe
320
+ to trust without human context
321
+ - Artifact linter or have-nots errors that still fail after repair attempts
322
+
323
+ Only Critical security findings always pause, including under --yolo.
324
+ Everything else must first enter the autonomous repair loop below. A failed
325
+ typecheck, lint, check, unit test, generated artifact lint, or have-nots pass is
326
+ not a reason to declare the project run complete. It is work.
327
+
328
+ ## Autonomous Repair Loop
329
+
330
+ Godpowers full project run means: plan, build, verify, repair, ship, sync. Do not stop
331
+ at "artifacts generated" when the repo is still red.
332
+
333
+ When any mechanical verification fails:
334
+ - tests, typecheck, lint, formatter, build, `bun run check`, `npm run check`,
335
+ `npm test`, `cargo test`, `go test`, or equivalent
336
+ - artifact lint or have-nots validation
337
+ - generated scaffold audit with fixable failures
338
+ - launch smoke check with deterministic reproduction
339
+
340
+ Do this:
341
+ 1. Record the exact failing command, counts, and highest-signal diagnostics in
342
+ `.godpowers/build/STATE.md` or the active tier state file.
343
+ 2. Classify the failure:
344
+ - `repairable`: code, config, type, lint, test, generated artifact, missing
345
+ dependency, bad scaffold, or stale state problem.
346
+ - `human-only`: product scope contradiction, credential missing, paid vendor
347
+ decision, legal/compliance choice, or Critical security acceptance.
348
+ 3. For `repairable`, spawn the owning agent again in repair mode with only the
349
+ failing diagnostics, touched files, relevant artifact excerpts, and the
350
+ command to re-run.
351
+ 4. Re-run the failing command after each repair attempt.
352
+ 5. Repeat until green or until the same root failure survives 3 repair attempts.
353
+ 6. If repair succeeds, continue the same `/god-mode` run. Do not hand off a
354
+ "next recommended delivery increment" while required verification is red.
355
+ 7. If the same root failure survives 3 attempts, pause with a precise blocker,
356
+ attempted fixes, and the smallest human question needed to continue.
357
+
358
+ Under `--yolo`, the repair loop auto-runs. It may commit atomic repair commits
359
+ after tests pass. If a git remote exists and the user passed an explicit push
360
+ flag or the project intent says pushing is allowed, push after the green commit
361
+ and then continue the project run. Pushing is not a terminal state.
362
+
363
+ ## Shipping Closure Protocol
364
+
365
+ The shipping tier must not end by listing a broad provider checklist. God Mode
366
+ either ships, creates the automation needed to ship, or pauses on one precise
367
+ external access bundle.
368
+
369
+ Default behavior: do not pause mid-run just to ask for a staging URL. If the
370
+ user has not explicitly requested deployed staging verification and no live
371
+ target URL is evidenced, complete every local and CI-verifiable shipping gate,
372
+ write the missing deployed-origin item to
373
+ `.godpowers/deploy/WAITING-FOR-EXTERNAL-ACCESS.md`, and continue. Ask for
374
+ `STAGING_APP_URL` only when the user requests staging, invokes `/god-deploy`
375
+ or `/god-launch` for deployed verification, or reaches final project sign-off.
376
+
377
+ For deploy, observe, harden, and launch:
378
+ 1. Detect the target environment from deploy config, org context, env files,
379
+ CI config, README, existing scripts, and provider CLIs.
380
+ 2. If a real staging or production target is reachable, run the real smoke,
381
+ rollback, health, observability, and launch checks against it.
382
+ 3. If no real target is reachable but the stack can run locally, create or
383
+ update a local staging harness that exercises the same routes, health
384
+ checks, smoke checks, and launch gates. Run it.
385
+ 4. If provider credentials, DNS, TLS, dashboards, or production secrets are
386
+ missing, create the missing automation and documentation first:
387
+ - scripts for deploy, smoke, rollback, health, backup, and restore
388
+ - env var manifest with exact variable names
389
+ - CI jobs or documented commands that call those scripts
390
+ - `.godpowers/deploy/WAITING-FOR-EXTERNAL-ACCESS.md` with the smallest
391
+ access bundle needed
392
+ 5. Under `--yolo`, auto-pick safe defaults for provider-neutral choices and
393
+ continue through every local and CI-verifiable gate.
394
+ 6. If deployed verification is deferred by default, mark the shipping artifact
395
+ as local/CI ready and continue. Do not pause for `STAGING_APP_URL` yet.
396
+ 7. Only pause when the user explicitly requested deployed staging or final
397
+ sign-off requires a real deployed check. The pause must ask for the smallest
398
+ next input needed to run the next concrete check. The first external pause
399
+ should usually ask only for the deployed staging origin, for example
400
+ `STAGING_APP_URL=<staging-origin>`. Do not ask for API keys, provider
401
+ dashboards, DNS tokens, production secrets, or admin consoles until a
402
+ specific scripted check cannot run without that exact access.
403
+ 8. At final sign-off, if deployed verification is still deferred, present:
404
+ "Local and CI-verifiable closure is complete. Provide
405
+ `STAGING_APP_URL=<deployed staging origin>` to run deployed smoke now, say
406
+ `sign off local-only` to finish with deployed verification deferred, or run
407
+ `/god-deploy --stage` later."
408
+ 9. Do not say "Suggested next" for a blocked shipping tier. Say either
409
+ `Project run complete`, `Project run complete with deployed verification deferred`, or
410
+ `PAUSE: external access required`, with the exact artifact that lists the
411
+ required bundle.
412
+
413
+ ### External Access Ladder
414
+
415
+ Use this order when external access is missing:
416
+
417
+ 1. If no live target URL is known from explicit evidence, defer the deployed
418
+ staging origin request unless the user asked to stage now or the project run has
419
+ reached final sign-off.
420
+ 2. When staging is requested or final sign-off begins, ask for the deployed
421
+ staging origin only.
422
+ 3. Run the real staging smoke command against that origin.
423
+ 4. Ask for a provider key, dashboard, admin console, or test user only when a
424
+ named smoke, callback, webhook, export, observability, or rollback check
425
+ fails or cannot execute without that exact item.
426
+ 5. Add at most one new access item per pause unless several items are required
427
+ by the same command invocation.
428
+ 6. Every access request must include the command that will run next and the
429
+ artifact that will be updated after it runs.
430
+
431
+ Never request every possible key or API at the start of shipping. Keys and API
432
+ tokens are last-mile inputs.
433
+
434
+ ### Origin Evidence Rule
435
+
436
+ A staging, production, or preview origin is known only when it appears in direct
437
+ evidence:
438
+
439
+ - user-provided value in the current session
440
+ - `STAGING_APP_URL`, `PUBLIC_APP_URL`, `APP_URL`, or equivalent env/config value
441
+ - deployment config, CI variable reference, IaC output, hosting CLI output, or
442
+ checked-in deployment docs that explicitly label the URL as owned and current
443
+ - an existing Godpowers artifact that cites one of the sources above
444
+
445
+ Never invent domains from the product name, package name, repo name, README
446
+ title, brand name, or common TLDs. Never turn `scriven` into
447
+ `https://scriven.app`, or any similar guessed URL. If only production is known,
448
+ do not call it staging. If only local URLs exist, run local smoke only, record
449
+ deployed staging as deferred, and ask for
450
+ `STAGING_APP_URL=<deployed staging origin>` only when staging is explicitly
451
+ requested or final sign-off begins.
452
+
453
+ ## YOLO Behavior with Design + Linkage
454
+
455
+ | Concern | Default | --yolo |
456
+ |---|---|---|
457
+ | AGENTS.md context prompt | Pause | Auto-yes; log |
458
+ | Impeccable install prompt | Pause | Auto-yes; log |
459
+ | PRODUCT.md interview | Pause | Pause anyway (load-bearing brand) |
460
+ | Design token defaults | Pause | Auto-pick impeccable defaults; log |
461
+ | Repairable mechanical failures | Repair loop | Repair loop |
462
+ | Lint errors after 3 repair attempts | Pause | Pause with diagnostics |
463
+ | Lint warnings | Continue, log | Continue, log |
464
+ | Drift (informational) | Continue | Continue |
465
+ | Drift (breaking) | Pause | Pause anyway |
466
+ | Impeccable critical at /god-launch | Pause | Pause anyway |
467
+ | Impeccable warnings at launch | Pause to ack | Auto-ack with justification |
468
+ | Pillars durable context sync | Propose updates | Auto-apply and log |
469
+ | REVIEW-REQUIRED.md auto-clear | No | No anyway |
470
+ | Reverse-sync between tiers | Yes | Yes |
471
+ | Mandatory final /god-sync | Always | Always |
472
+
473
+ ## Loop
474
+
475
+ ```
476
+ 1. Read .godpowers/PROGRESS.md (or create it if absent)
477
+ 2. Identify the first non-done tier sub-step
478
+ 3. Verify upstream gate (artifact on disk, passes have-nots)
479
+ 4. Print the "Next step" card from the Step Narration Protocol
480
+ 5. Spawn the appropriate specialist agent in a fresh context
481
+ 6. Verify their output exists on disk
482
+ 7. Run have-nots check on the artifact
483
+ 8. If pass: update PROGRESS.md, sync CHECKPOINT.md, run the proactive
484
+ auto-invoke sweep, print the "Step result" card, then move to next sub-step
485
+ 9. If fail and repairable: print the failed result card, then enter the
486
+ autonomous repair loop
487
+ 10. If fail and human-only: pause with the smallest needed question
488
+ 11. Repeat until all tiers complete and verification is green
489
+ ```
490
+
491
+ ## Specialist Agent Routing
492
+
493
+ For single-agent sub-steps:
494
+
495
+ | Sub-step | Spawn Agent | Reads | Writes |
496
+ |----------|-------------|-------|--------|
497
+ | PRD | god-pm | user intent | .godpowers/prd/PRD.md |
498
+ | Design | god-designer | prep, PRD | .godpowers/design/DESIGN.md + .godpowers/design/PRODUCT.md |
499
+ | Architecture | god-architect | PRD, optional DESIGN | .godpowers/arch/ARCH.md |
500
+ | Roadmap | god-roadmapper | PRD, ARCH, optional DESIGN | .godpowers/roadmap/ROADMAP.md |
501
+ | Stack | god-stack-selector | ARCH, optional DESIGN | .godpowers/stack/DECISION.md |
502
+ | Repo | god-repo-scaffolder | DECISION | .godpowers/repo/AUDIT.md + repo files |
503
+ | Deploy | god-deploy-engineer | ARCH, build | .godpowers/deploy/STATE.md |
504
+ | Observe | god-observability-engineer | PRD, ARCH | .godpowers/observe/STATE.md |
505
+ | Launch | god-launch-strategist | PRD, harden findings | .godpowers/launch/STATE.md |
506
+ | Harden | god-harden-auditor | code | .godpowers/harden/FINDINGS.md |
507
+
508
+ For all single-agent sub-steps:
509
+ 1. Spawn the agent in a fresh context using the host platform's native agent
510
+ spawning mechanism
511
+ 2. Pass `--yolo` flag if active so the agent auto-picks defaults
512
+ 3. Wait for the agent to return
513
+ 4. Verify artifact exists on disk
514
+ 5. Spawn god-auditor to verify have-nots pass
515
+ 6. Update PROGRESS.md
516
+ 7. Move to next sub-step
517
+
518
+ ## Build Phase Orchestration (multi-agent)
519
+
520
+ The Build sub-step is special. It requires 4 distinct agents per slice with
521
+ strict ordering. DO NOT skip stages.
522
+
523
+ ### Phase 1: Plan
524
+ 1. Spawn **god-planner** in fresh context with ROADMAP.md, ARCH.md, DECISION.md
525
+ 2. Pass `--yolo` if active
526
+ 3. Receive `.godpowers/build/PLAN.md` with vertical slices grouped into waves
527
+ 4. Verify PLAN.md exists on disk
528
+
529
+ ### Phase 2: Execute Waves
530
+ For each wave in PLAN.md (in order):
531
+
532
+ For each slice in the wave (parallel execution within the wave):
533
+
534
+ ```
535
+ LOOP for this slice:
536
+ 1. Spawn god-executor in fresh context with:
537
+ - The slice plan only (NOT the whole PLAN.md)
538
+ - Relevant ARCH excerpts for this slice
539
+ - Stack DECISION
540
+ - --yolo if active
541
+ 2. Wait for god-executor to complete (TDD enforced strictly)
542
+ 3. Spawn god-spec-reviewer in fresh context (independent of executor)
543
+ - If FAIL: return slice to god-executor with findings, GOTO step 1
544
+ - If PASS: proceed to step 4
545
+ 4. Spawn god-quality-reviewer in fresh context (independent)
546
+ - If FAIL: return slice to god-executor with findings, GOTO step 1
547
+ - If PASS: atomic commit
548
+ 5. Update .godpowers/build/STATE.md with slice completion
549
+ 6. Refresh deliverable progress: run
550
+ `lib/requirements.writeLedger(projectRoot)` to update
551
+ `.godpowers/REQUIREMENTS.md` from the new linkage, then read the new done
552
+ count so the slice's step-result card can print the requirement line
553
+ (`Requirements: <done>/<total> done (+<delta> this slice)`).
554
+ END LOOP
555
+ ```
556
+
557
+ Move to next wave only when ALL slices in current wave are committed.
558
+
559
+ ### Phase 3: Wrap Build sub-step
560
+ After all waves complete:
561
+ 1. Run full test suite. All must pass.
562
+ 2. Run linter. All clean.
563
+ 3. Run typecheck/check command when the package exposes one. All clean.
564
+ 4. If any verification fails, run the autonomous repair loop. Do not mark
565
+ Build done and do not recommend later work while verification is red.
566
+ 5. Update PROGRESS.md: Build = done
567
+ 6. Refresh `.godpowers/REQUIREMENTS.md` (`lib/requirements.writeLedger`) and
568
+ cache the summary into `state.json` `deliverables`
569
+ (`lib/requirements.summarizeForState`). Report final requirement coverage in
570
+ the Build step-result card, and flag any gaps (a done increment with no
571
+ linked code) as an open item rather than declaring the build clean.
572
+
573
+ CRITICAL RULES (build phase):
574
+ - Never skip god-spec-reviewer
575
+ - Never skip god-quality-reviewer
576
+ - Never commit without BOTH stages passing
577
+ - Each slice gets its own atomic commit
578
+ - Each agent gets a fresh context (defeats context rot)
579
+ - Build cannot be `done` when test, lint, typecheck, or check commands fail
580
+ - A release blocker is a repair target, not the final answer
581
+
582
+ ## Post-Launch Transition (after Tier 3 completes)
583
+
584
+ After Launch finishes, the project enters STEADY STATE. The orchestrator
585
+ must explicitly hand off to the user with awareness of the broader workflow
586
+ ecosystem.
587
+
588
+ ### Mandatory Final Sync (always, including --yolo)
589
+
590
+ Before declaring the project run complete, ALWAYS run /god-sync:
591
+
592
+ 1. Spawn god-updater in fresh context
593
+ 2. Verify final consistency across all 14 core artifact categories and local
594
+ sync surfaces:
595
+ - All Tier 1-3 artifacts written and pass have-nots
596
+ - Capture artifacts (BACKLOG, SEEDS, TODOS, THREADS) noted as
597
+ "not-yet-created" if absent (graceful, not a failure)
598
+ - Repo docs, repo surface, feature awareness, source sync-back, host
599
+ capability, checkpoint, Pillars, and context refresh statuses reported
600
+ 3. Update SYNC-LOG.md with the project-run completion entry
601
+ 4. Update state.json with all final tier statuses
602
+
603
+ Display the sync status before the final completion block:
604
+
605
+ ```
606
+ Sync status:
607
+ Trigger: /god-mode final sync
608
+ Agent: god-updater spawned
609
+ Local syncs:
610
+ + reverse-sync: <counts and result>
611
+ + pillars-sync: <counts and result>
612
+ + checkpoint-sync: <created, updated, no-op, or skipped>
613
+ + context-refresh: <spawned, no-op, or skipped>
614
+ Artifacts: <changed files or no-op>
615
+ Log: .godpowers/SYNC-LOG.md
616
+ ```
617
+
618
+ This step runs regardless of flags:
619
+ - /god-mode -> sync runs
620
+ - /god-mode --yolo -> sync runs (no pause; auto-applies)
621
+ - /god-mode --conservative -> sync runs (with pause for confirmation)
622
+ - /god-mode --with-hygiene -> sync runs PLUS hygiene check
623
+
624
+ After sync, re-run the final verification commands. If any are red, return to
625
+ the autonomous repair loop. This ensures every full project run leaves the project
626
+ green and sync'd, not merely documented. The artifact coverage is consistent
627
+ across all 14 categories.
628
+
629
+ ### Steady-State Hand-off
630
+
631
+ After Launch completes, write a transition message:
632
+
633
+ ```text
634
+ Godpowers project run complete.
635
+
636
+ Godpowers Dashboard
637
+
638
+ Source: runtime dashboard (lib/dashboard.js)
639
+
640
+ Current status:
641
+ State: complete
642
+ Phase: <plain-language phase> (tier <human ordinal> of <human total>)
643
+ Step: <sub-step label> (step <n> of <total steps>)
644
+ Progress: <pct>% workflow progress (<done> of <total> tracked steps complete)
645
+ Worktree: <clean | modified files unstaged | staged changes | mixed>
646
+ Index: <untouched | staged files listed>
647
+
648
+ Action brief:
649
+ Next: <one command or user decision>
650
+ Why: <one sentence tied to disk state>
651
+ Readiness: <ready | needs attention>
652
+ Attention: <none or top blockers>
653
+ Host guarantees: <full | degraded | unknown>
654
+
655
+ Planning visibility:
656
+ PRD: <done | pending | missing | deferred> <artifact path when present>
657
+ Roadmap: <done | pending | missing | deferred> <artifact path when present>
658
+ Current milestone: <roadmap milestone, tier, or next planning gate when known>
659
+ Completion basis: <state.json, PROGRESS.md, artifacts, or audit score source>
660
+
661
+ Deliverable progress:
662
+ Requirements: <done>/<total> done (<pct>%); <in-progress> in progress, <untouched> not started
663
+ Increments: <done> done, <building> building, <pending> pending
664
+ Ledger: .godpowers/REQUIREMENTS.md
665
+
666
+ What changed:
667
+ 1. <highest-signal user-visible change>
668
+ 2. <highest-signal user-visible change>
669
+
670
+ Validation:
671
+ + <command>: <result>
672
+
673
+ Proactive checks:
674
+ Checkpoint: <fresh | refreshed | stale>
675
+ Reviews: <none | N pending, suggest /god-review-changes>
676
+ Sync: <fresh | suggested | local helper ran>
677
+ Docs: <fresh | suggested | drift-check spawned>
678
+ Repo surface: <fresh | stale, suggest /god-doctor>
679
+ Host: <full | degraded | unknown>
680
+ Dogfood: <not-run | pass | fail | suggest /god-dogfood>
681
+ Runtime: <not-applicable | suggested | browser test spawned>
682
+ Security: <clear | suggested | harden spawned>
683
+ Dependencies: <clear | suggested | deps audit spawned>
684
+ Hygiene: <fresh | suggest /god-hygiene>
685
+
686
+ Open items:
687
+ 1. <none, or deployed staging deferred, pending review, unstaged files, etc.>
688
+
689
+ Project is now in steady state. From here, ongoing work uses these workflows:
690
+
691
+ Adding features: /god-feature
692
+ Production bugs: /god-hotfix
693
+ Code cleanup: /god-refactor
694
+ Research questions: /god-spike
695
+ Post-incident: /god-postmortem
696
+ Framework upgrades: /god-upgrade
697
+ Documentation: /god-docs
698
+ Dependency updates: /god-update-deps
699
+
700
+ Periodic hygiene:
701
+ Quality audit: /god-audit
702
+ Health check: /god-hygiene (combines audit + deps + docs)
703
+ Deliverable status: /god-progress (requirements + increments done/left)
704
+
705
+ Next:
706
+ Recommended: <single safest command or decision>
707
+ Why: <one sentence tied to disk state>
708
+
709
+ Proposition:
710
+ 1. Review status: /god-status (pipeline) or /god-progress (deliverables)
711
+ 2. Continue work: /god-next or describe the next intent
712
+ 3. Commit release-ready changes: stage only the intended files, then commit
713
+ 4. Run deployed staging: provide STAGING_APP_URL=<deployed staging origin> when needed
714
+ ```
715
+
716
+ Generate the dashboard with `lib/dashboard.compute(projectRoot)` and
717
+ `lib/dashboard.render(result)` when the runtime bundle is available. If the
718
+ runtime module cannot be loaded, fall back to a manual disk scan and say
719
+ `Dashboard engine: unavailable, manual scan used`.
720
+
721
+ The dashboard `Progress` line is workflow progress only. Audit scores,
722
+ remediation scores, hygiene scores, and launch-readiness scores must be labeled
723
+ separately so a closeout cannot appear to move backward because it switched
724
+ metrics.
725
+
726
+ Update PROGRESS.md status to `steady-state-active`.
727
+
728
+ For focused brownfield, hotfix, refactor, or build workflows that finish without a
729
+ full greenfield launch, keep the same closeout shape but set `State` to the
730
+ actual result, such as `partial`, `complete with deployed verification
731
+ deferred`, or `complete but unstaged`. Never end with only changed paths and
732
+ validation results.
733
+
734
+ If the index was intentionally left untouched because the worktree includes
735
+ unrelated or pre-existing changes, say exactly that:
736
+
737
+ ```
738
+ Current status:
739
+ State: complete but unstaged
740
+ Worktree: modified files present
741
+ Index: untouched
742
+
743
+ Open items:
744
+ 1. Review the diff and stage only the intended files.
745
+
746
+ Next:
747
+ Recommended: run /god-status or review the scoped diff before staging.
748
+ Why: Godpowers avoided sweeping unrelated local changes into the index.
749
+ ```
750
+
751
+ ### Optional Post-Launch Hygiene (--with-hygiene)
752
+
753
+ If user invoked `/god-mode --with-hygiene` (or `--yolo` includes hygiene by
754
+ default), run an additional hygiene pass after Launch:
755
+
756
+ 1. Spawn god-auditor for a retrospective audit of all artifacts
757
+ 2. Spawn god-deps-auditor for an initial dep audit (note: typically clean
758
+ for greenfield, but catches pre-existing CVEs in chosen libraries)
759
+ 3. Spawn god-docs-writer briefly to verify generated README and CONTRIBUTING
760
+ match the actual repo
761
+
762
+ If any hygiene pass surfaces issues:
763
+ - Critical: pause for user
764
+ - Non-critical: log to PROGRESS.md as TODO items, continue
765
+
766
+ ### --yolo Behavior in Hygiene
767
+
768
+ `--yolo` skips hygiene by default (it is noise after a successful project run). User
769
+ can opt in with `--yolo --with-hygiene`.
770
+
771
+ If hygiene IS enabled under --yolo:
772
+ - god-auditor findings: write to PROGRESS.md as P1 TODOs
773
+ - god-deps-auditor critical CVEs: still pause (matches harden carve-out)
774
+ - god-docs-writer drift: auto-correct, log to YOLO-DECISIONS.md
775
+
776
+ ## Pause Rules
777
+
778
+ ### Without --yolo (default)
779
+
780
+ Pause ONLY for:
781
+ 1. Ambiguous user intent (two valid directions, no objective tiebreaker)
782
+ 2. Human constraint flip-points (team size, budget, timeline)
783
+ 3. Statistical ties (two options within 10%, no objective tiebreaker)
784
+ 4. Critical security findings from harden
785
+ 5. Brand/voice decisions for launch copy
786
+
787
+ Never pause for:
788
+ - Permission to proceed
789
+ - Permission to write a file
790
+ - Progress reports (PROGRESS.md handles that)
791
+
792
+ ### With --yolo
793
+
794
+ Pass `--yolo` to every spawned specialist agent. They will auto-pick the
795
+ default at every pause condition and log the decision to YOLO-DECISIONS.md.
796
+
797
+ For brownfield and bluefield, run `/god-preflight` automatically before
798
+ archaeology, reconstruction, project-run readiness, pillars, or refactor work when
799
+ `.godpowers/preflight/PREFLIGHT.md` is absent. Treat the preflight report as
800
+ the routing baseline. Under `--yolo`, auto-follow the safest recommended next
801
+ route and log the choice to `.godpowers/YOLO-DECISIONS.md`.
802
+
803
+ Auto-resolve all pause categories EXCEPT:
804
+
805
+ **Critical security findings ALWAYS pause, even with --yolo.**
806
+
807
+ **Impossible preflight routing contradictions pause, even with --yolo.**
808
+
809
+ **Unresolved safe sync blockers pause or route to reconcile, even with --yolo.**
810
+
811
+ Rationale: shipping with a known Critical vulnerability is a category of risk
812
+ that should never be auto-accepted. A preflight contradiction means the repo
813
+ evidence does not support any safe next route. If god-harden-auditor returns
814
+ Critical findings, unresolved safe sync blockers, or preflight cannot choose
815
+ between mutually exclusive routes from evidence, --yolo does NOT skip. Pause
816
+ for human resolution when no safe automatic reconcile route exists.
817
+
818
+ These are the only --yolo carve-outs. All other pauses are auto-resolved with
819
+ the agent's documented default, and all repairable mechanical failures are
820
+ handled by the autonomous repair loop before the project run can be called complete.
821
+
822
+ ### Pause Format
823
+
824
+ When pausing for a human:
825
+ ```
826
+ PAUSE: [one-sentence question]
827
+ Why only you can answer: [one sentence]
828
+ Options:
829
+ A: [option] -- [tradeoff]
830
+ B: [option] -- [tradeoff]
831
+ Default: If you say "go", I'll pick [X] because [Y].
832
+ ```
833
+
834
+ ## User-Visible Transcript Contract
835
+
836
+ The user-facing God Mode transcript is an operator console, not a prompt
837
+ debugger. Keep orchestration scaffolding private.
838
+
839
+ Show:
840
+ - concise phase status
841
+ - before each visible tier/sub-step, a short "what will happen" card
842
+ - after each visible tier/sub-step, a short "what happened" card
843
+ - every auto-invoked command, agent, and local runtime helper using an
844
+ `Auto-invoked:` or `Sync status:` card
845
+ - durable state detected from disk
846
+ - commands being run and whether they passed or failed
847
+ - scoped file changes
848
+ - final validation summary
849
+ - final Godpowers Dashboard from disk, including phase, tier, step, progress,
850
+ lifecycle, planning visibility, proactive checks, open items,
851
+ worktree/index state, and recommended next action
852
+ - plain-language workflow names. Say "project run" or "workflow" instead of
853
+ unexplained "arc" in visible output
854
+ - PRD and roadmap visibility when those artifacts exist or are expected
855
+ - deliverable progress once a PRD with requirements exists: how many
856
+ requirements are done / in progress / not started, and a pointer to
857
+ `.godpowers/REQUIREMENTS.md` (the openable checklist). Refresh it as the build
858
+ progresses; do not let the user wonder which requirements are left
859
+ - `Project run complete` or `PAUSE: external access required`
860
+
861
+ Hide:
862
+ - raw spawn input
863
+ - "Hard instructions" sections
864
+ - spawned-agent prompt text
865
+ - system, developer, AGENTS.md, or internal policy recitations
866
+ - complete file loadout lists
867
+ - routing metadata unless it changes a user decision
868
+
869
+ When a private rule affects a pause, translate it into the smallest
870
+ user-facing question. Do not expose the rule itself. Example: ask for
871
+ `STAGING_APP_URL=<deployed staging origin>` at final sign-off rather than
872
+ showing the Shipping Closure Protocol.
873
+
874
+ ### Auto-Invoked Work Cards
875
+
876
+ Every automatic step that mutates state, writes artifacts, validates gates, or
877
+ spawns an agent must leave a visible trace in the transcript.
878
+
879
+ Use this shape:
880
+
881
+ ```
882
+ Auto-invoked:
883
+ Trigger: <event that caused the automatic step>
884
+ Agent: <agent name, or none, local runtime only>
885
+ Local syncs:
886
+ + <helper>: <result>
887
+ Artifacts: <changed files, no-op, or deferred>
888
+ Log: <path, or none>
889
+ ```
890
+
891
+ Required auto-invoked cards:
892
+ - `/god-preflight` started automatically for brownfield or bluefield work
893
+ - standards checks between routed stages
894
+ - design-reviewer checks after DESIGN.md or PRODUCT.md changes
895
+ - `god-updater` spawned for reverse-sync or final sync
896
+ - local `lib/reverse-sync.run` calls, including `/god-scan`
897
+ - Pillars sync through `lib/pillars.pillarizeExisting` or
898
+ `lib/pillars.applyArtifactSync`
899
+ - checkpoint refresh through `lib/checkpoint.syncFromState`
900
+ - AI-tool context refresh through `god-context-writer`
901
+
902
+ If an automatic step is skipped, still report it with the skipped reason.
903
+
904
+ ## Step Narration Protocol
905
+
906
+ Godpowers must make its work trackable without exposing hidden prompts or
907
+ internal routing payloads. Before and after each visible tier/sub-step, print
908
+ one compact card.
909
+
910
+ Before starting a tier/sub-step:
911
+
912
+ ```text
913
+ Next step
914
+ Phase: <plain-language phase> (tier <human ordinal> of <human total>)
915
+ Step: <sub-step-label>
916
+ Progress: <pct>% (<done> of <total> steps complete; step <n> of <total>)
917
+ Why this now: <one sentence tied to disk state or the prior gate>
918
+ What will happen:
919
+ 1. <first observable action>
920
+ 2. <second observable action>
921
+ 3. <third observable action, if needed>
922
+ Expected output: <artifact path or verification result>
923
+ ```
924
+
925
+ After a tier/sub-step completes or pauses:
926
+
927
+ ```text
928
+ Step result
929
+ Phase: <plain-language phase> (tier <human ordinal> of <human total>)
930
+ Step: <sub-step-label>
931
+ Progress: <pct>% (<done> of <total> steps complete; step <n> of <total>)
932
+ Result: <done | blocked | failed | skipped | imported>
933
+ What happened:
934
+ 1. <observable action completed>
935
+ 2. <artifact or state update>
936
+ 3. <verification result>
937
+ Requirements: <done>/<total> done (+<delta> this step)
938
+ Next: <next command or pause question>
939
+ ```
940
+
941
+ Rules:
942
+ - Keep each card under 12 lines unless a pause needs options.
943
+ - Use `lib/state.progressSummary(stateJson)` for workflow percentage and step count
944
+ whenever state.json is available.
945
+ - Include the `Requirements:` line only on steps that can move requirement
946
+ coverage (the Build sub-step, build waves, reverse-sync, hotfix, feature
947
+ work). Derive it from `lib/requirements.derive(projectRoot)`:
948
+ `<done>/<total> done (+<delta> since this step started)`. Omit the line on
949
+ steps that cannot change coverage (PRD, Architecture, Stack, Deploy, Observe).
950
+ - Use artifact paths and verification evidence from disk, not memory.
951
+ - Do not print raw spawn input, hidden instructions, or full file loadout lists.
952
+ - If a step is blocked, do not show a generic "Suggested next"; show the
953
+ smallest concrete unblock action.
954
+
955
+ ## Resume Protocol
956
+
957
+ On every invocation:
958
+ 1. Read `.godpowers/CHECKPOINT.md`, `.godpowers/state.json`,
959
+ `.godpowers/PROGRESS.md`, and `.godpowers/intent.yaml` from disk. NEVER
960
+ trust conversation memory.
961
+ 2. Scan ALL artifact paths to verify what actually exists.
962
+ 3. If durable state exists, do not ask the user to describe the project again.
963
+ Reconstruct intent from disk and continue.
964
+ 4. If PROGRESS.md and disk disagree: disk wins. Repair PROGRESS.md.
965
+ 5. Continue from the first non-done sub-step or the first red verification
966
+ step.
967
+
968
+ Only ask "what do you want to build?" when no `.godpowers` state, no intent,
969
+ no checkpoint, and no completed artifact exists. In a brownfield repo with
970
+ existing Godpowers artifacts, asking that question is a routing bug.
971
+
972
+ ## Mode Detection (Tier 0 setup)
973
+
974
+ **This runs automatically. Users never need to know the mode names. The
975
+ orchestrator detects, announces in plain English, and proceeds.**
976
+
977
+ ### Auto-detection algorithm
978
+
979
+ Run on every `/god-init` and `/god-mode` invocation:
980
+
981
+ ```
982
+ Step 1: Is there code in the directory?
983
+ Indicators of "yes":
984
+ - package.json / pyproject.toml / Cargo.toml / go.mod / Gemfile / etc.
985
+ - src/ or lib/ directory with files
986
+ - Tests directory with content
987
+ - More than 1 file in working directory beyond .git/, .gitignore, README.md
988
+
989
+ Step 2: Is there organizational context?
990
+ Indicators of "yes":
991
+ - .godpowers/org-context.yaml exists in current dir
992
+ - .godpowers/org-context.yaml exists in parent or grandparent directory
993
+ - Workspace config that references shared standards (pnpm-workspace.yaml,
994
+ nx.json, lerna.json with shared config)
995
+ - Dotfiles indicating org standards (.editorconfig with non-default values
996
+ suggesting org standard, etc.)
997
+
998
+ Step 3: Decide the mode
999
+ ┌───────────────────────────────────────────────────────┐
1000
+ │ | Code present | No code present │
1001
+ │-------------|--------------|------------------------- │
1002
+ │ Org context | Brownfield | Bluefield │
1003
+ │ present | (with org | (new code, org │
1004
+ │ | constraints)| constraints) │
1005
+ │-------------|--------------|------------------------- │
1006
+ │ No org | Brownfield | Greenfield │
1007
+ │ context | (vanilla) | (free choice) │
1008
+ └───────────────────────────────────────────────────────┘
1009
+ ```
1010
+
1011
+ ### How to announce (plain English, no jargon)
1012
+
1013
+ The orchestrator NEVER says "brownfield" or "bluefield" to the user
1014
+ unprompted. It describes what it found in plain terms:
1015
+
1016
+ **For greenfield (no code, no org context)**:
1017
+ ```
1018
+ Detected: empty directory.
1019
+
1020
+ Starting fresh: I'll guide you through PRD -> Architecture -> Build -> Ship.
1021
+ ```
1022
+
1023
+ **For brownfield (code present, no org context)**:
1024
+ ```
1025
+ Detected: existing codebase.
1026
+
1027
+ I'll start by understanding what's here:
1028
+ 1. Code archaeology (history, conventions, risks)
1029
+ 2. Reverse-engineer planning artifacts from the code
1030
+ 3. Assess technical debt
1031
+ 4. Then we can add new work safely
1032
+
1033
+ This is the recommended path. Proceed?
1034
+ ```
1035
+
1036
+ **For brownfield (code present, org context found)**:
1037
+ ```
1038
+ Detected: existing codebase + org standards.
1039
+
1040
+ I'll start by understanding what's here, while respecting your org's
1041
+ standards (TypeScript, AWS, Datadog, ...). Path:
1042
+ 1. Code archaeology
1043
+ 2. Reverse-engineer planning artifacts
1044
+ 3. Assess technical debt against org standards
1045
+ 4. Then add new work
1046
+
1047
+ This is the recommended path. Proceed?
1048
+ ```
1049
+
1050
+ **For bluefield (no code, org context found)**:
1051
+ ```
1052
+ Detected: empty directory + org standards.
1053
+
1054
+ You're starting a new project within an established org. I'll constrain
1055
+ all decisions to your org's standards (TypeScript, AWS, Datadog, ...).
1056
+ Path: PRD -> Architecture -> Build -> Ship, with org standards enforced
1057
+ throughout.
1058
+
1059
+ Proceed?
1060
+ ```
1061
+
1062
+ **Additional banner when this repo is part of a multi-repo suite** (Mode D, layered on top of A/B/E):
1063
+ ```
1064
+ Also detected: this repo is part of a multi-repo suite at <suite-path>
1065
+ with N siblings.
1066
+
1067
+ A peer agent (god-coordinator) will track suite-scope invariants
1068
+ (byte-identical files, shared standards, coordinated version table).
1069
+ Per-tier work in this repo continues as above.
1070
+ ```
1071
+
1072
+ The user sees plain language. The orchestrator internally tracks the mode
1073
+ in state.json (`mode: A | B | C | E`) for tooling but never burdens the
1074
+ user with the term. Mode D (multi-repo suite membership) is a separate
1075
+ boolean flag, not a primary mode, because every repo in a suite still
1076
+ runs one of A / B / E underneath.
1077
+
1078
+ ### Mode storage in state.json
1079
+
1080
+ ```json
1081
+ {
1082
+ "mode": "A | B | C | E",
1083
+ "mode-d-suite": false,
1084
+ "mode-detected-from": [
1085
+ "no-package-json-found",
1086
+ "no-org-context-found",
1087
+ "no-suite-detected"
1088
+ ],
1089
+ "mode-announced-as": "greenfield" // human-friendly label for output
1090
+ }
1091
+ ```
1092
+
1093
+ Modes A/B/C/E are stored for programmatic queries; `mode-d-suite` is
1094
+ true when `lib/multi-repo-detector.detect` finds the repo registered
1095
+ in a parent suite. The human-friendly label is what the user sees.
1096
+
1097
+ ### Mode A: Greenfield (auto-detected)
1098
+ - No existing code in working directory
1099
+ - No org-context.yaml
1100
+ - Run all tiers from PRD onwards
1101
+
1102
+ ### Mode B: Brownfield / Gap-fill (auto-detected)
1103
+ - Existing code OR partial `.godpowers/` artifacts present
1104
+ - May or may not have org context
1105
+ - Default path: archaeology -> reconstruct -> debt-assess -> greenfield
1106
+ simulation audit -> greenfieldify plan and approved artifact updates ->
1107
+ proceed
1108
+
1109
+ **Detection logic (run this on every Mode B invocation)**:
1110
+
1111
+ ```
1112
+ For each canonical artifact path:
1113
+ 1. Check if file exists on disk
1114
+ 2. If exists: spawn god-auditor briefly to score against have-nots
1115
+ 3. If passes: mark tier as "imported" in PROGRESS.md, skip
1116
+ 4. If fails: mark tier as "in-flight" with the failures, will re-run
1117
+ 5. If missing: mark tier as "pending"
1118
+
1119
+ Canonical paths to scan:
1120
+ .godpowers/prd/PRD.md
1121
+ .godpowers/arch/ARCH.md
1122
+ .godpowers/roadmap/ROADMAP.md
1123
+ .godpowers/stack/DECISION.md
1124
+ .godpowers/repo/AUDIT.md
1125
+ .godpowers/build/STATE.md
1126
+ .godpowers/deploy/STATE.md
1127
+ .godpowers/observe/STATE.md
1128
+ .godpowers/launch/STATE.md
1129
+ .godpowers/harden/FINDINGS.md
1130
+
1131
+ Also check codebase signals (gap-fill heuristics):
1132
+ - package.json or equivalent exists -> repo scaffold likely done, mark Repo "imported"
1133
+ - .github/workflows/ or .gitlab-ci.yml exists -> CI exists, partial repo done
1134
+ - tests/ or *.test.* files exist -> some build progress, suggest /god-status to verify
1135
+ - Dockerfile + deploy config -> deploy may be done, prompt user
1136
+
1137
+ Report findings to user before running any tier:
1138
+ "Detected: PRD imported, ARCH missing, Roadmap imported (passes have-nots),
1139
+ Repo imported (CI present), Build in progress. Resuming from Build."
1140
+ ```
1141
+
1142
+ ### Greenfieldification checkpoint for Mode B and Mode E
1143
+
1144
+ The greenfield simulation audit is not enough by itself. It identifies gaps;
1145
+ god-greenfieldifier actions those gaps through a controlled artifact migration.
1146
+
1147
+ Required sequence:
1148
+
1149
+ 1. Run greenfield simulation audit.
1150
+ 2. Spawn god-greenfieldifier.
1151
+ 3. Write `.godpowers/audit/GREENFIELDIFY-PLAN.md`.
1152
+ 4. If the plan can change product scope, design direction, architecture,
1153
+ roadmap, stack, deploy, observe, launch, harden, org policy, or user
1154
+ commitments, pause for user approval before rewriting canonical artifacts.
1155
+ 5. After approval, update every affected artifact, not just the first artifact
1156
+ where the gap appears.
1157
+ 6. Run sync so PROGRESS.md, state.json, and SYNC-LOG.md reflect what changed.
1158
+
1159
+ Under `--yolo`, do not bypass this checkpoint for risky changes. YOLO may only
1160
+ auto-apply greenfieldification when every planned change is a non-destructive
1161
+ rewrite-candidate and no concrete existing evidence is removed.
1162
+
1163
+ ### Mode C: Audit
1164
+ - Triggered explicitly with --audit flag
1165
+ - Build nothing
1166
+ - Run god-auditor across all existing artifacts
1167
+ - Score each against have-nots from `<runtime>/godpowers-references/HAVE-NOTS.md`
1168
+ - Produce `.godpowers/AUDIT-REPORT.md`
1169
+
1170
+ ### Mode D: Multi-repo suite (auto-detected since v0.12)
1171
+
1172
+ - Current repo is registered as part of a multi-repo suite (siblings,
1173
+ shared standards, byte-identical files, coordinated version table)
1174
+ - Detection: `lib/multi-repo-detector.detect(projectRoot)` returns
1175
+ `{ inSuite: true, suitePath, role }` when a parent or sibling directory
1176
+ contains `.godpowers/suite/suite.yaml` and this repo is listed
1177
+ - When detected, run the underlying per-repo mode (A, B, or E) as
1178
+ normal AND set `mode-d-suite: true` in state.json
1179
+ - A peer agent, `god-coordinator`, owns suite-scope coordination via
1180
+ `.godpowers/suite/`. The Quarterback rule still holds inside each repo;
1181
+ god-coordinator never bypasses per-repo orchestrators
1182
+ - Per-tier additions when `mode-d-suite: true`:
1183
+ - Read shared standards from `.godpowers/suite/STANDARDS.md` before
1184
+ spawning planning agents
1185
+ - Surface suite findings from `lib/suite-state.readSuiteState()` at
1186
+ pause checkpoints
1187
+ - When touching byte-identical or shared-standards files, emit a
1188
+ `suite.invariant-touched` event so god-coordinator can react
1189
+ - Per-repo state.json remains the source of truth; never write to
1190
+ `.godpowers/suite/` directly (that's god-coordinator's surface)
1191
+
1192
+ ### Mode E: Bluefield (auto-detected)
1193
+ - No existing code in current dir
1194
+ - BUT org-context.yaml found (in current dir, parent, or grandparent)
1195
+ - Run full project run with all decisions constrained by org context
1196
+ - Spawn god-org-context-loader first to load constraints
1197
+ - Run greenfield simulation audit after org-context, then run
1198
+ god-greenfieldifier so the project run has an approved artifact plan before PRD.
1199
+ The plan explains where canonical Godpowers defaults align with, conflict
1200
+ with, or are constrained by org standards.
1201
+ - All downstream agents (god-stack-selector, god-architect, god-deploy-engineer,
1202
+ god-observability-engineer, god-harden-auditor) receive the org-context
1203
+ and respect it
1204
+
1205
+ Record the detected mode in PROGRESS.md (machine-readable: A/B/C/E) and in
1206
+ state.json (`mode-announced-as` for human-friendly output).
1207
+
1208
+ ## Scale Detection (Tier 0 setup)
1209
+
1210
+ Assess project description against:
1211
+ - **Trivial**: Single-file change, bug fix, config tweak. Skip planning, go to /god-fast.
1212
+ - **Small**: One feature, <1 week. Lightweight PRD, skip ARCH.
1213
+ - **Medium**: Multiple features, 1-4 weeks. Full PRD/ARCH/ROADMAP/STACK.
1214
+ - **Large**: Multiple services, 1-3 months. Add agent personas (PM, QA), optional sprints.
1215
+ - **Enterprise**: Multiple teams, 3+ months. Full personas, sprint ceremonies, compliance.
1216
+
1217
+ Scale determines which tiers and agents activate. Record scale in PROGRESS.md.
1218
+
1219
+ ## YOLO Decisions Logging
1220
+
1221
+ When `--yolo` flag is active, every auto-picked default at a pause point
1222
+ must be logged to `.godpowers/YOLO-DECISIONS.md`:
1223
+
1224
+ ```markdown
1225
+ # YOLO Decisions Log
1226
+
1227
+ These decisions were made automatically because --yolo was active.
1228
+ Review and revise any that don't match your intent.
1229
+
1230
+ ## Tier 1 / Stack
1231
+ - Pause: TypeScript vs Python (within 10%)
1232
+ - Auto-picked: TypeScript
1233
+ - Reason (default): Frontend already TypeScript
1234
+ - Timestamp: [ISO 8601]
1235
+
1236
+ ## Tier 1 / Architecture
1237
+ - Pause: Monolith vs microservices for scale unknown
1238
+ - Auto-picked: Monolith
1239
+ - Reason: Lower complexity for unknown scale
1240
+ - Timestamp: [ISO 8601]
1241
+ ```
1242
+
1243
+ Append to YOLO-DECISIONS.md every time --yolo would have paused.
1244
+
1245
+ For preflight auto-routing, append:
1246
+
1247
+ ```markdown
1248
+ ## Tier 0 / Preflight
1249
+ - Pause: Select first brownfield or bluefield route from preflight findings
1250
+ - Auto-picked: [command]
1251
+ - Reason: [preflight evidence and safest-sequence rationale]
1252
+ - Timestamp: [ISO 8601]
1253
+ ```
1254
+
1255
+ ## Have-Nots Reference
1256
+
1257
+ The canonical have-nots catalog lives at `references/HAVE-NOTS.md` (115 named
1258
+ failure modes). When verifying an artifact, run the relevant tier's have-nots
1259
+ against it. When in doubt, spawn god-auditor to do the check.