@michelj/context-guard 0.4.2 → 0.4.4
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/README.md +113 -150
- package/README.zh-CN.md +113 -150
- package/SKILL.md +46 -0
- package/agents/openai.yaml +4 -0
- package/bin/context-guard-skill.js +234 -46
- package/bin/postinstall.js +1 -1
- package/hooks.json +29 -5
- package/package.json +12 -5
- package/prototype/workbench.html +4933 -0
- package/references/bug-record-template.md +37 -0
- package/references/context-template.md +19 -0
- package/scripts/context_guard.py +806 -0
- package/scripts/context_guard_hook.py +302 -0
- package/scripts/map_owns.py +769 -0
- package/skills/context-guard/README.md +0 -234
- package/skills/context-guard/README.zh-CN.md +0 -234
- package/skills/context-guard/SKILL.md +0 -558
- package/skills/context-guard/agents/openai.yaml +0 -4
- package/skills/context-guard/references/context-template.md +0 -290
- package/skills/context-guard/references/register-template.md +0 -85
- package/skills/context-guard/references/task-case-template.md +0 -63
- package/skills/context-guard/scripts/context_guard.py +0 -4886
- package/skills/context-guard/scripts/context_guard_hook.py +0 -522
- package/skills/context-guard/tests/BC-20260618-063.sh +0 -116
- package/skills/context-guard/tests/BC-20260618-065.sh +0 -66
- package/skills/context-guard/tests/BC-20260626-080.sh +0 -48
- package/skills/context-guard/tests/BC-20260626-081.sh +0 -40
- package/skills/context-guard/tests/BC-20260626-082.sh +0 -32
- package/skills/context-guard/tests/BC-20260626-083.sh +0 -66
- package/skills/context-guard/tests/BC-20260627-084.sh +0 -74
- package/skills/context-guard/tests/BC-20260630-086.sh +0 -50
- package/skills/context-guard/tests/BC-20260630-087.sh +0 -103
- package/skills/context-guard/tests/BC-20260630-088.sh +0 -32
- package/skills/context-guard/tests/BC-20260630-089.sh +0 -63
- package/skills/context-guard/tests/BC-20260701-090.sh +0 -83
- package/skills/context-guard/tests/BC-20260702-096.sh +0 -45
package/README.md
CHANGED
|
@@ -2,233 +2,196 @@
|
|
|
2
2
|
|
|
3
3
|
Language: **English** | [中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
Context Guard is a
|
|
5
|
+
Context Guard is a durable project-memory skill for Codex, Cursor, and Claude. It keeps the task route, branches, bad cases, and verification paths inside the project's own `.codex/context/` folder, so agents can understand where the work is, what went wrong before, and how to avoid repeating fixed mistakes across sessions.
|
|
6
6
|
|
|
7
7
|
## What It Does
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **Handles task switches**: parks, resumes, and branches interrupted work.
|
|
16
|
-
- **Keeps tests human-designed**: Codex reuses approved checks or proposes drafts, but does not silently create durable tests.
|
|
17
|
-
- **Covers bad cases with feature chains**: prefer one real feature/workflow chain covering multiple bad cases over one separate test per bad case.
|
|
18
|
-
- **Runs approved tests by default**: user-created or user-approved tests run at every development completion unless the user sets another cadence.
|
|
19
|
-
- **Provides a Test Hub entrypoint**: `dev-complete` runs approved always-run tests, cleans success artifacts, and preserves failed evidence.
|
|
9
|
+
- **Four stores**: sessions, bugs, tasks, map — in the opened project’s `.codex/context/`
|
|
10
|
+
- **First-use map**: the agent and the human decide the first layer together (several candidate cuts, then lock L1), then L2, then L3. Titles must be instantly readable. Later sessions open that map
|
|
11
|
+
- **Human workbench**: people confirm in `prototype/workbench.html`. Agents read small indexes, not the whole map
|
|
12
|
+
- **User wording**: durable prompts go in `user-messages.md`; secrets stay under `private/`
|
|
13
|
+
- **Record language**: Chinese or English per folder
|
|
14
|
+
- **Lifecycle**: create session records, retain user messages, and persist agent-identified bad cases through one command
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
v1 does **not** include Roadmap HTML, Test Hub, or feature chains.
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
## Human workbench
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
npx @michelj/context-guard install
|
|
27
|
-
```
|
|
20
|
+
People confirm the architecture map in the workbench. With hooks installed, a new session starts one local workbench instance and opens it in the browser. Agents read the small indexes under `.codex/context/`; they do not drive the canvas.
|
|
28
21
|
|
|
29
|
-
|
|
22
|
+
**Current workbench:** [prototype/workbench.html](https://github.com/Michel-Johnson/Context-Guard-Skill/blob/main/prototype/workbench.html) · [open in browser](https://raw.githack.com/Michel-Johnson/Context-Guard-Skill/main/prototype/workbench.html)
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
npm install -g @michelj/context-guard --registry=https://registry.npmjs.org
|
|
33
|
-
```
|
|
24
|
+
The first browser open may show GitHack’s “One more step” page (it is only a proxy and does not review the HTML). Click **Open the page**.
|
|
34
25
|
|
|
35
|
-
|
|
26
|
+
To decide the first layer: click the repo name, switch to **OpenClaw** (first use), then **See first-layer cuts**. Picking one lands it on the canvas. Titles are still prepared; the cut is yours.
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
npx @michelj/context-guard install --with-hooks
|
|
39
|
-
```
|
|
28
|
+
The workbench chrome is Chinese or English. Use **中 / EN** in the top bar. Map titles, purposes, and memories stay in the language they were written.
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
Start or stop it manually when needed:
|
|
42
31
|
|
|
43
32
|
```bash
|
|
44
|
-
|
|
33
|
+
context-guard workbench --root /path/to/project
|
|
34
|
+
context-guard workbench --root /path/to/project --stop
|
|
45
35
|
```
|
|
46
36
|
|
|
47
|
-
|
|
37
|
+
### Overview
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
git clone git@github.com:Michel-Johnson/Context-Guard-Skill.git
|
|
51
|
-
cd Context-Guard-Skill
|
|
52
|
-
mkdir -p ~/.codex/skills/context-guard
|
|
53
|
-
rsync -a --delete skills/context-guard/ ~/.codex/skills/context-guard/
|
|
54
|
-
```
|
|
39
|
+
Root catalog: 4–8 module cards. Click a card to enter. Bugs stay in the right-hand list.
|
|
55
40
|
|
|
56
|
-
|
|
41
|
+

|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
~/.codex/skills/context-guard/SKILL.md
|
|
60
|
-
```
|
|
43
|
+
### Inside a module
|
|
61
44
|
|
|
62
|
-
|
|
45
|
+
Work units hang under the module. Hierarchy is parent–child solid curves.
|
|
63
46
|
|
|
64
|
-
|
|
47
|
+

|
|
65
48
|
|
|
66
|
-
|
|
67
|
-
<Codex project root>/.codex/context/
|
|
68
|
-
```
|
|
49
|
+
### Module relations
|
|
69
50
|
|
|
70
|
-
|
|
51
|
+
「关系」 highlights produce/consume partners and dims the rest. It does not enter the module.
|
|
71
52
|
|
|
72
|
-
|
|
73
|
-
- a chat/thread directory
|
|
74
|
-
- a temporary directory
|
|
75
|
-
- an SSH remote server path
|
|
53
|
+

|
|
76
54
|
|
|
77
|
-
|
|
55
|
+
### Session flow
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
57
|
+
Click a bug with an assigned session. The path from the root to that node lights up; current session beads run along the chain.
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
### Auth / inspect mode
|
|
62
|
+
|
|
63
|
+
「授权模式」 marks which slices this session’s agent may read. Grey cards are not authorized.
|
|
82
64
|
|
|
83
|
-
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
## Install
|
|
68
|
+
|
|
69
|
+
Install with npx. The installer detects Codex, Cursor, and Claude, then installs both the skill and lifecycle hooks while preserving existing configuration:
|
|
84
70
|
|
|
85
71
|
```bash
|
|
86
|
-
|
|
87
|
-
--root /path/to/project \
|
|
88
|
-
--title "Markdown preview rendering" \
|
|
89
|
-
--command-text "npm test"
|
|
72
|
+
npx @michelj/context-guard install
|
|
90
73
|
```
|
|
91
74
|
|
|
92
|
-
|
|
75
|
+
Or install globally and let the package configure detected clients automatically:
|
|
93
76
|
|
|
94
77
|
```bash
|
|
95
|
-
|
|
96
|
-
--root /path/to/project \
|
|
97
|
-
--title "GPU monitor button" \
|
|
98
|
-
--entry "Click the GPU monitor button" \
|
|
99
|
-
--exit-check "Open a monitoring page with a valid grafana_url" \
|
|
100
|
-
--command-text "npm test -- gpu-monitor"
|
|
78
|
+
npm install -g @michelj/context-guard --registry=https://registry.npmjs.org
|
|
101
79
|
```
|
|
102
80
|
|
|
103
|
-
|
|
81
|
+
Force installation for all three clients:
|
|
104
82
|
|
|
105
83
|
```bash
|
|
106
|
-
|
|
107
|
-
--root /path/to/project \
|
|
108
|
-
--chain-id FC-... \
|
|
109
|
-
--node-title "Backend returns monitor URL" \
|
|
110
|
-
--bad-case BC-... \
|
|
111
|
-
--check "grafana_url is non-empty and the frontend does not hang"
|
|
84
|
+
npx @michelj/context-guard install --platform all
|
|
112
85
|
```
|
|
113
86
|
|
|
114
|
-
|
|
87
|
+
Hooks are installed by default. To copy only the skill, opt out explicitly:
|
|
115
88
|
|
|
116
89
|
```bash
|
|
117
|
-
|
|
90
|
+
npx @michelj/context-guard install --no-hooks
|
|
118
91
|
```
|
|
119
92
|
|
|
120
|
-
|
|
93
|
+
Default skill paths are `~/.codex/skills/context-guard`, `~/.cursor/skills/context-guard`, and `~/.claude/skills/context-guard`. The installer backs up and merges existing hook/settings files. For Codex it also enables `[features] hooks = true` and migrates the deprecated `codex_hooks` alias.
|
|
94
|
+
|
|
95
|
+
Use from GitHub before the npm package is published:
|
|
121
96
|
|
|
122
97
|
```bash
|
|
123
|
-
|
|
98
|
+
npx github:Michel-Johnson/Context-Guard-Skill install
|
|
124
99
|
```
|
|
125
100
|
|
|
126
|
-
|
|
101
|
+
Manual install is also supported:
|
|
127
102
|
|
|
128
103
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
104
|
+
git clone git@github.com:Michel-Johnson/Context-Guard-Skill.git
|
|
105
|
+
cd Context-Guard-Skill
|
|
106
|
+
mkdir -p ~/.codex/skills/context-guard
|
|
107
|
+
rsync -a --delete \
|
|
108
|
+
SKILL.md README.md README.zh-CN.md agents prototype references scripts \
|
|
109
|
+
~/.codex/skills/context-guard/
|
|
134
110
|
```
|
|
135
111
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Ask Codex to maintain context:
|
|
112
|
+
After installation, the matching clients should discover:
|
|
139
113
|
|
|
140
114
|
```text
|
|
141
|
-
|
|
115
|
+
~/.codex/skills/context-guard/SKILL.md
|
|
116
|
+
~/.cursor/skills/context-guard/SKILL.md
|
|
117
|
+
~/.claude/skills/context-guard/SKILL.md
|
|
142
118
|
```
|
|
143
119
|
|
|
144
|
-
|
|
120
|
+
## Publishing
|
|
121
|
+
|
|
122
|
+
GitHub Releases are not part of this package's delivery path. Users install the skill from npm, so publishing is driven by a version tag:
|
|
123
|
+
|
|
124
|
+
1. Update `package.json` to the next stable version and merge that commit into `main`.
|
|
125
|
+
2. Create the matching `vX.Y.Z` tag on that commit.
|
|
126
|
+
3. Push the tag. `.github/workflows/npm-publish.yml` validates, packs, smoke-tests, and publishes that exact tarball to npm.
|
|
127
|
+
|
|
128
|
+
The workflow has no manual trigger. Pushing a matching version tag starts the complete publish pipeline automatically; the validated tarball is retained as a GitHub Actions artifact for 14 days. It reuses npm Trusted Publishing for `Michel-Johnson/Context-Guard-Skill`, workflow filename `npm-publish.yml`, with the `npm publish` action allowed. Local npm login is not required for Actions publishing. See the [release and recovery runbook](https://github.com/Michel-Johnson/Context-Guard-Skill/blob/main/docs/npm-release-runbook.md).
|
|
129
|
+
|
|
130
|
+
## Where Context Lives
|
|
131
|
+
|
|
132
|
+
Context stays under the opened local project, independent of the client:
|
|
145
133
|
|
|
146
134
|
```text
|
|
147
|
-
|
|
135
|
+
<project root>/.codex/context/
|
|
148
136
|
```
|
|
149
137
|
|
|
150
|
-
|
|
138
|
+
Do not write project context into:
|
|
151
139
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
- the skill install directory
|
|
141
|
+
- a chat/thread directory
|
|
142
|
+
- a temporary directory
|
|
143
|
+
- an SSH remote server path
|
|
155
144
|
|
|
156
|
-
|
|
145
|
+
Short user prompts that matter for future work are kept in:
|
|
157
146
|
|
|
158
|
-
```
|
|
159
|
-
|
|
147
|
+
```text
|
|
148
|
+
<project root>/.codex/context/user-messages.md
|
|
160
149
|
```
|
|
161
150
|
|
|
162
|
-
|
|
151
|
+
If the user provides a credential that future turns need, Context Guard records only a redacted pointer in public context. Raw durable secrets must stay local-only under:
|
|
163
152
|
|
|
164
|
-
```
|
|
165
|
-
|
|
153
|
+
```text
|
|
154
|
+
<project root>/.codex/context/private/
|
|
166
155
|
```
|
|
167
156
|
|
|
168
|
-
|
|
157
|
+
When running scripts manually, pass the project root:
|
|
169
158
|
|
|
170
159
|
```bash
|
|
171
|
-
|
|
160
|
+
python3 scripts/context_guard.py init --root /path/to/project
|
|
161
|
+
python3 scripts/context_guard.py set-language --root /path/to/project --language English
|
|
172
162
|
```
|
|
173
163
|
|
|
174
|
-
|
|
164
|
+
On the first session, if `record_language` is still `unset`, the hook instructs the agent to ask “中文 or English?” and persist the answer. Later sessions do not ask again. The `workbench` command starts the local server and returns its browser URL.
|
|
175
165
|
|
|
176
|
-
|
|
177
|
-
python3 ~/.codex/skills/context-guard/scripts/context_guard.py create-branch-task \
|
|
178
|
-
--root /path/to/project \
|
|
179
|
-
--title "branch task title" \
|
|
180
|
-
--branch "branch name" \
|
|
181
|
-
--parent-node NODE-YYYYMMDD-001
|
|
182
|
-
```
|
|
166
|
+
## Common Usage
|
|
183
167
|
|
|
184
|
-
|
|
168
|
+
```text
|
|
169
|
+
Use $context-guard. Four stores: sessions, bugs, tasks, map.
|
|
170
|
+
```
|
|
185
171
|
|
|
186
172
|
```bash
|
|
187
|
-
python3
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
--display-title "short human title" \
|
|
191
|
-
--user-request "what the user asked" \
|
|
192
|
-
--progress-summary "current progress" \
|
|
193
|
-
--method-summary "method used" \
|
|
194
|
-
--branch Main \
|
|
195
|
-
--level major \
|
|
196
|
-
--outcome "result"
|
|
173
|
+
python3 scripts/context_guard.py init --root /path/to/project
|
|
174
|
+
python3 scripts/context_guard.py set-language --root /path/to/project --language English
|
|
175
|
+
python3 scripts/context_guard.py workbench --root /path/to/project
|
|
197
176
|
```
|
|
198
177
|
|
|
178
|
+
Run `context-guard workbench --root /path/to/project` to see the map.
|
|
179
|
+
|
|
199
180
|
## Main Files
|
|
200
181
|
|
|
201
182
|
```text
|
|
202
183
|
.codex/context/
|
|
203
|
-
|--
|
|
204
|
-
|--
|
|
205
|
-
|--
|
|
206
|
-
|--
|
|
207
|
-
|--
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|--
|
|
212
|
-
|--
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
## Principles
|
|
218
|
-
|
|
219
|
-
- Record only meaningful progress, not every small action.
|
|
220
|
-
- Human-facing titles should read naturally, not like implementation logs.
|
|
221
|
-
- A bad case should help future Codex prevent recurrence.
|
|
222
|
-
- Test design belongs to humans; Codex can run approved checks or draft a proposal for confirmation.
|
|
223
|
-
- Prefer feature chains as the durable testing unit: one clear entry, one real workflow, ordered checkpoints, and multiple covered bad cases.
|
|
224
|
-
- Attach new bad cases to an existing feature-chain checkpoint first; propose a new chain only when no existing workflow matches.
|
|
225
|
-
- User-approved tests default to `every-dev-completion`; Codex may lower that cadence only when the user asks.
|
|
226
|
-
- Approved automated tests should go into `.codex/context/test-hub/registry.json` or `.codex/context/test-hub/feature-chains.json` and be scheduled through `dev-complete`.
|
|
227
|
-
- Keep the Test Hub simple: one registry, one `dev-complete` runner, one latest-result file, one read-only HTML status page, and a few management commands.
|
|
228
|
-
- Final Codex summaries should state the current Test Hub result: whether approved always-run tests all passed, failed, blocked, or do not exist.
|
|
229
|
-
- Verification should reuse existing commands, scripts, screenshots, or manual checks first.
|
|
230
|
-
- Do not create a new script for every bad case.
|
|
231
|
-
- For frontend or HTML changes, inspect the rendered page or screenshot before claiming success.
|
|
232
|
-
- For any new durable test case, draft a short task-case proposal and confirm with the user before making it active.
|
|
233
|
-
|
|
234
|
-
See [`skills/context-guard/SKILL.md`](skills/context-guard/SKILL.md) for the full behavior rules.
|
|
184
|
+
|-- FIND.md
|
|
185
|
+
|-- sessions.jsonl
|
|
186
|
+
|-- sessions/
|
|
187
|
+
|-- bugs-index.json
|
|
188
|
+
|-- bugs/ and fixes/
|
|
189
|
+
|-- tasks/
|
|
190
|
+
|-- map.json
|
|
191
|
+
|-- owns-index.json and cards/ # generated
|
|
192
|
+
|-- preferences.json
|
|
193
|
+
|-- user-messages.md
|
|
194
|
+
`-- private/ # gitignored
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
See [`SKILL.md`](SKILL.md) (one page) and `.codex/context/FIND.md`.
|