ai-runtime-kit 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +307 -0
- package/bin/cli.js +52 -0
- package/package.json +40 -0
- package/runtime/BOOTSTRAP.md +230 -0
- package/runtime/CAPABILITIES.md +166 -0
- package/runtime/INDEX.md +397 -0
- package/runtime/PRIORITIES.md +84 -0
- package/runtime/RUNTIME_HEALTH.md +87 -0
- package/runtime/RUNTIME_MODE.md +109 -0
- package/runtime/RUNTIME_TRANSITIONS.md +141 -0
- package/runtime/RUNTIME_VERSION.md +17 -0
- package/runtime/SAFETY.md +156 -0
- package/runtime/adr/0000-template.md +55 -0
- package/runtime/agents/executor.md +19 -0
- package/runtime/agents/verifier.md +83 -0
- package/runtime/hooks/README.md +163 -0
- package/runtime/hooks/_template/HOOK.md +87 -0
- package/runtime/hooks/pre-executor/runtime-scoped-preflight/HOOK.md +189 -0
- package/runtime/memory/architecture/principles.md +107 -0
- package/runtime/memory/engineering/principles.md +102 -0
- package/runtime/memory/runtime/context-loading.md +107 -0
- package/runtime/plans/_template.md +81 -0
- package/runtime/prds/_template.md +73 -0
- package/runtime/reviews/_template.md +37 -0
- package/runtime/rules/README.md +101 -0
- package/runtime/rules/_template/RULE.md +75 -0
- package/runtime/skills/README.md +96 -0
- package/runtime/skills/_template/SKILL.md +61 -0
- package/runtime/specs/_template/spec.md +50 -0
- package/runtime/specs/_template-bug-fix/spec.md +120 -0
- package/runtime/tasks/TASK_STATUS.md +58 -0
- package/runtime/tasks/_template.md +73 -0
- package/runtime/workflows/branching.md +128 -0
- package/runtime/workflows/bug-fix.md +169 -0
- package/runtime/workflows/feature-development.md +238 -0
- package/src/diff.js +81 -0
- package/src/git.js +38 -0
- package/src/init.js +166 -0
- package/src/prompt.js +17 -0
- package/src/snapshot.js +84 -0
- package/src/templates.js +96 -0
- package/src/upgrade.js +179 -0
- package/src/version.js +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kaelen
|
|
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,307 @@
|
|
|
1
|
+
# ai-runtime-kit
|
|
2
|
+
|
|
3
|
+
Reusable AI engineering runtime: BOOTSTRAP, workflows, safety, hooks,
|
|
4
|
+
and templates for software projects driven by AI agents.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx ai-runtime-kit init # new project
|
|
8
|
+
npx ai-runtime-kit upgrade # existing kit consumer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Status
|
|
12
|
+
|
|
13
|
+
**v0.5.0** — PRDs become a first-class workflow artifact upstream
|
|
14
|
+
of specs. New `runtime/prds/_template.md` (Problem / Target Users
|
|
15
|
+
/ Success Metrics / User Stories / Out of Scope / Open Questions
|
|
16
|
+
/ Stakeholders); new optional Step 0 in feature-development
|
|
17
|
+
workflow; `init` now scaffolds `.ai/project/prds/`. Bug fixes and
|
|
18
|
+
engineering-only changes still skip PRDs and go straight to a
|
|
19
|
+
spec. Kit still ships zero concrete skills — the `write-a-prd`
|
|
20
|
+
skill referenced in this repo's dogfood lives project-side.
|
|
21
|
+
|
|
22
|
+
**v0.4.1** — `init` now hints when `.ai/runtime/` is gitignored,
|
|
23
|
+
so clones won't silently miss the runtime tree. Print is
|
|
24
|
+
suppressed when the path is tracked (normal case) and in non-git
|
|
25
|
+
directories. Surfaced during dogfood: the kit's own repo
|
|
26
|
+
gitignores `.ai/runtime/` because it's a snapshot of `./runtime/`.
|
|
27
|
+
|
|
28
|
+
**v0.4.0** — `init` now also writes a project-root `CLAUDE.md`
|
|
29
|
+
agent entry file pointing Claude Code at
|
|
30
|
+
`.ai/runtime/BOOTSTRAP.md`, so the runtime is actually
|
|
31
|
+
discoverable on first run. The file is project-owned (never
|
|
32
|
+
touched by `upgrade`) and skippable via `--no-agent-entry`.
|
|
33
|
+
Surfaced and fixed during dogfood of this repo itself.
|
|
34
|
+
|
|
35
|
+
**v0.3.0** — kit skeleton, runtime snapshot, `init` + `upgrade`
|
|
36
|
+
CLI, documentation, and the two S3-discovered quirks fixed:
|
|
37
|
+
`init --migrate` now tolerates an empty-only `.ai/runtime/` left
|
|
38
|
+
by `git rm`, and `upgrade --pager <cmd>` pipes the per-file diff
|
|
39
|
+
through a pager when stdout is a TTY. ai-workflow-demo migrated
|
|
40
|
+
to consume this kit at v0.2.0 (the first dogfood consumer).
|
|
41
|
+
|
|
42
|
+
The design spec is at:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
ai-workflow-demo/.ai/project/specs/2026-05-13-phase-2-ai-runtime-kit-extraction/spec.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The S1–S3 completion records (kit skeleton, init/upgrade impl,
|
|
49
|
+
ai-workflow-demo migration) live at
|
|
50
|
+
`ai-workflow-demo/.ai/project/reviews/2026-05-1{3,4}-phase-2-s*.md`.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## What this is
|
|
55
|
+
|
|
56
|
+
A package that provides the reusable framework half of an
|
|
57
|
+
`.ai/` engineering runtime — the same content that lives under
|
|
58
|
+
`.ai/runtime/` in projects that adopt this system. Project-specific
|
|
59
|
+
content (concrete rules, skills, hooks, project memory, ADRs, specs,
|
|
60
|
+
plans, tasks, reviews) lives in `.ai/project/` and is **not** part
|
|
61
|
+
of the kit.
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
your-project/
|
|
65
|
+
├── .ai/
|
|
66
|
+
│ ├── runtime/ ← kit-managed (read-only between upgrades)
|
|
67
|
+
│ │ ├── BOOTSTRAP.md
|
|
68
|
+
│ │ ├── INDEX.md
|
|
69
|
+
│ │ ├── KIT_VERSION (e.g. 0.2.1)
|
|
70
|
+
│ │ ├── workflows/
|
|
71
|
+
│ │ ├── hooks/
|
|
72
|
+
│ │ ├── rules/ ← README + _template (no concrete rules)
|
|
73
|
+
│ │ ├── skills/ ← README + _template (no concrete skills)
|
|
74
|
+
│ │ └── ...
|
|
75
|
+
│ └── project/ ← project-owned
|
|
76
|
+
│ ├── rules/ ← your project's concrete rules
|
|
77
|
+
│ ├── skills/ ← your project's concrete skills
|
|
78
|
+
│ ├── hooks/ ← your project's concrete hooks
|
|
79
|
+
│ ├── specs/ plans/ tasks/ reviews/ ...
|
|
80
|
+
│ ├── STATE.md
|
|
81
|
+
│ └── ...
|
|
82
|
+
└── src/ ...
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Agents loading rules / skills / hooks read from **both** trees;
|
|
86
|
+
project-side files take precedence on path collision. The kit ships
|
|
87
|
+
zero concrete rules/skills/hooks (apart from the one safety-intrinsic
|
|
88
|
+
`pre-executor/runtime-scoped-preflight` hook), so collisions are
|
|
89
|
+
impossible in v0.x.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## What ships in `runtime/`
|
|
94
|
+
|
|
95
|
+
- Top-level docs: `BOOTSTRAP.md`, `INDEX.md`, `CAPABILITIES.md`,
|
|
96
|
+
`SAFETY.md`, `PRIORITIES.md`, `RUNTIME_HEALTH.md`,
|
|
97
|
+
`RUNTIME_MODE.md`, `RUNTIME_TRANSITIONS.md`, `RUNTIME_VERSION.md`.
|
|
98
|
+
- `workflows/` — feature-development, bug-fix, branching.
|
|
99
|
+
- `agents/` — `executor.md` and `verifier.md` role definitions.
|
|
100
|
+
(Architect, planner, reviewer are transition-only concepts
|
|
101
|
+
referenced by workflows and hooks; no file required.)
|
|
102
|
+
- `hooks/` — framework hook README + `_template/` + the one generic
|
|
103
|
+
governance hook:
|
|
104
|
+
`pre-executor/runtime-scoped-preflight` (GATE — enforces the
|
|
105
|
+
Runtime Tree Protection rule in `SAFETY.md`).
|
|
106
|
+
- `rules/` — framework README + `_template/`. **No concrete rules
|
|
107
|
+
ship**; projects author their own under `.ai/project/rules/`.
|
|
108
|
+
- `skills/` — framework README + `_template/`. Same convention.
|
|
109
|
+
- Templates: `specs/_template/`, `specs/_template-bug-fix/`,
|
|
110
|
+
`plans/_template.md`, `reviews/_template.md`, `tasks/_template.md`,
|
|
111
|
+
`adr/0000-template.md`.
|
|
112
|
+
- `memory/runtime/context-loading.md`,
|
|
113
|
+
`memory/architecture/principles.md`,
|
|
114
|
+
`memory/engineering/principles.md`.
|
|
115
|
+
- `tasks/TASK_STATUS.md` (schema only — instance state lives
|
|
116
|
+
project-side).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## `init` — initialize a fresh project
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx ai-runtime-kit init # in cwd
|
|
124
|
+
npx ai-runtime-kit init --cwd /path # somewhere else
|
|
125
|
+
npx ai-runtime-kit init --help
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Lays down `.ai/runtime/` (from the kit's canonical snapshot) and
|
|
129
|
+
`.ai/project/` (a skeleton with empty `specs/`, `plans/`, `tasks/`,
|
|
130
|
+
`reviews/`, `verifications/`, `adr/`, `contracts/`, `memory/`,
|
|
131
|
+
`rules/`, `skills/`, `hooks/` directories plus `STATE.md` and
|
|
132
|
+
`tasks/TASK_STATUS.md` from fill-the-blanks templates). Writes
|
|
133
|
+
`.ai/runtime/KIT_VERSION` recording the installed kit version. Also
|
|
134
|
+
writes a project-root `CLAUDE.md` (the Claude Code agent entry
|
|
135
|
+
point) pointing at `.ai/runtime/BOOTSTRAP.md`; pass
|
|
136
|
+
`--no-agent-entry` to skip it.
|
|
137
|
+
|
|
138
|
+
**Refuses** if `.ai/runtime/`, `.ai/project/`, or `CLAUDE.md`
|
|
139
|
+
already exists. Use `--migrate` if you're bootstrapping an existing
|
|
140
|
+
project that already has its own `.ai/project/` content or its own
|
|
141
|
+
`CLAUDE.md` (this is the path ai-workflow-demo took during S3).
|
|
142
|
+
`CLAUDE.md` is project-owned — `upgrade` never touches it.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## `upgrade` — update an existing kit consumer
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npx ai-runtime-kit upgrade # interactive
|
|
150
|
+
npx ai-runtime-kit upgrade --yes # skip y/N prompt
|
|
151
|
+
npx ai-runtime-kit upgrade --no-diff # skip per-file diff
|
|
152
|
+
npx ai-runtime-kit upgrade --allow-dirty # skip git porcelain check
|
|
153
|
+
npx ai-runtime-kit upgrade --allow-downgrade # install an older kit
|
|
154
|
+
npx ai-runtime-kit upgrade --help
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Sequence:
|
|
158
|
+
|
|
159
|
+
1. Verifies `.ai/runtime/KIT_VERSION` exists.
|
|
160
|
+
2. Refuses if the installed version is newer than the kit
|
|
161
|
+
(`--allow-downgrade` overrides).
|
|
162
|
+
3. If the project is a git repo: `git status --porcelain .ai/runtime/`
|
|
163
|
+
must be empty. (`--allow-dirty` overrides; non-git projects skip
|
|
164
|
+
this check with a warning.)
|
|
165
|
+
4. Computes a file-level diff (ADD / REPLACE / DELETE) of the kit's
|
|
166
|
+
canonical snapshot vs your current `.ai/runtime/`.
|
|
167
|
+
5. Prints the summary, then a `diff -u` per REPLACEd file (unless
|
|
168
|
+
`--no-diff`).
|
|
169
|
+
6. Prompts `Apply this upgrade? (y/N)` — default `N`. (`--yes`
|
|
170
|
+
bypasses.)
|
|
171
|
+
7. On yes: `rm -rf .ai/runtime/`, lays down the new snapshot,
|
|
172
|
+
updates KIT_VERSION. Never touches `.ai/project/`. Changes are
|
|
173
|
+
unstaged — review with `git diff .ai/runtime/` and commit when
|
|
174
|
+
ready.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Versioning
|
|
179
|
+
|
|
180
|
+
- Kit version is stored at `.ai/runtime/KIT_VERSION` (a single-line
|
|
181
|
+
semver string).
|
|
182
|
+
- Kit MAJOR is locked to `runtime/RUNTIME_VERSION.md`. v0.x and v1.x
|
|
183
|
+
both adapt to runtime `v1` (current, Frozen). A future runtime
|
|
184
|
+
`v2` would require a kit MAJOR bump.
|
|
185
|
+
- v0.x is pre-stable. Breaking changes can occur at any minor.
|
|
186
|
+
Pin to a specific minor in CI if you depend on the kit.
|
|
187
|
+
- The upgrade flow refuses downgrades by default (the kit treats
|
|
188
|
+
this as a likely mistake; the `--allow-downgrade` flag exists for
|
|
189
|
+
intentional rollback).
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Walkthrough 1 — fresh project from scratch
|
|
194
|
+
|
|
195
|
+
Assuming you've cloned the kit and `npm link`ed it:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
mkdir my-project && cd my-project
|
|
199
|
+
git init -b main
|
|
200
|
+
npx ai-runtime-kit init
|
|
201
|
+
# .ai/runtime/ and .ai/project/ are now laid down; KIT_VERSION = current
|
|
202
|
+
git add -A && git commit -m "chore: init .ai/ runtime + project skeleton"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Edit `.ai/project/STATE.md` — replace each `(fill me in)` placeholder
|
|
206
|
+
with values specific to your project (mode, health drivers, recovery
|
|
207
|
+
goals, current priority focus).
|
|
208
|
+
|
|
209
|
+
Edit `.ai/project/memory/core/tech-stack.md` (if you put one there)
|
|
210
|
+
with your stack details. Initially this file doesn't exist; create
|
|
211
|
+
it when you have something to record.
|
|
212
|
+
|
|
213
|
+
Open `.ai/runtime/BOOTSTRAP.md` and skim it — it's the agent-side
|
|
214
|
+
entry point describing the runtime contract.
|
|
215
|
+
|
|
216
|
+
You're ready to use this with any AI agent that knows how to read
|
|
217
|
+
`.ai/runtime/INDEX.md`.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Walkthrough 2 — adding a project-side rule
|
|
222
|
+
|
|
223
|
+
Project-side rules live at `.ai/project/rules/<language>/<name>.md`
|
|
224
|
+
(or `.ai/project/rules/<name>.md` for cross-language rules). The
|
|
225
|
+
kit's framework `rules/README.md` and `rules/_template/RULE.md`
|
|
226
|
+
describe the format; copy the template:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
mkdir -p .ai/project/rules/typescript
|
|
230
|
+
cp .ai/runtime/rules/_template/RULE.md \
|
|
231
|
+
.ai/project/rules/typescript/my-rule.md
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Edit `.ai/project/rules/typescript/my-rule.md`:
|
|
235
|
+
|
|
236
|
+
- Set the YAML frontmatter (`name`, `description`, `severity`, etc.)
|
|
237
|
+
- Fill in the body sections (the rule, the reason, examples,
|
|
238
|
+
exceptions).
|
|
239
|
+
|
|
240
|
+
That's it — no registration step required in v0.x. The kit's
|
|
241
|
+
canonical loading paths (workflows + context-loading) instruct
|
|
242
|
+
agents to scan **both** `.ai/runtime/rules/<lang>/` (kit, empty by
|
|
243
|
+
design) and `.ai/project/rules/<lang>/` (your project) at task time.
|
|
244
|
+
Your new rule applies automatically whenever the agent touches a
|
|
245
|
+
file in its scope.
|
|
246
|
+
|
|
247
|
+
Same shape for skills (`.ai/project/skills/<stack>/<name>/SKILL.md`)
|
|
248
|
+
and hooks (`.ai/project/hooks/<phase>/<name>/HOOK.md`). See the
|
|
249
|
+
kit's `skills/README.md` and `hooks/README.md` for the formats.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Local development
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
git clone <kit-repo> # currently local-only
|
|
257
|
+
cd ai-runtime-kit
|
|
258
|
+
npm link # makes `ai-runtime-kit` globally available
|
|
259
|
+
npm test # 8/8 smoke tests in test/
|
|
260
|
+
ai-runtime-kit --help # verify
|
|
261
|
+
ai-runtime-kit --version
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Layout:
|
|
265
|
+
|
|
266
|
+
```text
|
|
267
|
+
ai-runtime-kit/
|
|
268
|
+
├── bin/cli.js # dispatcher: --help, --version, init, upgrade
|
|
269
|
+
├── src/
|
|
270
|
+
│ ├── init.js # init command
|
|
271
|
+
│ ├── upgrade.js # upgrade command
|
|
272
|
+
│ ├── snapshot.js # kit→target copy + file walk
|
|
273
|
+
│ ├── git.js # porcelain dirty check
|
|
274
|
+
│ ├── version.js # KIT_VERSION read/write + semver compare
|
|
275
|
+
│ ├── diff.js # ADD/REPLACE/DELETE classifier + diff -u
|
|
276
|
+
│ ├── prompt.js # readline-based y/N
|
|
277
|
+
│ └── templates.js # STATE.md + project TASK_STATUS.md bodies
|
|
278
|
+
├── runtime/ # canonical framework snapshot
|
|
279
|
+
└── test/ # node:test smoke tests
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
`npm test` exercises both commands against `mkdtemp`'d fixture
|
|
283
|
+
projects.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## v0.3.0 quirk fixes
|
|
288
|
+
|
|
289
|
+
Both v0.2.x quirks discovered during the S3 dogfood are fixed:
|
|
290
|
+
|
|
291
|
+
- **`init --migrate` now tolerates empty `.ai/runtime/`.** If `git
|
|
292
|
+
rm -r .ai/runtime/` left empty parent directories behind, the
|
|
293
|
+
v0.3.0 `init` detects "exists but contains zero regular files"
|
|
294
|
+
and treats it as absent (cleans up the stale dirs and proceeds).
|
|
295
|
+
Real content under `.ai/runtime/` still triggers the refuse-to-
|
|
296
|
+
overwrite guard.
|
|
297
|
+
- **`upgrade --pager <cmd>` pipes per-file diff through a pager.**
|
|
298
|
+
Pass `--pager 'less -R'` (or set the env var
|
|
299
|
+
`AI_RUNTIME_KIT_PAGER`) and the per-file `diff -u` output is
|
|
300
|
+
spawned through the pager. Only applied when stdout is a TTY
|
|
301
|
+
(CI / scripted use keeps the direct-write behavior).
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT — see `LICENSE`.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const pkg = require('../package.json');
|
|
5
|
+
|
|
6
|
+
const HELP = `ai-runtime-kit ${pkg.version}
|
|
7
|
+
|
|
8
|
+
Usage: ai-runtime-kit <command> [options]
|
|
9
|
+
|
|
10
|
+
Commands:
|
|
11
|
+
init Initialize .ai/ runtime in the current directory.
|
|
12
|
+
upgrade Upgrade .ai/runtime/ to the kit's current version.
|
|
13
|
+
--help, -h Show this help.
|
|
14
|
+
--version Show kit version.
|
|
15
|
+
|
|
16
|
+
Run \`ai-runtime-kit <command> --help\` for command-specific options.
|
|
17
|
+
|
|
18
|
+
Design spec:
|
|
19
|
+
ai-workflow-demo/.ai/project/specs/2026-05-13-phase-2-ai-runtime-kit-extraction/spec.md`;
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
const cmd = process.argv[2];
|
|
23
|
+
const rest = process.argv.slice(3);
|
|
24
|
+
|
|
25
|
+
switch (cmd) {
|
|
26
|
+
case undefined:
|
|
27
|
+
case '--help':
|
|
28
|
+
case '-h':
|
|
29
|
+
console.log(HELP);
|
|
30
|
+
return;
|
|
31
|
+
case '--version':
|
|
32
|
+
case '-v':
|
|
33
|
+
console.log(pkg.version);
|
|
34
|
+
return;
|
|
35
|
+
case 'init':
|
|
36
|
+
require('../src/init').run(rest);
|
|
37
|
+
return;
|
|
38
|
+
case 'upgrade':
|
|
39
|
+
await require('../src/upgrade').run(rest);
|
|
40
|
+
return;
|
|
41
|
+
default:
|
|
42
|
+
console.error(`ai-runtime-kit: unknown command '${cmd}'`);
|
|
43
|
+
console.error('');
|
|
44
|
+
console.error(HELP);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main().catch((err) => {
|
|
50
|
+
console.error(`ai-runtime-kit: ${err.message ?? err}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-runtime-kit",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Reusable AI engineering runtime: BOOTSTRAP, workflows, safety, hooks, and templates for software projects driven by AI agents.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ai-runtime-kit": "./bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "node --test test/*.test.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"src",
|
|
14
|
+
"runtime",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "kaelen <kaelen.hou@gmail.com>",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/kaelen2026/ai-runtime-kit.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/kaelen2026/ai-runtime-kit#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/kaelen2026/ai-runtime-kit/issues"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"ai",
|
|
33
|
+
"agent",
|
|
34
|
+
"runtime",
|
|
35
|
+
"engineering",
|
|
36
|
+
"workflow",
|
|
37
|
+
"scaffolding",
|
|
38
|
+
"governance"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# AI Runtime Bootstrap
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This file defines how AI agents should initialize and operate within the repository runtime.
|
|
6
|
+
|
|
7
|
+
All AI execution should begin here.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Bootstrap Sequence
|
|
12
|
+
|
|
13
|
+
### Step 1: Read Runtime Index
|
|
14
|
+
|
|
15
|
+
Read:
|
|
16
|
+
|
|
17
|
+
```txt
|
|
18
|
+
.ai/runtime/INDEX.md
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Understand:
|
|
22
|
+
|
|
23
|
+
- runtime structure
|
|
24
|
+
- governance model
|
|
25
|
+
- workflow organization
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Step 2: Read Runtime Capabilities
|
|
30
|
+
|
|
31
|
+
Read:
|
|
32
|
+
|
|
33
|
+
```txt
|
|
34
|
+
.ai/runtime/CAPABILITIES.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Determine:
|
|
38
|
+
|
|
39
|
+
- supported operations
|
|
40
|
+
- unsupported operations
|
|
41
|
+
- runtime constraints
|
|
42
|
+
|
|
43
|
+
### Step 3: Read Runtime Mode
|
|
44
|
+
|
|
45
|
+
Read:
|
|
46
|
+
|
|
47
|
+
```txt
|
|
48
|
+
.ai/runtime/RUNTIME_MODE.md
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Determine:
|
|
52
|
+
|
|
53
|
+
- current operating mode
|
|
54
|
+
- execution behavior expectations
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Step 4: Read Safety Rules
|
|
59
|
+
|
|
60
|
+
Read:
|
|
61
|
+
|
|
62
|
+
```txt
|
|
63
|
+
.ai/runtime/SAFETY.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Determine:
|
|
67
|
+
|
|
68
|
+
- protected operations
|
|
69
|
+
- forbidden operations
|
|
70
|
+
- approval requirements
|
|
71
|
+
|
|
72
|
+
### Step 5: Read Priorities
|
|
73
|
+
|
|
74
|
+
Read:
|
|
75
|
+
|
|
76
|
+
```txt
|
|
77
|
+
.ai/runtime/PRIORITIES.md
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Determine:
|
|
81
|
+
|
|
82
|
+
- current priority focus
|
|
83
|
+
- runtime urgency
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Step 6: Read Runtime Health
|
|
88
|
+
|
|
89
|
+
Read:
|
|
90
|
+
|
|
91
|
+
```txt
|
|
92
|
+
.ai/runtime/RUNTIME_HEALTH.md
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Determine:
|
|
96
|
+
|
|
97
|
+
- current runtime stability
|
|
98
|
+
- allowed operation types
|
|
99
|
+
- runtime recovery priorities
|
|
100
|
+
|
|
101
|
+
### Step 7: Read Runtime Transitions
|
|
102
|
+
|
|
103
|
+
Read:
|
|
104
|
+
|
|
105
|
+
```txt
|
|
106
|
+
|
|
107
|
+
.ai/runtime/RUNTIME_TRANSITIONS.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Determine:
|
|
111
|
+
|
|
112
|
+
- allowed runtime transitions
|
|
113
|
+
- escalation behavior
|
|
114
|
+
- recovery behavior
|
|
115
|
+
|
|
116
|
+
### Step 8: Read Context Loading Strategy
|
|
117
|
+
|
|
118
|
+
Read:
|
|
119
|
+
|
|
120
|
+
```txt
|
|
121
|
+
.ai/runtime/memory/runtime/context-loading.md
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Determine:
|
|
125
|
+
|
|
126
|
+
- which memory layers to load
|
|
127
|
+
- which context to avoid loading
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Step 9: Read Active Workflow
|
|
132
|
+
|
|
133
|
+
Read the workflow file matching the current runtime mode:
|
|
134
|
+
|
|
135
|
+
| Runtime Mode | Workflow file |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| FEATURE_DEVELOPMENT | `.ai/runtime/workflows/feature-development.md` |
|
|
138
|
+
| BUG_FIX | `.ai/runtime/workflows/bug-fix.md` |
|
|
139
|
+
| GOVERNANCE_RECOVERY | `.ai/runtime/workflows/feature-development.md` (until a recovery-specific workflow exists) |
|
|
140
|
+
| REFACTOR | `.ai/runtime/workflows/feature-development.md` |
|
|
141
|
+
| INCIDENT | (no workflow file required; follow `SAFETY.md` only) |
|
|
142
|
+
|
|
143
|
+
Always also read `.ai/runtime/workflows/branching.md` regardless of mode — it
|
|
144
|
+
owns git-level rules (ref naming, branch tiers, merge gates) that apply
|
|
145
|
+
to every change.
|
|
146
|
+
|
|
147
|
+
Determine:
|
|
148
|
+
|
|
149
|
+
- spec lifecycle rules (`DRAFT → APPROVED → REJECTED → SUPERSEDED`)
|
|
150
|
+
- branch tiering rules
|
|
151
|
+
- merge gates
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Step 10: Load Relevant Memory
|
|
156
|
+
|
|
157
|
+
Examples:
|
|
158
|
+
|
|
159
|
+
#### Feature Work
|
|
160
|
+
|
|
161
|
+
Load:
|
|
162
|
+
|
|
163
|
+
- memory/core/
|
|
164
|
+
- memory/engineering/
|
|
165
|
+
- memory/product/
|
|
166
|
+
|
|
167
|
+
#### Refactor Work
|
|
168
|
+
|
|
169
|
+
Load:
|
|
170
|
+
|
|
171
|
+
- memory/architecture/
|
|
172
|
+
- memory/engineering/
|
|
173
|
+
- memory/runtime/
|
|
174
|
+
|
|
175
|
+
#### Governance Work
|
|
176
|
+
|
|
177
|
+
Load:
|
|
178
|
+
|
|
179
|
+
- memory/governance/
|
|
180
|
+
- memory/runtime/
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### Step 11: Determine Workflow State
|
|
185
|
+
|
|
186
|
+
Read:
|
|
187
|
+
|
|
188
|
+
- task status system
|
|
189
|
+
- relevant tasks
|
|
190
|
+
- relevant plans
|
|
191
|
+
- relevant specs
|
|
192
|
+
|
|
193
|
+
Determine:
|
|
194
|
+
|
|
195
|
+
- executable tasks
|
|
196
|
+
- blocked tasks
|
|
197
|
+
- dependency chains
|
|
198
|
+
- workflow health
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### Step 12: Execute Safely
|
|
203
|
+
|
|
204
|
+
Rules:
|
|
205
|
+
|
|
206
|
+
- preserve contracts
|
|
207
|
+
- preserve verification integrity
|
|
208
|
+
- preserve governance rules
|
|
209
|
+
- avoid unrelated changes
|
|
210
|
+
- stop on runtime tree edits
|
|
211
|
+
|
|
212
|
+
#### Runtime tree edits
|
|
213
|
+
|
|
214
|
+
If task execution requires modifying anything under `.ai/runtime/**`
|
|
215
|
+
and no authorizing runtime-scoped spec is present in the task's
|
|
216
|
+
referenced spec, STOP. Surface the situation to the user — runtime
|
|
217
|
+
edits are governance changes per `.ai/runtime/SAFETY.md` § Runtime
|
|
218
|
+
Tree Protection.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Runtime Principles
|
|
223
|
+
|
|
224
|
+
- Prefer narrow context.
|
|
225
|
+
- Prefer incremental execution.
|
|
226
|
+
- Preserve workflow consistency.
|
|
227
|
+
- Preserve runtime health.
|
|
228
|
+
- Verification is mandatory.
|
|
229
|
+
- Contracts override convenience.
|
|
230
|
+
- Governance overrides speed.
|