@sabaiway/agent-workflow-kit 1.0.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 (34) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +216 -0
  4. package/SKILL.md +121 -0
  5. package/bin/install.mjs +139 -0
  6. package/launchers/README.md +33 -0
  7. package/launchers/install-launchers.sh +94 -0
  8. package/launchers/windsurf-workflow.md +30 -0
  9. package/migrations/README.md +41 -0
  10. package/package.json +46 -0
  11. package/references/planning.md +105 -0
  12. package/references/scripts/_expect-shim.mjs +41 -0
  13. package/references/scripts/archive-changelog.mjs +441 -0
  14. package/references/scripts/archive-changelog.test.mjs +212 -0
  15. package/references/scripts/archive-issues.mjs +179 -0
  16. package/references/scripts/archive-issues.test.mjs +95 -0
  17. package/references/scripts/check-docs-size.mjs +353 -0
  18. package/references/scripts/check-docs-size.test.mjs +180 -0
  19. package/references/scripts/install-git-hooks.mjs +83 -0
  20. package/references/templates/AGENTS.md +78 -0
  21. package/references/templates/active_plan.md +31 -0
  22. package/references/templates/agent_rules.md +85 -0
  23. package/references/templates/architecture.md +49 -0
  24. package/references/templates/changelog.md +24 -0
  25. package/references/templates/current_state.md +36 -0
  26. package/references/templates/decisions.md +44 -0
  27. package/references/templates/env_commands.md +41 -0
  28. package/references/templates/handover.md +37 -0
  29. package/references/templates/known_issues.md +33 -0
  30. package/references/templates/pages/PAGE_TEMPLATE.md +53 -0
  31. package/references/templates/pages/index.md +23 -0
  32. package/references/templates/pages/shared-patterns.md +30 -0
  33. package/references/templates/tech_reference.md +34 -0
  34. package/references/templates/technical_specification.md +37 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog — agent-workflow-kit
2
+
3
+ Semantically versioned ([semver](https://semver.org)), newest first. The `version:` in `SKILL.md`
4
+ is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
5
+ every `migrations/<version>-<slug>.md` newer than it, in semver order.
6
+
7
+ ## 1.0.0 — Initial public release
8
+
9
+ First public release of `@sabaiway/agent-workflow-kit`. The kernel — distilled from a battle-tested, multi-year-verified reference implementation — ships on npm + GitHub so it installs (and self-upgrades) in one command. Adoption is countable from the registry's public per-version download numbers — no telemetry, no phone-home.
10
+
11
+ **The kernel — a portable AI-agent memory & workflow system**
12
+
13
+ - **Entry point** — `AGENTS.md` (cross-agent open standard: Codex / Cursor / Windsurf / Copilot read it natively) + `CLAUDE.md` symlink for Claude Code; concise Memory Map, protocols delegated to `agent_rules.md`.
14
+ - **`docs/ai/` structure** — `handover`, `active_plan`, `current_state`, `technical_specification`, `architecture`, `known_issues`, `decisions`, `changelog`, `env_commands`, `tech_reference`, `agent_rules` + `pages/` (`index`, `shared-patterns`, `PAGE_TEMPLATE`). Layered lazy-loading: always-loaded / on-demand / hierarchical subdir `AGENTS.md` / archive.
15
+ - **Frontmatter caps** — every file declares `maxLines` + `staleAfter`; the validator errors over cap, warns when stale.
16
+ - **Index-freshness gate** — `check-docs-size.mjs --check-index` regenerates the navigator in memory and diffs it against the on-disk `index.md`, using the on-disk header date so a day-rollover is not a false positive.
17
+ - **3-tier rolling archive** — `archive-changelog.mjs` (HOT changelog → WARM `recent.md` → COLD `YYYY-MM.md`) + condensed-index META; `archive-issues.mjs` for resolved issues.
18
+ - **Pre-commit hook** — `install-git-hooks.mjs` wires caps + index freshness + archive checks + the `scripts/` test suite; package-manager-agnostic (`node` directly).
19
+ - **Tests** — rotation/cap pure functions covered by `*.test.mjs`, runnable under `node --test` via a zero-dependency `expect` shim.
20
+ - **Planning** — `references/planning.md`: Plan→Phase→Step→Substep, ephemeral plan lifecycle, `queue.md` series-index, mandatory Cleanup, plan-then-execute split + session-continuity heuristic.
21
+ - **Two modes** — `/agent-workflow-kit` (new) and `/agent-workflow-kit upgrade` (existing).
22
+ - **Cross-agent invocation** — `launchers/`: `SKILL.md` is a native Codex skill (same cross-agent standard); a Windsurf workflow launcher + `install-launchers.sh` let Codex/Windsurf users run the bootstrapper too, not just Claude Code.
23
+ - **Visibility** — `visible` (committed) and `hidden` (in-tree, hidden via `~/.gitignore_global`).
24
+
25
+ **Distribution & install**
26
+
27
+ - **`npx @sabaiway/agent-workflow-kit init`** — `bin/install.mjs` (dependency-free, Node ≥ 18) copies the kit into `~/.claude/skills/agent-workflow-kit/` and runs `launchers/install-launchers.sh` (auto-detects Codex / Windsurf). `--dir` / `AGENT_WORKFLOW_KIT_DIR` override the target; `--no-launchers` skips the wiring.
28
+ - **Self-upgrade** — `npx @sabaiway/agent-workflow-kit@latest init` refreshes the kit's own files; distinct from `/agent-workflow-kit upgrade`, which migrates a project's `docs/ai/` deployment.
29
+ - **Manual install still supported** — `git clone` + `install-launchers.sh`; only the npx path is reflected in install stats.
30
+ - **Additive & safe** — the installer writes only the kit's own namespaced slots and never deletes your settings. A pre-existing non-kit Codex link or Windsurf workflow is left untouched unless you pass `--force`, which backs it up to `*.bak.<timestamp>` and prints a restore command first. Windsurf launcher files carry an `agent-workflow-kit:managed` marker so the installer can tell its own file from yours.
31
+
32
+ **Known limitation** — condensed-index grows O(total archived entries); shard per-year on a multi-year horizon (noted in `archive-changelog.mjs`). Fully-external hidden mode is deferred to a later release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sabaiway
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,216 @@
1
+ <div align="center">
2
+
3
+ # 🧠 agent-workflow-kit
4
+
5
+ **A portable, cross-agent memory & workflow system for AI coding agents.**
6
+
7
+ *Bootstrap it once — then every future session reconstructs project context in seconds
8
+ instead of re-reading your whole repo.*
9
+
10
+ `v1.0.0` · `Claude Code · Codex · Cursor · Windsurf` · `Node ≥ 18` · `kernel-only · English`
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## ❓ The problem
17
+
18
+ AI coding agents are **stateless between sessions**. Every new chat starts from zero:
19
+
20
+ ```
21
+ ── new session, no kit ───────────────────
22
+ ▶ "continue the feature"
23
+
24
+ reads 18 files… greps ×6…
25
+ re-infers the architecture…
26
+ re-asks a decision you settled…
27
+ ↓ (15k–40k tokens later)
28
+ …finally starts working
29
+ ──────────────────────────────────────────
30
+ → re-derives what it knew yesterday, and
31
+ re-introduces a bug you already fixed
32
+ ```
33
+
34
+ No durable handover ⇒ **drift between sessions, repeated mistakes, ballooning token cost.**
35
+
36
+ ---
37
+
38
+ ## ⚡ Without vs. With
39
+
40
+ The kit gives the agent a small, structured **memory** it reads at the start of every
41
+ session — instead of rebuilding context from source each time.
42
+
43
+ ```
44
+ WITHOUT the kit · cold start, cost grows
45
+ s1 ~30k tok ██████████
46
+ s2 ~28k tok █████████ ← repeats a fixed bug
47
+ s3 ~34k tok ███████████ ← drift
48
+
49
+ WITH the kit · boots from memory, cost flat
50
+ s1 ~4k tok █
51
+ s2 ~4k tok █ ← no drift
52
+ s3 ~5k tok █ ← decisions kept
53
+ ```
54
+
55
+ <sub>*Illustrative — exact numbers scale with repo size. The point is the **shape**: cold re-reads that grow vs. a flat, cache-warm boot.*</sub>
56
+
57
+ | | 🚫 Without | ✅ With `agent-workflow-kit` |
58
+ |---|---|---|
59
+ | **Session boot** | re-read source + grep to rebuild context | read 4 small docs, ~constant |
60
+ | **Boot cost** | grows with repo, paid every session | flat; stable layer stays prompt-cache-warm |
61
+ | **Cross-session memory** | none | `handover` (where we left off) |
62
+ | **Past decisions** | re-litigated | `decisions.md` (ADRs) — settled once |
63
+ | **Known bugs** | re-discovered | `known_issues.md` — impact + workaround |
64
+ | **Doc growth** | unbounded sprawl | frontmatter caps + 3-tier rolling archive |
65
+ | **Drift** | docs ≠ code over time | pre-commit gate keeps them honest |
66
+
67
+ ---
68
+
69
+ ## 📦 What it deploys into your project
70
+
71
+ ```
72
+ your-repo/
73
+ ├── AGENTS.md ← single entry point
74
+ ├── CLAUDE.md → AGENTS.md ← symlink, for Claude Code
75
+ └── docs/ai/
76
+ ├── index.md ← auto-generated navigator
77
+ ├── handover.md ← where we left off (read first)
78
+ ├── active_plan.md ← current task
79
+ ├── agent_rules.md ← session protocols + self-review
80
+ ├── current_state.md ← snapshot of the codebase now
81
+ ├── architecture.md ← layers & boundaries
82
+ ├── technical_specification.md
83
+ ├── decisions.md ← ADRs — settled once
84
+ ├── known_issues.md ← bugs + workarounds
85
+ ├── changelog.md ← rolling, then archived
86
+ ├── env_commands.md ← daily commands
87
+ ├── tech_reference.md ← configs & patterns
88
+ ├── pages/ ← one spec per page/route
89
+ └── history/ ← archive (HOT→WARM→COLD)
90
+ + scripts/ ← caps · index · archive (Node)
91
+ + pre-commit hook ← keeps it all honest
92
+ ```
93
+
94
+ Two visibility modes, chosen at bootstrap: **visible** (committed) or **hidden**
95
+ (in-tree but git-ignored, so the repo "looks normal").
96
+
97
+ ---
98
+
99
+ ## 🚀 Install
100
+
101
+ **One command** installs the kit into `~/.claude/skills/` and wires any Codex / Windsurf you have:
102
+
103
+ ```bash
104
+ npx @sabaiway/agent-workflow-kit init
105
+ ```
106
+
107
+ Then invoke it in any project:
108
+
109
+ | Agent | Invoke |
110
+ |-------|--------|
111
+ | **Claude Code** | `/agent-workflow-kit` |
112
+ | **Codex** | `/skills` menu → `agent-workflow-kit` |
113
+ | **Windsurf** (Cascade) | `/agent-workflow-kit` |
114
+
115
+ **Upgrade the kit itself** later — same command with `@latest`:
116
+
117
+ ```bash
118
+ npx @sabaiway/agent-workflow-kit@latest init
119
+ ```
120
+
121
+ <sub>That refreshes the **kit's own files** — distinct from `/agent-workflow-kit upgrade`, which migrates a **project's** deployment (see **Use** below).</sub>
122
+
123
+ <details>
124
+ <summary><b>Manual install</b> — no <code>npx</code></summary>
125
+
126
+ The kit is a single self-contained folder. Clone it into a skill scope yourself, then run the launcher:
127
+
128
+ ```bash
129
+ git clone https://github.com/sabaiway/agent-workflow-kit \
130
+ ~/.claude/skills/agent-workflow-kit
131
+ cd ~/.claude/skills/agent-workflow-kit
132
+ bash launchers/install-launchers.sh
133
+ ```
134
+
135
+ `install-launchers.sh` auto-detects Codex **and** Windsurf — it only touches tools you actually
136
+ have. See [`launchers/README.md`](launchers/README.md) for the full matrix (incl. Cursor / any
137
+ other agent). The manual path works identically but **isn't reflected in install stats** — prefer
138
+ `npx` if you don't mind.
139
+ </details>
140
+
141
+ <details>
142
+ <summary><b>What <code>init</code> touches — and how to undo it</b></summary>
143
+
144
+ `init` is **additive — it never deletes your settings.** It writes only its own namespaced slots:
145
+
146
+ | Path | What |
147
+ |------|------|
148
+ | `~/.claude/skills/agent-workflow-kit/` | the kit itself (refreshed on every `init`) |
149
+ | `~/.codex/skills/agent-workflow-kit` | a symlink — only if you have Codex |
150
+ | `…/global_workflows/agent-workflow-kit.md` | a managed file — only if you have Windsurf |
151
+
152
+ Your other Codex skills and Windsurf workflows are never touched. If one of those exact slots
153
+ already holds a file the kit didn't write, it is **left alone** and you're told — re-run with
154
+ `--force` to replace it (the original is first copied to `*.bak.<timestamp>` and the restore
155
+ command is printed).
156
+
157
+ **Uninstall:** delete the slots above (the kit folder, the symlink, the workflow file).
158
+ </details>
159
+
160
+ ---
161
+
162
+ ## 🛠️ Use
163
+
164
+ | Command | When | What happens |
165
+ |---------|------|--------------|
166
+ | `/agent-workflow-kit` | new / empty project | recon → **asks visible-or-hidden** → deploys `AGENTS.md` + `docs/ai/` filled with real recon data → installs enforcement → **asks before committing** |
167
+ | `/agent-workflow-kit upgrade` | existing deployment | reads `docs/ai/.workflow-version`, shows the changelog diff, applies migrations, re-stamps |
168
+
169
+ It **never auto-commits** and **never overwrites** an existing `AGENTS.md` without asking.
170
+
171
+ > **Two kinds of "upgrade":** `npx @sabaiway/agent-workflow-kit@latest init` updates the **kit's
172
+ > own files** in `~/.claude/skills/`; `/agent-workflow-kit upgrade` then migrates a **project's**
173
+ > `docs/ai/` deployment to that kit version.
174
+
175
+ ---
176
+
177
+ ## 🔍 How it works (60 seconds)
178
+
179
+ - **Layered, lazy loading** — *always-loaded* = `AGENTS.md` + `index.md` (~160 lines, cache-warm). *On-demand* = open a `docs/ai/` file only when its "Read When" applies. *Hierarchical* = subdir `AGENTS.md` loads when you work in that folder. *Archive* = old history rolls out of the hot files.
180
+ - **Caps + freshness** — every doc declares a `maxLines` cap; a pre-commit hook blocks commits that bust a cap or let the auto-generated index go stale.
181
+ - **3-tier rolling archive** — `changelog.md` (HOT, last days) → `history/recent.md` (WARM) → per-month COLD + a one-line condensed index. Hot files stay small forever.
182
+ - **Plan lifecycle** — Plan → Phase → Step → Substep, ephemeral plan files, a mandatory Cleanup phase, and a session-continuity heuristic tuned for large-context models (e.g. Opus 4.8).
183
+ - **No silent failures** — every guard that rejects an action logs structured context.
184
+
185
+ Enforcement ships as dependency-free **Node** scripts (`node --test`, no package manager assumed). Non-Node projects follow the same policy by hand.
186
+
187
+ ---
188
+
189
+ ## 🤝 Cross-agent by design
190
+
191
+ One kit, three front doors — the *output* (`AGENTS.md` + `docs/ai/`) is read natively by
192
+ Codex, Cursor, Windsurf, Copilot, Gemini CLI & 20+ tools, and the *bootstrapper* runs from
193
+ Claude Code, Codex, or Windsurf. No logic is duplicated per tool.
194
+
195
+ ---
196
+
197
+ ## 📁 What's in the kit
198
+
199
+ ```
200
+ agent-workflow-kit/
201
+ ├── README.md ← you are here
202
+ ├── SKILL.md ← agent-facing algorithm
203
+ ├── CHANGELOG.md ← version history
204
+ ├── references/
205
+ ├── templates/ ← AGENTS.md + every docs/ai file
206
+ ├── scripts/ ← caps / archive / index + tests
207
+ └── planning.md ← plan lifecycle + continuity
208
+ ├── launchers/ ← Codex / Windsurf / Cursor entries
209
+ └── migrations/ ← per-version upgrade steps
210
+ ```
211
+
212
+ ---
213
+
214
+ <div align="center">
215
+ <sub>Kernel-only · stack-agnostic · English · distilled from a multi-year-verified reference implementation.</sub>
216
+ </div>
package/SKILL.md ADDED
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: agent-workflow-kit
3
+ description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow".
4
+ disable-model-invocation: true
5
+ metadata:
6
+ version: '1.0.0'
7
+ ---
8
+
9
+ # agent-workflow-kit
10
+
11
+ Deploys a **portable AI-agent memory-and-workflow system** into a project, and upgrades it as the kernel evolves. After it runs, any future agent (including a fresh session of yourself) can reconstruct project context in ~60 seconds, find the current task, and avoid repeating past mistakes.
12
+
13
+ The kernel is **stack-agnostic workflow** — `docs/ai/` structure, entry-point doc, session protocols, plan lifecycle, frontmatter caps, 3-tier archive, index-freshness gate. Enforcement ships as **Node `.mjs` scripts** (the reference implementation; non-Node stacks follow the same policy manually). This skill is **English-only**.
14
+
15
+ This kernel is distilled from a canonical, battle-tested reference implementation. The skill is the single source of truth — projects deploy from it and upgrade against it.
16
+
17
+ ---
18
+
19
+ ## Two modes
20
+
21
+ Pick the mode from the user's invocation. Auto-detect an existing `docs/ai/` to guard against bootstrapping over a live system, but the user makes the final call.
22
+
23
+ - **`/agent-workflow-kit`** (default) — bootstrap a new or empty project. If `docs/ai/` already exists, stop and ask whether they meant `upgrade`.
24
+ - **`/agent-workflow-kit upgrade`** — upgrade an existing deployment to the skill's current `version`.
25
+
26
+ ### Mode: bootstrap
27
+
28
+ > Bundled sources below (templates, scripts) live in **this skill's own directory** — `${CLAUDE_SKILL_DIR}/` in Claude Code, or the folder containing this `SKILL.md` in Codex / other agents. Use that as the copy/read source; the working directory is the **target project**, not the skill.
29
+
30
+ 1. **Recon (read-only).** Before writing anything:
31
+ - `package.json` / `pyproject.toml` / `go.mod` / `Cargo.toml` → stack, package manager, scripts.
32
+ - `ls -la` root → `README`, existing `AGENTS.md`/`CLAUDE.md`, CI configs, linter/formatter configs.
33
+ - `git log --oneline -30` + `git status` → recent activity, branch, uncommitted changes.
34
+ - `src/` (or equivalent) 2–3 levels deep → modules, routes/pages, components, services, types.
35
+ - Tests (framework, location, E2E?) and linter rules.
36
+ - Record: stack, package manager, daily commands (`dev`/`test`/`lint`/`type-check`), routes/pages, architecture layers.
37
+ 2. **Choose visibility — ASK the user explicitly and wait for the answer, before writing anything.** This decides what gets tracked and is hard to reverse after a commit, so never assume the default silently: `visible` (committed — canonical, recommended) or `hidden` (in-tree, hidden via `~/.gitignore_global`). See *Visibility contract*.
38
+ 3. **Entry-point doc.** If `AGENTS.md` / `CLAUDE.md` already exist (step-1 recon), do **not** overwrite — show the user and ask whether to merge or replace. Otherwise create `AGENTS.md` (the cross-agent standard — Codex / Cursor / Windsurf / Copilot read it natively) from `${CLAUDE_SKILL_DIR}/references/templates/AGENTS.md`, and symlink `CLAUDE.md -> AGENTS.md` (`ln -s AGENTS.md CLAUDE.md`) for Claude Code — single source, no duplication. For nested context, add a subdir `AGENTS.md` (+ a `CLAUDE.md` symlink beside it for Claude Code).
39
+ 4. **Deploy `docs/ai/`.** Create the 11 files + `pages/` from `${CLAUDE_SKILL_DIR}/references/templates/`. Keep each file's frontmatter (`type / lastUpdated / scope / staleAfter / owner / maxLines`).
40
+ 5. **Fill templates** per the table below.
41
+ 6. **Install enforcement (Node projects).** Copy `${CLAUDE_SKILL_DIR}/references/scripts/*.mjs` (+ `*.test.mjs`) into the project's `scripts/`. They self-configure (project name from `package.json`, hierarchical/on-demand sections auto-discovered). **If the project has no Node runtime** (step-1 recon), skip this step and the hook in step 7 — follow the cap/archive/index policy manually, or port the scripts to the project's language.
42
+ 7. **Wire / hide** per visibility (see contract). Install the pre-commit hook (Node projects): `node scripts/install-git-hooks.mjs`. If the installer reports a pre-existing non-marker hook, stop and ask the user to merge it manually rather than overwriting.
43
+ 8. **Stamp version.** Write the skill's `version` into `docs/ai/.workflow-version` (one semver line).
44
+ 9. **Report & ask.** Show `tree docs/ai/`, 2–3 lines on what was filled with real data vs left as TODO, then **ask before committing** — never auto-commit.
45
+
46
+ Fill strategy:
47
+
48
+ | File | Strategy |
49
+ |------|----------|
50
+ | `current_state.md`, `architecture.md`, `env_commands.md`, `technical_specification.md`, `pages/index.md` | Fill with **real** recon data (stack, scripts, layers, routes). |
51
+ | `tech_reference.md` | Carry over real configs/patterns found in deps. |
52
+ | `active_plan.md`, `handover.md` | TODO seed (e.g. "Bootstrap session — fill domain sections after first real work"). |
53
+ | `decisions.md` | Seed `AD-001` (adopting this memory system). |
54
+ | `known_issues.md`, `changelog.md`, `pages/shared-patterns.md` | Empty template / first bootstrap entry. |
55
+
56
+ ### Mode: upgrade
57
+
58
+ 1. Read `docs/ai/.workflow-version` (the project's stamped version). If missing, treat as a pre-versioned deployment and offer to re-bootstrap conservatively.
59
+ 2. Compare to this skill's `metadata.version` (frontmatter). If equal → report "up to date" and stop.
60
+ 3. Show the relevant `${CLAUDE_SKILL_DIR}/CHANGELOG.md` diff (entries newer than the project's stamp).
61
+ 4. Apply `${CLAUDE_SKILL_DIR}/migrations/<version>-<slug>.md` in **semver order**, only those newer than the project's stamp. Migrations are **idempotent** — safe to re-run.
62
+ 5. Reconcile drift: add any kernel files/scripts the project is missing; never clobber project-authored content (their `decisions.md`, `known_issues.md`, page specs stay).
63
+ 6. Re-stamp `docs/ai/.workflow-version` to the skill's `version`. Report changes; **ask before committing**.
64
+
65
+ ---
66
+
67
+ ## Visibility contract
68
+
69
+ The user chooses at bootstrap whether the AI artifacts are visible in the repo or hidden — an **explicit up-front question** (step 2), never an assumed default. The two modes then diverge:
70
+
71
+ - **visible** — artifacts are committed. Wire the project's `package.json` scripts (`docs:check` / `docs:index` / `docs:index:check` / `docs:archive` / `docs:archive:check` / `docs:archive:issues` / `docs:archive:issues:check` / `prepare: node scripts/install-git-hooks.mjs`) and add a minimal `.gitignore` (`docs/plans/`, `.claude/settings.local.json`). This is the canonical model.
72
+ - **hidden** (in-tree) — same files on disk, but the repo "looks normal": append the artifact paths (`AGENTS.md`, `CLAUDE.md`, `docs/ai/`, `docs/plans/`, `scripts/*.mjs` you added, `docs/ai/.workflow-version`) to the global excludes file git **already uses** (`git config --get core.excludesFile`); if none is set, point it at `~/.gitignore_global` (`git config --global core.excludesFile ~/.gitignore_global`) and append there. **Verify `git status` shows the artifacts as ignored** afterwards. **Do not edit `package.json`** — that is a tracked change and would leak; the pre-commit hook (always untracked in `.git/hooks/`) calls the scripts via `node scripts/<x>.mjs` directly.
73
+
74
+ Not in this version: a fully-external hidden mode (artifacts relocated outside the repo tree). Deferred to a later release + migration.
75
+
76
+ ---
77
+
78
+ ## System principles (encode these into the project's `AGENTS.md`)
79
+
80
+ 1. **Single entry point.** `AGENTS.md` is the only entry point (tool aliases like `CLAUDE.md` symlink to it); it never bloats — details live in `docs/ai/`.
81
+ 2. **Memory Map.** A "read-when / update-when" table for every file. Without it agents get lost.
82
+ 3. **Three protocols.** Start of Session → During Work → Task Completion, each a short checklist.
83
+ 4. **Update docs BEFORE code.** Page behaviour changing? Update `pages/<page>.md` first, then the code.
84
+ 5. **No silent failures.** Every internal validation/guard that rejects an action logs structured context (component, action, ids, inputs); user-facing failures also surface in the UI.
85
+ 6. **TDD by default.** Test before code (unit for functions, E2E for user flows).
86
+ 7. **ADR for strategic choices.** Long-term-consequence decisions get a `decisions.md` entry.
87
+ 8. **Hard Constraints are tool-enforced.** Style rules live in linter/type-checker configs, not prose.
88
+ 9. **Ask before commit.** The agent reports quality-gate results and waits for explicit approval; it never auto-commits.
89
+ 10. **Honest `known_issues.md`.** Every bug with a workaround gets Impact + Plan so it isn't re-discovered later.
90
+
91
+ ---
92
+
93
+ ## Hard Constraints (template — adapt to the stack)
94
+
95
+ Deploy these into `AGENTS.md`; remove rows that don't apply to the stack.
96
+
97
+ | Rule | Enforcement |
98
+ |------|-------------|
99
+ | No `export default` (named exports only) | Linter |
100
+ | No `any` / no unsafe casts | Linter / type-checker |
101
+ | Functional style (no mutation in app code) | Linter |
102
+ | No single-letter variables | Code review |
103
+ | Interactive elements semantic (button/link, not div+onClick) | Linter / a11y |
104
+ | No hardcoded colors — design tokens only | Code review |
105
+ | No business logic in components → hooks/services | Architecture review |
106
+ | No changes without tests (TDD) | Required |
107
+ | Check page docs before changes; update them after | Process |
108
+ | Ask user before committing | Process |
109
+ | Every page has an HTML-validity / a11y E2E test | Required |
110
+ | **No silent failures** — structured logging on every rejected action | Required |
111
+
112
+ ---
113
+
114
+ ## References
115
+
116
+ - [`references/planning.md`](references/planning.md) — plan vocabulary (Plan→Phase→Step→Substep), lifecycle, `queue.md` series-index, mandatory Cleanup, session-continuity heuristic.
117
+ - [`references/templates/`](references/templates/) — stack-agnostic `AGENTS.md`, `agent_rules.md`, and all `docs/ai/` files to deploy.
118
+ - [`references/scripts/`](references/scripts/) — the Node enforcement scripts (caps + staleness + index-freshness gate, 3-tier archive, hook installer) and their unit tests.
119
+ - [`migrations/`](migrations/) — per-version upgrade steps; see `migrations/README.md`.
120
+ - [`launchers/`](launchers/) — run the bootstrapper from non-Claude agents (`SKILL.md` is a native Codex skill; a Windsurf workflow launcher + install script). See `launchers/README.md`.
121
+ - [`CHANGELOG.md`](CHANGELOG.md) — version history of this kernel.
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ // One-shot installer for @sabaiway/agent-workflow-kit.
3
+ //
4
+ // npx @sabaiway/agent-workflow-kit init
5
+ //
6
+ // Copies the kit into the canonical skill home (~/.claude/skills/agent-workflow-kit),
7
+ // then runs the cross-agent launcher (auto-detects Codex / Windsurf — only touches tools
8
+ // you actually have). Re-running refreshes the skill to this package's version, which is
9
+ // how you upgrade the *skill files* themselves:
10
+ //
11
+ // npx @sabaiway/agent-workflow-kit@latest init
12
+ //
13
+ // That is distinct from `/agent-workflow-kit upgrade`, which migrates a *project's*
14
+ // docs/ai deployment — see README "Use".
15
+ //
16
+ // No telemetry, no phone-home: adoption is the npm registry's public, passive per-version
17
+ // download numbers (api.npmjs.org/downloads). Nothing here contacts a server.
18
+ //
19
+ // Dependency-free, Node >= 18.
20
+
21
+ import { readFile, mkdir, readdir, copyFile, lstat, readlink, symlink } from 'node:fs/promises';
22
+ import { existsSync } from 'node:fs';
23
+ import { dirname, join, resolve } from 'node:path';
24
+ import { fileURLToPath } from 'node:url';
25
+ import { homedir } from 'node:os';
26
+ import { spawnSync } from 'node:child_process';
27
+
28
+ const __dirname = dirname(fileURLToPath(import.meta.url));
29
+ const PKG_ROOT = resolve(__dirname, '..');
30
+
31
+ // The deployable skill = everything except the npm wrapper (package.json, bin/).
32
+ const PAYLOAD = ['SKILL.md', 'README.md', 'CHANGELOG.md', 'references', 'launchers', 'migrations'];
33
+
34
+ const tildify = (path) => path.replace(homedir(), '~');
35
+
36
+ const readVersion = async () => {
37
+ try {
38
+ const pkg = JSON.parse(await readFile(resolve(PKG_ROOT, 'package.json'), 'utf8'));
39
+ return pkg.version ?? 'unknown';
40
+ } catch {
41
+ return 'unknown';
42
+ }
43
+ };
44
+
45
+ const copyRecursive = async (src, dest) => {
46
+ const stat = await lstat(src);
47
+ if (stat.isSymbolicLink()) {
48
+ if (existsSync(dest)) return; // additive: never delete/replace an existing entry
49
+ const linkTarget = await readlink(src);
50
+ await symlink(linkTarget, dest);
51
+ } else if (stat.isDirectory()) {
52
+ await mkdir(dest, { recursive: true });
53
+ const entries = await readdir(src);
54
+ await Promise.all(entries.map((entry) => copyRecursive(join(src, entry), join(dest, entry))));
55
+ } else {
56
+ await mkdir(dirname(dest), { recursive: true });
57
+ await copyFile(src, dest);
58
+ }
59
+ };
60
+
61
+ const parseArgs = (argv) => {
62
+ const dirFlag = argv.indexOf('--dir');
63
+ return {
64
+ help: argv.includes('--help') || argv.includes('-h'),
65
+ version: argv.includes('--version') || argv.includes('-v'),
66
+ noLaunchers: argv.includes('--no-launchers'),
67
+ force: argv.includes('--force'),
68
+ dir: dirFlag >= 0 ? argv[dirFlag + 1] : undefined,
69
+ };
70
+ };
71
+
72
+ const resolveTarget = (dirArg) => {
73
+ if (dirArg) return resolve(dirArg);
74
+ if (process.env.AGENT_WORKFLOW_KIT_DIR) return resolve(process.env.AGENT_WORKFLOW_KIT_DIR);
75
+ return resolve(homedir(), '.claude/skills/agent-workflow-kit');
76
+ };
77
+
78
+ const printHelp = (version) => {
79
+ console.log(`agent-workflow-kit ${version}
80
+
81
+ Usage:
82
+ npx @sabaiway/agent-workflow-kit init [--dir <path>] [--no-launchers] [--force]
83
+ npx @sabaiway/agent-workflow-kit --version
84
+ npx @sabaiway/agent-workflow-kit --help
85
+
86
+ Installs/refreshes the kit at ~/.claude/skills/agent-workflow-kit
87
+ (override with --dir <path> or AGENT_WORKFLOW_KIT_DIR), then wires any
88
+ Codex / Windsurf you have. --no-launchers skips that wiring; --force replaces a
89
+ pre-existing non-kit launcher file (backed up first). init is additive — it never
90
+ deletes your settings.
91
+
92
+ After install, invoke the skill in your agent:
93
+ Claude Code / Codex: /agent-workflow-kit
94
+ Windsurf Cascade: /agent-workflow-kit`);
95
+ };
96
+
97
+ const main = async () => {
98
+ const version = await readVersion();
99
+ const args = parseArgs(process.argv.slice(2));
100
+
101
+ if (args.help) return printHelp(version);
102
+ if (args.version) return console.log(version);
103
+
104
+ if (!existsSync(resolve(PKG_ROOT, 'SKILL.md'))) {
105
+ console.error('[agent-workflow-kit] package payload missing (no SKILL.md) — corrupt install?');
106
+ process.exit(1);
107
+ }
108
+
109
+ const target = resolveTarget(args.dir);
110
+ await mkdir(target, { recursive: true });
111
+ await Promise.all(
112
+ PAYLOAD.filter((entry) => existsSync(resolve(PKG_ROOT, entry))).map((entry) =>
113
+ copyRecursive(resolve(PKG_ROOT, entry), resolve(target, entry)),
114
+ ),
115
+ );
116
+ console.log(`[agent-workflow-kit] installed v${version} -> ${tildify(target)}`);
117
+
118
+ // Wire non-Claude agents — best-effort; the launcher only touches tools you have.
119
+ const launcher = resolve(target, 'launchers/install-launchers.sh');
120
+ if (args.noLaunchers) {
121
+ console.log('[agent-workflow-kit] --no-launchers: skipped Codex/Windsurf wiring.');
122
+ } else if (process.platform === 'win32') {
123
+ console.log('[agent-workflow-kit] Windows: skipped POSIX launcher. Claude Code reads the kit natively.');
124
+ } else if (existsSync(launcher)) {
125
+ const launcherArgs = args.force ? [launcher, '--force'] : [launcher];
126
+ const launcherRun = spawnSync('bash', launcherArgs, { stdio: 'inherit' });
127
+ if (launcherRun.status !== 0) {
128
+ console.warn('[agent-workflow-kit] launcher step skipped/failed — run it by hand if you use Codex/Windsurf:');
129
+ console.warn(` bash ${tildify(launcher)}`);
130
+ }
131
+ }
132
+
133
+ console.log('\nNext: open your agent and run /agent-workflow-kit');
134
+ };
135
+
136
+ main().catch((err) => {
137
+ console.error(err);
138
+ process.exit(1);
139
+ });
@@ -0,0 +1,33 @@
1
+ # Cross-agent launchers
2
+
3
+ `agent-workflow-kit` is one kit with **three front doors**. The logic lives once in
4
+ [`../SKILL.md`](../SKILL.md) + [`../references/`](../references/); each launcher is a thin
5
+ pointer, no duplicated logic. The kit's *output* (`AGENTS.md` + `docs/ai/`) is cross-agent
6
+ already — these launchers make the *bootstrapper itself* runnable from non-Claude agents.
7
+
8
+ `<KIT_DIR>` below = this kit's directory (e.g. `~/.claude/skills/agent-workflow-kit`).
9
+
10
+ ## Install matrix
11
+
12
+ | Agent | Mechanism | Install | Invoke |
13
+ |-------|-----------|---------|--------|
14
+ | **Claude Code** | native skill | already at `~/.claude/skills/agent-workflow-kit/` | `/agent-workflow-kit` |
15
+ | **Codex** | native skill (same `SKILL.md` cross-agent standard) | symlink the kit into a Codex skill scope: `ln -sfn <KIT_DIR> ~/.codex/skills/agent-workflow-kit` (or `~/.agents/skills/`) | Codex `/skills` menu → `agent-workflow-kit` |
16
+ | **Windsurf** | workflow (Cascade doesn't read `SKILL.md`) | `sed "s#<KIT_DIR>#$KIT#g" <KIT_DIR>/launchers/windsurf-workflow.md > ~/.codeium/windsurf/global_workflows/agent-workflow-kit.md` | `/agent-workflow-kit` in Cascade |
17
+ | **Cursor** (bonus) | command/rule | point a `.cursor/commands` entry at `<KIT_DIR>/SKILL.md` (same pattern as the Windsurf launcher) | the command name |
18
+ | **Any other** | manual | tell the agent: "execute the bootstrap in `<KIT_DIR>/SKILL.md`" | — |
19
+
20
+ Or run [`install-launchers.sh`](install-launchers.sh) — it auto-detects which of these tools
21
+ you have and installs the matching launcher (Claude Code needs none).
22
+
23
+ ## Notes
24
+
25
+ - **`${CLAUDE_SKILL_DIR}`** in `SKILL.md` means "this skill's own directory". Claude Code expands
26
+ it; other agents should read it as `<KIT_DIR>` (the folder containing `SKILL.md`).
27
+ - **Codex invocation policy**: `SKILL.md`'s `disable-model-invocation` is Claude-Code-specific.
28
+ To make the skill user-only in Codex too, add an `agents/openai.yaml` to the kit per the
29
+ [Codex skills docs](https://developers.openai.com/codex/skills). Without it, Codex may
30
+ auto-trigger; the kit's internal "ask before writing / ask before commit" gates still hold.
31
+ - **Where the kit lives for non-Claude users**: it does not have to be under `~/.claude/`. Clone
32
+ the kit anywhere (or to `~/.agents/skills/agent-workflow-kit`, which Codex scans) and point the
33
+ launchers at that path.