@justethales/cockpit 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.
@@ -0,0 +1,55 @@
1
+ # What I'm doing NOW
2
+
3
+ > **Updated** : {{TODAY}} (initial scaffold — replace at session close).
4
+ >
5
+ > **Read this first.** The single most important cockpit file. "Where am I?" has a one-screen answer here.
6
+
7
+ ---
8
+
9
+ ## Current focus (1 sentence)
10
+
11
+ **TODO** — describe what just shipped in one rich paragraph. Use bold sparingly to highlight the most important state. Future-you should be able to read this paragraph and reconstruct the project's working state without reading any other file.
12
+
13
+ ---
14
+
15
+ ## Concrete next action if I have…
16
+
17
+ ### 15 minutes
18
+
19
+ TODO — the smallest-possible step that moves the next slice forward. Often a smoke test, a manual `curl`, or a single file edit. Should be doable without context switching.
20
+
21
+ ### 1 hour
22
+
23
+ TODO — the next coherent unit of work. Should produce a commit-worthy diff. Usually maps to one section of the active session prompt.
24
+
25
+ ### Half a day
26
+
27
+ TODO — the realistic completion target for the next session. Should produce a shippable artifact (commit + push + session log + cockpit bump).
28
+
29
+ ---
30
+
31
+ ## Don't get distracted by
32
+
33
+ These items are NOT on the Next-3 (still or newly) :
34
+
35
+ - **TODO — item 1**, why it's deferred (when to revisit).
36
+ - **TODO — item 2**, why it's deferred.
37
+ - **TODO — item 3**, why it's deferred.
38
+
39
+ ---
40
+
41
+ ## Constraints active today
42
+
43
+ - TODO — date-bound constraints (launch deadlines, freezes, SLAs).
44
+ - TODO — environment constraints (envs missing, pending deploys).
45
+ - TODO — discipline constraints (rules that apply across all sessions).
46
+ - TODO — `npx cockpit check` is mandatory before push when the cockpit was bumped.
47
+
48
+ ---
49
+
50
+ ## How to use this file
51
+
52
+ - **Start of session** : `npx cockpit status` reads this + state.json + the next-prompt preview + last 10 commits in one command.
53
+ - **End of session** : overwrite the three blocks (focus, next-actions-by-budget, don't-get-distracted). No paragraphs, no narrative — mirror the shape of this file.
54
+ - **Before push** : `npx cockpit check` exits 0. If FAIL, fix inline.
55
+ - **When "don't get distracted" feels limiting** : that's the point. If you need to break it, justify in `roadmap.md` first.
@@ -0,0 +1,64 @@
1
+ # Roadmap
2
+
3
+ > **Updated** : {{TODAY}} (initial scaffold — replace at session close).
4
+ > **Source of truth** : this file + `docs/plan/sessions/*.md` (status frontmatter) + `session-logs/`.
5
+ > **Maintenance rule** : update at the end of every session that ships something or surfaces a blocker.
6
+
7
+ ---
8
+
9
+ ## Now — Next 3 to ship (in this order)
10
+
11
+ | # | Item | Prompt | Status |
12
+ |---|------|--------|--------|
13
+ | 1 | TODO — first slice (specific verb + outcome) | `docs/plan/sessions/PHASE-1-FIRST-SLICE.md` | queued |
14
+ | 2 | TODO — second slice | (prompt not yet drafted) | not drafted |
15
+ | 3 | TODO — third slice | (prompt not yet drafted) | not drafted |
16
+
17
+ If you reach for anything BELOW Next-3, stop and check why.
18
+
19
+ ---
20
+
21
+ ## In-flight (other agents working in parallel)
22
+
23
+ | Item | Owner | Expected close |
24
+ |------|-------|----------------|
25
+ | _(none)_ | _(none)_ | _(none)_ |
26
+
27
+ ---
28
+
29
+ ## Blocked
30
+
31
+ | Item | Blocker | Unblock action |
32
+ |------|---------|----------------|
33
+ | _(none)_ | _(none)_ | _(none)_ |
34
+
35
+ ---
36
+
37
+ ## Queued — launch-critical (do before public launch)
38
+
39
+ 1. TODO — item with one-line rationale.
40
+ 2. TODO — item with one-line rationale.
41
+
42
+ ---
43
+
44
+ ## Queued — non-critical (post-launch deferable)
45
+
46
+ - TODO — item.
47
+ - TODO — item.
48
+
49
+ ---
50
+
51
+ ## Shipped this week
52
+
53
+ | Date | Commit | Title | Notes |
54
+ |------|--------|-------|-------|
55
+ | _(none yet)_ | — | — | — |
56
+
57
+ ---
58
+
59
+ ## Phase scoreboard
60
+
61
+ | Phase | Status | Session log | Notes |
62
+ |-------|--------|-------------|-------|
63
+ | Phase 0 — Init | shipped | — | Cockpit scaffolded |
64
+ | Phase 1 — First slice | queued | _(pending)_ | First real piece of work |
@@ -0,0 +1,14 @@
1
+ {
2
+ "updated_at": "{{TODAY}}",
3
+ "last_session_id": "pending",
4
+ "last_commit": "pending",
5
+ "current_phase": "phase-0-init",
6
+ "next_phase": "phase-1-first-slice",
7
+ "next_prompt": "docs/plan/sessions/PHASE-1-FIRST-SLICE.md",
8
+ "phases_shipped": [],
9
+ "phases_queued": ["phase-1-first-slice"],
10
+ "phases_backlog": [],
11
+ "migrations_applied": [],
12
+ "migrations_dir": "drizzle",
13
+ "notes": "Bump every section at session close. Replace last_session_id + last_commit + current_phase + next_phase + next_prompt as appropriate. Run `npx cockpit check` before push."
14
+ }
@@ -0,0 +1,107 @@
1
+ # Audit brief — canonical Explore sub-agent template
2
+
3
+ > Use this template to spawn the post-implementation audit agent. Copy the body below into the `prompt` parameter of an `Agent` call with `subagent_type: "Explore"`. Fill the `<...>` placeholders with the session's actual surface.
4
+ >
5
+ > Why this template exists : generic "review this" prompts produce generic feedback. The structured `Context / Files / Checklist / Output` shape forces the audit to be specific to THIS session's risk class.
6
+
7
+ ---
8
+
9
+ You are a senior reviewer auditing a freshly-written `<one-line description of the surface — multi-tenancy on a new entity / schema migration / auth path / billing flow>` for `<project name>` at `<absolute project root>`. Read-only. Do NOT edit. Produce a structured verdict + per-item PASS/WARN/FAIL with `file:line` refs + a "Top 5 to fix" list + a "deferred / nice-to-haves" list.
10
+
11
+ ## Context
12
+
13
+ This session shipped `<one paragraph — what landed, what's intentionally out-of-scope, the parent prompt path>`.
14
+
15
+ Parent prompt with the spec : `<docs/plan/sessions/<id>.md>`. Read it first — it states the rules the new files must obey.
16
+
17
+ ## Files to audit (read whole file, not excerpts)
18
+
19
+ 1. **`<path>`** (NEW | MODIFIED) — one-line summary of what each verb does.
20
+ 2. **`<path>`** (NEW | MODIFIED) — same shape.
21
+
22
+ For context (read once for shape) :
23
+ - `<schema block>` — the new tables / columns.
24
+ - `<helper>` — the signature that must not drift.
25
+ - `<auth / hooks>` — the gate behavior the new routes inherit.
26
+ - `<closest analogue>` — what shape the new files should mirror.
27
+
28
+ ## Audit checklist
29
+
30
+ For each item, write PASS / WARN / FAIL + `file:line` + one-sentence justification. The checklist below is the canonical baseline — REMOVE sections that don't apply, ADD sections specific to the session's risk class (race conditions, SQL parser corner cases, TTL semantics, reverse-proxy assumptions, idempotency, header trust, S3 / DB orphan risks, MIME / extension validation, fire-and-forget task safety, error response contracts, i18n parity, dead code, doc/spec conformance).
31
+
32
+ ### A. Multi-tenancy (if the session touched a per-user entity)
33
+
34
+ 1. Every read query filters `WHERE userId = locals.user.id` or its equivalent.
35
+ 2. **404-not-403 leak protection on cross-user fetch.** Cross-user response is byte-identical to a truly-nonexistent row.
36
+ 3. **404-not-403 on write surfaces.** Non-owner PATCH / DELETE returns 404, not 403.
37
+ 4. Shared rows do not appear in the per-user list.
38
+
39
+ ### B. Input validation
40
+
41
+ 5. Every body schema ends with `.strict()` (or equivalent). Unknown keys reject.
42
+ 6. PATCH requires at least one field. Empty body returns 400.
43
+ 7. String fields are capped to the schema column's size.
44
+ 8. Query params are whitelisted. Numeric params coerced + capped. Datetime params validated.
45
+
46
+ ### C. Audit log discipline
47
+
48
+ 9. No content body in any audit payload.
49
+ 10. No message body, no S3 URL, no prompt content in `payload_json`.
50
+ 11. PATCH audit includes which `fields` changed and the entity id — nothing else from the request.
51
+ 12. DELETE audit captures count metadata from a pre-delete COUNT.
52
+ 13. CREATE audit logs ids only — no payload content for freshly-empty rows.
53
+
54
+ ### D. Cascade / orphan behavior
55
+
56
+ 14. DELETE cascades via the FK (no manual child-row delete in the route).
57
+ 15. Pre-delete COUNT is correct (counts the rows about to be cascaded, not the rows AFTER delete).
58
+
59
+ ### E. Pagination cursor honesty
60
+
61
+ 16. `nextCursor` is `null` when the result fits in one page.
62
+ 17. Cursor is the sort-key of the LAST returned row.
63
+ 18. Select fetches `limit + 1` rows to detect overflow without an extra query.
64
+
65
+ ### F. Out-of-scope guards
66
+
67
+ 19. No LLM-client / SSE / streaming import unless the session is the streaming session.
68
+ 20. No writes to tables this session was not allowed to touch.
69
+ 21. No external-effect code (email send, payment charge, file upload) unless the session ships that integration.
70
+
71
+ ### G. Regression surface
72
+
73
+ 22. No existing files modified except the explicit surface this session shipped.
74
+ 23. Tests + build + typecheck green.
75
+ 24. `npx cockpit check` ran 0 FAIL.
76
+
77
+ ## Output format
78
+
79
+ ```
80
+ ## Verdict
81
+ <GO | GO-WITH-FIXES | NO-GO>
82
+
83
+ ## Detail
84
+ A1. <PASS|WARN|FAIL> file:line — justification
85
+ A2. ...
86
+ ...
87
+ G24. ...
88
+
89
+ ## Top 5 to fix
90
+ 1. <issue> — file:line — proposed fix
91
+ ...
92
+
93
+ ## Deferred / nice-to-haves
94
+ - ...
95
+ ```
96
+
97
+ Keep the report under 600 words. Skip generic boilerplate. If everything is PASS, the verdict is GO and the "Top 5" can be empty.
98
+
99
+ ---
100
+
101
+ ## Tips for the spawning session
102
+
103
+ - **Brief the agent as a senior reviewer, not a generic "review this."** The structure above IS the brief.
104
+ - **Spawn in foreground** when you need the verdict before pushing.
105
+ - **Apply findings inline.** Don't ship "GO-WITH-FIXES" and defer the fixes ; they ride the same commit family as the implementation.
106
+ - **Document deferred items in the session log** under `## Deferred / risks`.
107
+ - **Re-run tests + `npx cockpit check`** after fixes.
@@ -0,0 +1,86 @@
1
+ # YY-MM-DD-NNN — <Phase id> : <Concise title>
2
+
3
+ **Session prompt :** `docs/plan/sessions/<id>-<slug>.md`.
4
+ **Previous session end :** `<short-sha>` (one-line description of the last commit before this session).
5
+ **Delegation :** <Executed inline | Sub-agent <type> for X step>. Reason in one sentence.
6
+ **State at session start :** What the cockpit looked like, what was unblocked, why this slice was picked.
7
+
8
+ ## Scope shipped this session
9
+
10
+ Organized by the prompt's MUST / SHOULD list. Each surface gets its own subsection.
11
+
12
+ ### A — `<file>` (NEW | MODIFIED)
13
+
14
+ #### `<verb>` — <what it does>
15
+
16
+ - Input shape.
17
+ - Filter / scope clauses.
18
+ - Response shape.
19
+ - Audit / log keys (metadata-only — list what's IN and what's NEVER).
20
+
21
+ ### B — `<file>` (NEW | MODIFIED)
22
+
23
+ Same shape.
24
+
25
+ ## What did NOT ship this session — and why
26
+
27
+ Per the prompt's DEFER list :
28
+
29
+ - **<Sub-slice>** — lives in Section `<id>` next. Reason.
30
+
31
+ ## Files touched
32
+
33
+ | File | Change |
34
+ |------|--------|
35
+ | `<path>` | NEW / MODIFIED — one-line description. |
36
+ | `session-logs/YY-MM-DD-NNN-<slug>.md` | This log. |
37
+ | `docs/plan/sessions/<this-prompt>.md` | Frontmatter `status:` queued → shipped. |
38
+ | `cockpit/state.json` | `last_commit` + `last_session_id` + `current_phase` + `next_phase` + `next_prompt` + `phases_shipped` bumped. |
39
+ | `cockpit/now.md` | Focus + Next-action rewritten. |
40
+ | `cockpit/roadmap.md` | Next-3 row updated, "Shipped this week" appended. |
41
+
42
+ No deletions. No renames.
43
+
44
+ ## Verify
45
+
46
+ ### Inline
47
+
48
+ - Tests / build / typecheck green.
49
+ - `npx cockpit check` — 0 FAIL, `<N>` warnings.
50
+
51
+ ### Post-implementation audit (Explore sub-agent)
52
+
53
+ Verdict : **GO | GO-WITH-FIXES | NO-GO**.
54
+
55
+ Per-checklist results :
56
+
57
+ - **<Section>** — PASS / FAIL — one-line justification.
58
+ - …
59
+
60
+ ### Observed divergence (documented, no code change)
61
+
62
+ If the prompt's spec didn't match reality, document here with the "why no code change" reason.
63
+
64
+ ## Deferred / risks
65
+
66
+ - **<Risk 1>.** What's deferred, when it lands, what breaks if it never lands.
67
+
68
+ ## Scope decisions made this session
69
+
70
+ - **<Decision>.** What was picked, what the alternative would have cost.
71
+
72
+ ## Cockpit + housekeeping
73
+
74
+ - `cockpit/state.json` bumped — see "Files touched".
75
+ - `cockpit/now.md` rewritten — Focus = "<one-paragraph reality check>".
76
+ - `cockpit/roadmap.md` Next-3 + Phase scoreboard updated.
77
+ - `docs/plan/sessions/<this-prompt>.md` frontmatter flipped queued → shipped.
78
+ - `npx cockpit check` — green before push.
79
+
80
+ ## End-of-session
81
+
82
+ - Tests + build + typecheck ran inline. All green.
83
+ - `npx cockpit check` ran — 0 FAIL.
84
+ - Post-implementation audit ran (or skipped because <reason>) — verdict noted above.
85
+ - Next-session prompt drafted at `docs/plan/sessions/<next>.md`.
86
+ - Commit + `git push` next.
@@ -0,0 +1,121 @@
1
+ ---
2
+ status: queued
3
+ session_id: pending
4
+ session_log: pending
5
+ drafted_at: YYYY-MM-DD
6
+ next_after: <previous-session-id-or-prompt-slug>
7
+ parent_prompt: docs/plan/sessions/<parent>.md # delete this line if this is not a sub-slice
8
+ ---
9
+
10
+ # Session — <Phase id> : <Concise title>
11
+
12
+ > **Status : QUEUED.** Drafted at the close of session `<NNN>` (commit `<short-sha>`). One-paragraph "why now" — what just shipped, what stays queued, what unblocks first.
13
+ >
14
+ > **Goal.** One sentence — what a fresh agent ships if they execute this prompt cleanly.
15
+ >
16
+ > **Why now.** One sentence — what changes if this slice doesn't ship next.
17
+
18
+ **Project root.** `<absolute-path>`
19
+ **Branch.** `main` (single branch, push at end).
20
+ **Session log target.** `session-logs/YY-MM-DD-NNN-<slug>.md`.
21
+ **Expected size.** `<1 h | 2-3 h | half-day>`. `<No | X>` schema change. `<No | X>` migration. `<No | X>` UI mount.
22
+
23
+ ---
24
+
25
+ ## CONTEXT — what changed since the parent prompt was drafted
26
+
27
+ Three to six bullets, strict diff against the parent's assumptions, with commit refs.
28
+
29
+ - **<What shipped>** (session NNN, commit `<sha>`). One-sentence summary + the constraint it imposes on this session.
30
+ - **<Reusable surface>**. Where the analogue lives (file path) + what's safe to copy vs extend.
31
+ - **<Standing convention>** this session must honor.
32
+
33
+ ---
34
+
35
+ ## REFERENCE FILES (read these before writing)
36
+
37
+ Paths only, no excerpts.
38
+
39
+ 1. **`<closest analogue>`** — what shape to mirror.
40
+ 2. **`<schema block>`** — the table / module this session touches.
41
+ 3. **`<helper>`** — the signature that must not drift.
42
+ 4. **`<gate>`** — auth / hooks / middleware that wraps the new surface.
43
+
44
+ ---
45
+
46
+ ## SCOPE (must-have → should-have → defer)
47
+
48
+ ### MUST HAVE — ship these or don't push
49
+
50
+ 1. **`<file>`** — what it does, the verbs / fields / shape, the failure modes.
51
+ 2. **`<file>`** — same.
52
+ 3. **<Cross-cutting invariant>** — list explicitly so the audit checklist is ready.
53
+
54
+ ### SHOULD HAVE — same session if time permits
55
+
56
+ 4. **<extra surface / smoke target / helper extraction>** with a one-line rationale.
57
+
58
+ ### DEFER if time runs short
59
+
60
+ - **<Sub-slice>** — lives in Section `<id>`. Reason.
61
+
62
+ ---
63
+
64
+ ## BUILD (in this order)
65
+
66
+ 1. Read the reference files end-to-end first.
67
+ 2. **`<file>`** — write in the order above. Smoke manually.
68
+ 3. **`<file>`** — same.
69
+ 4. **`pnpm check`** + **`pnpm build`** (or the equivalent) inline. Both green.
70
+
71
+ ---
72
+
73
+ ## VERIFY
74
+
75
+ Concrete smoke checks — each one a verb + expected envelope.
76
+
77
+ - **<Invariant 1>.** `<concrete test>` → `<expected envelope>`.
78
+ - **<Invariant 2>.** Same shape.
79
+ - **<No regression>.** List the surfaces this session must not break.
80
+ - **`npx cockpit check`** 0 FAIL before push.
81
+
82
+ ---
83
+
84
+ ## DO NOT
85
+
86
+ Anti-patterns + scope creep guards.
87
+
88
+ - **Do not <anti-pattern>.** Reason.
89
+ - **Do not <scope creep>.** Reason — lives in `<id>`.
90
+ - **Do not skip <safety>.** Reason.
91
+
92
+ ---
93
+
94
+ ## AT END OF SESSION
95
+
96
+ 1. Tests / build / typecheck green.
97
+ 2. Migration applied (or N/A).
98
+ 3. `git add` only this session's files (no `-A`).
99
+ 4. Commit message :
100
+ ```
101
+ feat(<phase>): <one-line — what shipped>
102
+ ```
103
+ 5. **Post-implementation audit** (REQUIRED for : multi-tenancy on a new entity / schema / auth / billing / voice ; SKIP for pure UI / doc-only / trivial). Use `cockpit/templates/audit-brief.md`. Apply findings inline.
104
+ 6. Write **`session-logs/YY-MM-DD-NNN-<slug>.md`** : `npx cockpit new log --slug <slug>`, then fill.
105
+ 7. **Draft next session's prompt** : `npx cockpit new prompt --slug <next-slug>`, then fill.
106
+ 8. **`npx cockpit check`** — must exit 0 FAIL. Fix any drift inline.
107
+ 9. `git push`.
108
+
109
+ ---
110
+
111
+ ## EXPECTED OUTPUT
112
+
113
+ - **New files :** `<path>` + the next-session prompt.
114
+ - **Updated :** `<path>` + `cockpit/state.json` + `cockpit/now.md` + `cockpit/roadmap.md`.
115
+ - **Commit count :** `<N>`.
116
+ - **Migration count :** `<N>`.
117
+ - **Session log :** one written.
118
+
119
+ ---
120
+
121
+ *Self-contained. A fresh agent reads this prompt + the reference files + the closest analogue, ships every MUST first, the SHOULDs if time, defers the rest with explicit rationale, writes the log, drafts the next prompt, commits + pushes after `npx cockpit check` is green. No regression on prior phases.*