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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Runtime Mode
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define the current engineering operating mode.
|
|
6
|
+
|
|
7
|
+
AI agents should adapt behavior based on runtime mode.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Available Modes
|
|
12
|
+
|
|
13
|
+
### FEATURE_DEVELOPMENT
|
|
14
|
+
|
|
15
|
+
Focus:
|
|
16
|
+
|
|
17
|
+
- feature delivery
|
|
18
|
+
- execution speed
|
|
19
|
+
- additive work
|
|
20
|
+
|
|
21
|
+
Behavior:
|
|
22
|
+
|
|
23
|
+
- prioritize executable feature tasks
|
|
24
|
+
- prefer small incremental changes
|
|
25
|
+
- preserve contracts
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### BUG_FIX
|
|
30
|
+
|
|
31
|
+
Focus:
|
|
32
|
+
|
|
33
|
+
- corrective change (observed vs documented behavior)
|
|
34
|
+
- minimal scope
|
|
35
|
+
- regression-test-first execution
|
|
36
|
+
|
|
37
|
+
Behavior:
|
|
38
|
+
|
|
39
|
+
- follow `.ai/runtime/workflows/bug-fix.md` strictly
|
|
40
|
+
- require Root Cause / Reproduction / Regression Test sections in spec
|
|
41
|
+
- write the regression test before the fix; confirm red → green
|
|
42
|
+
- prefer the smallest fix that addresses the named root cause
|
|
43
|
+
- preserve contracts; treat fixes as additive when possible
|
|
44
|
+
|
|
45
|
+
This mode is for non-incident corrective work. Production
|
|
46
|
+
incidents escalate to `INCIDENT` per
|
|
47
|
+
`RUNTIME_TRANSITIONS.md` § Any Mode → INCIDENT.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### GOVERNANCE_RECOVERY
|
|
52
|
+
|
|
53
|
+
Focus:
|
|
54
|
+
|
|
55
|
+
- workflow consistency
|
|
56
|
+
- verification coverage
|
|
57
|
+
- contract integrity
|
|
58
|
+
- runtime health
|
|
59
|
+
|
|
60
|
+
Behavior:
|
|
61
|
+
|
|
62
|
+
- prioritize maintenance tasks
|
|
63
|
+
- prioritize review coverage
|
|
64
|
+
- prioritize workflow repair
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### REFACTOR
|
|
69
|
+
|
|
70
|
+
Focus:
|
|
71
|
+
|
|
72
|
+
- architecture consistency
|
|
73
|
+
- module boundaries
|
|
74
|
+
- technical debt reduction
|
|
75
|
+
|
|
76
|
+
Behavior:
|
|
77
|
+
|
|
78
|
+
- prioritize safe migrations
|
|
79
|
+
- minimize behavior changes
|
|
80
|
+
- prefer small refactor tasks
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### INCIDENT
|
|
85
|
+
|
|
86
|
+
Focus:
|
|
87
|
+
|
|
88
|
+
- runtime stability
|
|
89
|
+
- rollback safety
|
|
90
|
+
- production recovery
|
|
91
|
+
|
|
92
|
+
Behavior:
|
|
93
|
+
|
|
94
|
+
- avoid unnecessary changes
|
|
95
|
+
- prioritize verification
|
|
96
|
+
- minimize scope
|
|
97
|
+
- avoid refactors
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Runtime Health Interaction
|
|
102
|
+
|
|
103
|
+
Runtime mode should adapt to runtime health.
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
|
|
107
|
+
- YELLOW health limits risky refactors.
|
|
108
|
+
- RED health pauses feature expansion.
|
|
109
|
+
- GREEN health allows normal feature development.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Runtime Transition Rules
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define how runtime state changes in response to governance conditions.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Health Transitions
|
|
10
|
+
|
|
11
|
+
### GREEN → YELLOW
|
|
12
|
+
|
|
13
|
+
Trigger conditions:
|
|
14
|
+
|
|
15
|
+
- governance drift detected
|
|
16
|
+
- stale runtime metadata
|
|
17
|
+
- missing review coverage
|
|
18
|
+
- inconsistent lifecycle state
|
|
19
|
+
- runtime audit warnings
|
|
20
|
+
|
|
21
|
+
Behavior changes:
|
|
22
|
+
|
|
23
|
+
- prioritize maintenance
|
|
24
|
+
- reduce risky changes
|
|
25
|
+
- increase governance focus
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### YELLOW → RED
|
|
30
|
+
|
|
31
|
+
Trigger conditions:
|
|
32
|
+
|
|
33
|
+
- verification failure
|
|
34
|
+
- active contract violation
|
|
35
|
+
- failing build
|
|
36
|
+
- runtime instability
|
|
37
|
+
- broken bootstrap
|
|
38
|
+
|
|
39
|
+
Behavior changes:
|
|
40
|
+
|
|
41
|
+
- stop feature expansion
|
|
42
|
+
- prioritize recovery
|
|
43
|
+
- minimize execution scope
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### RED → YELLOW
|
|
48
|
+
|
|
49
|
+
Trigger conditions:
|
|
50
|
+
|
|
51
|
+
- verification restored
|
|
52
|
+
- runtime stable
|
|
53
|
+
- critical failures resolved
|
|
54
|
+
|
|
55
|
+
Behavior changes:
|
|
56
|
+
|
|
57
|
+
- allow governance repair
|
|
58
|
+
- continue limited execution
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### YELLOW → GREEN
|
|
63
|
+
|
|
64
|
+
Trigger conditions:
|
|
65
|
+
|
|
66
|
+
- governance stabilized
|
|
67
|
+
- runtime consistency restored
|
|
68
|
+
- verification healthy
|
|
69
|
+
- no active runtime drift
|
|
70
|
+
|
|
71
|
+
Behavior changes:
|
|
72
|
+
|
|
73
|
+
- allow feature development
|
|
74
|
+
- allow runtime evolution
|
|
75
|
+
- reduce governance overhead
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Mode Transitions
|
|
80
|
+
|
|
81
|
+
### FEATURE_DEVELOPMENT → GOVERNANCE_RECOVERY
|
|
82
|
+
|
|
83
|
+
Trigger conditions:
|
|
84
|
+
|
|
85
|
+
- runtime audit detects governance drift
|
|
86
|
+
- workflow inconsistencies accumulate
|
|
87
|
+
- verification coverage degrades
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### GOVERNANCE_RECOVERY → FEATURE_DEVELOPMENT
|
|
92
|
+
|
|
93
|
+
Trigger conditions:
|
|
94
|
+
|
|
95
|
+
- governance stabilized
|
|
96
|
+
- runtime health GREEN
|
|
97
|
+
- workflow consistency restored
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### FEATURE_DEVELOPMENT → BUG_FIX
|
|
102
|
+
|
|
103
|
+
Trigger conditions:
|
|
104
|
+
|
|
105
|
+
- a defect is observed in shipped behavior
|
|
106
|
+
- the change is corrective, not additive
|
|
107
|
+
- production incident has NOT been declared
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### BUG_FIX → FEATURE_DEVELOPMENT
|
|
112
|
+
|
|
113
|
+
Trigger conditions:
|
|
114
|
+
|
|
115
|
+
- the fix is DONE per `bug-fix.md` § Definition of done
|
|
116
|
+
- no further corrective work is queued
|
|
117
|
+
- runtime health is GREEN
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### Any Mode → INCIDENT
|
|
122
|
+
|
|
123
|
+
Trigger conditions:
|
|
124
|
+
|
|
125
|
+
- RED runtime health
|
|
126
|
+
- contract breach
|
|
127
|
+
- failed verification
|
|
128
|
+
- runtime instability
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Runtime Principle
|
|
133
|
+
|
|
134
|
+
Runtime state should evolve conservatively.
|
|
135
|
+
|
|
136
|
+
Prefer:
|
|
137
|
+
|
|
138
|
+
- gradual escalation
|
|
139
|
+
- explicit recovery
|
|
140
|
+
- observable transitions
|
|
141
|
+
- reversible operations
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Runtime Safety Rules
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Define repository safety boundaries for AI agents.
|
|
6
|
+
|
|
7
|
+
AI agents must follow these rules before modifying the repository.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Safe Operations
|
|
12
|
+
|
|
13
|
+
Allowed without additional approval:
|
|
14
|
+
|
|
15
|
+
- additive feature work
|
|
16
|
+
- behavior-preserving refactors
|
|
17
|
+
- test additions
|
|
18
|
+
- review additions
|
|
19
|
+
- documentation updates
|
|
20
|
+
- task status updates
|
|
21
|
+
- plan updates
|
|
22
|
+
- review updates
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Protected Operations
|
|
27
|
+
|
|
28
|
+
Require explicit review or approval:
|
|
29
|
+
|
|
30
|
+
- contract changes
|
|
31
|
+
- breaking API changes
|
|
32
|
+
- runtime governance changes
|
|
33
|
+
- bootstrap changes
|
|
34
|
+
- priority system changes
|
|
35
|
+
- task lifecycle changes
|
|
36
|
+
- runtime mode changes
|
|
37
|
+
- verification policy changes
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### Runtime Tree Protection
|
|
42
|
+
|
|
43
|
+
The path scope `.ai/runtime/**` is a protected zone. It holds reusable
|
|
44
|
+
framework content (protocols, schemas, role definitions, generic
|
|
45
|
+
memory, workflows, templates) that other projects consume verbatim
|
|
46
|
+
once Phase 2 of the runtime extraction ships
|
|
47
|
+
(`ai-runtime-kit`).
|
|
48
|
+
|
|
49
|
+
#### What counts as a runtime edit
|
|
50
|
+
|
|
51
|
+
Any of the following actions targeting `.ai/runtime/**`:
|
|
52
|
+
|
|
53
|
+
- modifying an existing file
|
|
54
|
+
- adding a new file
|
|
55
|
+
- renaming or moving a file
|
|
56
|
+
- deleting a file
|
|
57
|
+
|
|
58
|
+
#### Rule
|
|
59
|
+
|
|
60
|
+
Runtime edits are governance changes. Each runtime edit requires:
|
|
61
|
+
|
|
62
|
+
- a spec under `.ai/project/specs/YYYY-MM-DD-<name>/` whose §2 Scope
|
|
63
|
+
lists the touched runtime paths explicitly, and
|
|
64
|
+
- a review file under `.ai/project/reviews/`.
|
|
65
|
+
|
|
66
|
+
Runtime edits MUST NOT be folded into feature work whose scope is a
|
|
67
|
+
project module (e.g. `src/modules/auth/`).
|
|
68
|
+
|
|
69
|
+
#### Exemptions
|
|
70
|
+
|
|
71
|
+
- The Phase 2 `ai-runtime-kit init` / `upgrade` flow operates outside
|
|
72
|
+
this rule — those commands materialize or replace the entire
|
|
73
|
+
`.ai/runtime/` subtree as a unit and are the canonical source of
|
|
74
|
+
truth. They do not constitute "edits" in the sense above.
|
|
75
|
+
- Pure read access (any agent loading a runtime file as context) is
|
|
76
|
+
unconstrained.
|
|
77
|
+
|
|
78
|
+
#### Why
|
|
79
|
+
|
|
80
|
+
- Phase 2 upgrades reset `.ai/runtime/` to the kit's canonical state;
|
|
81
|
+
edits made outside the spec-driven flow are lost.
|
|
82
|
+
- Project-specific knowledge that leaks into `runtime/` makes the
|
|
83
|
+
framework non-reusable across other projects.
|
|
84
|
+
- Spec-driven flow is how the rest of this governance system catches
|
|
85
|
+
regressions; runtime edits must use the same path.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## High-Risk Operations
|
|
90
|
+
|
|
91
|
+
Require ADR approval:
|
|
92
|
+
|
|
93
|
+
- deleting public APIs
|
|
94
|
+
- changing API response shapes
|
|
95
|
+
- removing contracts
|
|
96
|
+
- changing runtime architecture
|
|
97
|
+
- changing verification requirements
|
|
98
|
+
- removing governance artifacts
|
|
99
|
+
- changing task graph semantics
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Forbidden Operations
|
|
104
|
+
|
|
105
|
+
AI agents must NOT:
|
|
106
|
+
|
|
107
|
+
- bypass verification
|
|
108
|
+
- skip governance rules
|
|
109
|
+
- ignore contract violations
|
|
110
|
+
- silently change runtime behavior
|
|
111
|
+
- delete `.ai/` runtime structure
|
|
112
|
+
- remove reviews/verifications without reason
|
|
113
|
+
- execute destructive repository operations without approval
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Verification Safety
|
|
118
|
+
|
|
119
|
+
Before marking work DONE:
|
|
120
|
+
|
|
121
|
+
- verification must pass
|
|
122
|
+
- contracts must remain valid
|
|
123
|
+
- reviews must exist if required
|
|
124
|
+
- runtime health must not degrade
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Runtime Protection Priority
|
|
129
|
+
|
|
130
|
+
Priority order:
|
|
131
|
+
|
|
132
|
+
```txt
|
|
133
|
+
Safety
|
|
134
|
+
↓
|
|
135
|
+
Governance
|
|
136
|
+
↓
|
|
137
|
+
Contracts
|
|
138
|
+
↓
|
|
139
|
+
Verification
|
|
140
|
+
↓
|
|
141
|
+
Execution Speed
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Safety always overrides convenience.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Runtime Philosophy
|
|
149
|
+
|
|
150
|
+
The runtime should prefer:
|
|
151
|
+
|
|
152
|
+
- safe incremental change
|
|
153
|
+
- explicit governance
|
|
154
|
+
- observable workflow state
|
|
155
|
+
- reversible operations
|
|
156
|
+
- minimal surprise
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# ADR <NUMBER>: <TITLE>
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Proposed | Accepted | Rejected | Deprecated
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
Describe the problem, constraints, and background.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Decision
|
|
16
|
+
|
|
17
|
+
Describe the chosen solution.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Alternatives Considered
|
|
22
|
+
|
|
23
|
+
### Option 1
|
|
24
|
+
|
|
25
|
+
Pros:
|
|
26
|
+
-
|
|
27
|
+
|
|
28
|
+
Cons:
|
|
29
|
+
-
|
|
30
|
+
|
|
31
|
+
### Option 2
|
|
32
|
+
|
|
33
|
+
Pros:
|
|
34
|
+
-
|
|
35
|
+
|
|
36
|
+
Cons:
|
|
37
|
+
-
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Consequences
|
|
42
|
+
|
|
43
|
+
### Positive
|
|
44
|
+
|
|
45
|
+
-
|
|
46
|
+
|
|
47
|
+
### Negative
|
|
48
|
+
|
|
49
|
+
-
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
Additional implementation notes if needed.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Executor Agent
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You implement features according to specs.
|
|
6
|
+
|
|
7
|
+
## Responsibilities
|
|
8
|
+
|
|
9
|
+
- Read the provided spec
|
|
10
|
+
- Modify code safely
|
|
11
|
+
- Keep implementation simple
|
|
12
|
+
- Run build verification
|
|
13
|
+
- Report changed files
|
|
14
|
+
|
|
15
|
+
## Must Not
|
|
16
|
+
|
|
17
|
+
- Change unrelated code
|
|
18
|
+
- Add unnecessary dependencies
|
|
19
|
+
- Ignore build failures
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Verifier Agent
|
|
2
|
+
|
|
3
|
+
## Role
|
|
4
|
+
|
|
5
|
+
You are responsible for implementation verification and regression detection.
|
|
6
|
+
|
|
7
|
+
You do NOT implement features.
|
|
8
|
+
|
|
9
|
+
You verify:
|
|
10
|
+
- correctness
|
|
11
|
+
- compatibility
|
|
12
|
+
- contracts
|
|
13
|
+
- tests
|
|
14
|
+
- build integrity
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Responsibilities
|
|
19
|
+
|
|
20
|
+
- Run verification commands
|
|
21
|
+
- Compare implementation against contracts
|
|
22
|
+
- Detect regressions
|
|
23
|
+
- Detect missing tests
|
|
24
|
+
- Detect API breaking changes
|
|
25
|
+
- Detect contract violations
|
|
26
|
+
- Detect missing verification coverage
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Verification Areas
|
|
31
|
+
|
|
32
|
+
### Build
|
|
33
|
+
|
|
34
|
+
- TypeScript build passes
|
|
35
|
+
- No new type errors
|
|
36
|
+
|
|
37
|
+
### Tests
|
|
38
|
+
|
|
39
|
+
- Existing tests still pass
|
|
40
|
+
- New functionality is covered
|
|
41
|
+
|
|
42
|
+
### API Contracts
|
|
43
|
+
|
|
44
|
+
- Response fields are unchanged
|
|
45
|
+
- Field types are unchanged
|
|
46
|
+
- Required fields still exist
|
|
47
|
+
|
|
48
|
+
### Architecture
|
|
49
|
+
|
|
50
|
+
- Existing app structure remains consistent
|
|
51
|
+
- No unnecessary coupling introduced
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Output Format
|
|
56
|
+
|
|
57
|
+
### Summary
|
|
58
|
+
|
|
59
|
+
Short verification summary.
|
|
60
|
+
|
|
61
|
+
### Passed Checks
|
|
62
|
+
|
|
63
|
+
List successful checks.
|
|
64
|
+
|
|
65
|
+
### Failed Checks
|
|
66
|
+
|
|
67
|
+
List failed checks.
|
|
68
|
+
|
|
69
|
+
### Risks
|
|
70
|
+
|
|
71
|
+
Potential future risks or weak areas.
|
|
72
|
+
|
|
73
|
+
### Verdict
|
|
74
|
+
|
|
75
|
+
PASS | FAIL
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Must Not
|
|
80
|
+
|
|
81
|
+
- Implement features
|
|
82
|
+
- Change feature scope
|
|
83
|
+
- Ignore failing checks
|