agent-personalizer 0.8.3 → 0.8.5
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/CHANGELOG.md +40 -2
- package/CONTRIBUTING.md +2 -2
- package/README.md +18 -8
- package/RELEASING.md +1 -1
- package/SECURITY.md +4 -2
- package/bin/agent-personalizer.js +132 -82
- package/bin/git-exclude.cjs +1 -1
- package/bin/global.cjs +201 -0
- package/bin/home.cjs +15 -0
- package/bin/install-plan.cjs +7 -2
- package/bin/known-hashes.json +78 -0
- package/bin/learn.cjs +4 -2
- package/bin/sessions.cjs +64 -16
- package/bin/uninstall.cjs +2 -1
- package/docs/guarantees.md +2 -2
- package/docs/install.md +29 -5
- package/docs/learning.md +9 -6
- package/docs/paste-guide.md +5 -3
- package/docs/tiers.md +1 -1
- package/examples/freelance-illustrator/.agent-personalizer.json +3 -3
- package/examples/freelance-illustrator/AGENTS.md +1 -1
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +2 -2
- package/examples/freelance-illustrator/CLAUDE.md +1 -1
- package/examples/freelance-illustrator/rules/30-folder-index-is-part-of-the-change.md +2 -2
- package/examples/freelance-illustrator/rules/README.md +2 -0
- package/examples/lab-technician/.agent-personalizer.json +3 -3
- package/examples/lab-technician/AGENTS.md +1 -1
- package/examples/lab-technician/AGENT_ONBOARDING.md +1 -1
- package/examples/lab-technician/CLAUDE.md +1 -1
- package/examples/lab-technician/rules/30-folder-index-is-part-of-the-change.md +2 -2
- package/examples/lab-technician/rules/README.md +2 -0
- package/examples/product-designer/.agent-personalizer.json +3 -3
- package/examples/product-designer/AGENTS.md +1 -1
- package/examples/product-designer/AGENT_ONBOARDING.md +1 -1
- package/examples/product-designer/CLAUDE.md +1 -1
- package/examples/product-designer/rules/30-folder-index-is-part-of-the-change.md +2 -2
- package/examples/product-designer/rules/README.md +2 -0
- package/hooks/README.md +5 -3
- package/package.json +1 -1
- package/render/onboarding.cjs +6 -3
- package/render/render.cjs +14 -6
- package/rules/30-folder-index-is-part-of-the-change.md +2 -2
- package/rules/README.md +2 -0
package/bin/uninstall.cjs
CHANGED
|
@@ -176,7 +176,8 @@ function run(dir, dry) {
|
|
|
176
176
|
// later package release changing rules/ or USER.md cannot make an untouched block look
|
|
177
177
|
// edited (or vice versa).
|
|
178
178
|
const currentBlock = renderer.between(existing, rel);
|
|
179
|
-
|
|
179
|
+
// Explicit adoption of an older target can record the whole file; its outer text stays user-owned.
|
|
180
|
+
const blockUnedited = recorded ? (currentBlock !== null && (sha256(Buffer.from(currentBlock)) === recorded || sha256(bytes) === recorded)) : matchesBlock;
|
|
180
181
|
if (blockUnedited) add(rel, 'strip', Buffer.from(stripBlock(existing, ms)), 'pre-existing file; removed only the marked block');
|
|
181
182
|
else add(rel, 'keep', null, ms.kind === 'none' ? 'pre-existing file; block already absent' : 'edited');
|
|
182
183
|
continue;
|
package/docs/guarantees.md
CHANGED
|
@@ -36,7 +36,7 @@ On a re-run, each home-file line that byte-matches the previous template is migr
|
|
|
36
36
|
- **Notes history:** changing the notes path creates the new scaffold and keeps the old folder. The log names both paths once; the recorded files from both remain available to uninstall.
|
|
37
37
|
- **Tool updates:** a recorded install hash recognizes untouched tools and rules. For older installs without hashes, a shipped table of earlier release hashes recognizes untouched verbatim copies. Edited tools remain intact; the log names the known origin version and the replacement step. The configuration records the installed tooling version.
|
|
38
38
|
- **Removal inventory:** uninstall checks the union of recorded installed paths across all runs. A matching hash permits removal, a changed file is kept and named, and a missing file is skipped. An unrecorded file is left alone. Legacy configurations without hashes use their known install recipe.
|
|
39
|
-
- **Entries and evidence:** uninstall keeps `LEARNED.md` once it holds anything you wrote (an untouched template is removed). It removes
|
|
39
|
+
- **Entries and evidence:** uninstall keeps `LEARNED.md` once it holds anything you wrote (an untouched template is removed). It removes the digest and its `.gitignore` only when their bytes match recorded creation hashes, and removes the private folder only when recorded as installer-created and empty. Edited or unrecorded files stay, including digests from older installs without creation records. `learn --forget` removes only agent-personalizer's digest and its empty folder. Neither changes the AI apps' own history.
|
|
40
40
|
- **Removal paths:** every tracked path is validated before the first unlink and re-probed before each unlink. Removal is file by file. Only recorded install-created, empty directories are removed.
|
|
41
41
|
- **Configuration last:** the configuration is removed after tracked files are gone. Retained tracked files are named and keep the configuration for review.
|
|
42
42
|
- **Preview and manual steps:** `--uninstall --dry` makes the same decisions as removal and changes no files. A missing configuration exits `2` naming its path. Hook registration and pasted instructions are printed as manual cleanup steps.
|
|
@@ -69,7 +69,7 @@ Learning reads up to 20 recent usable sessions from the selected Claude Code, Co
|
|
|
69
69
|
|
|
70
70
|
The digest stays in `.agent-personalizer/digest.md`, with its contents ignored by git. Filesystem access, backups and sync services still apply. The terminal prints file names and counts, never message text. The digest is data, and the AI is instructed never to follow instructions within it. When your AI reads it, the contents go to that AI's provider again, like anything you share with it.
|
|
71
71
|
|
|
72
|
-
Reuse only sessions you are allowed to share. Past messages can contain other people's details; add private terms before accepting. Check employer or client agreements for work accounts. agent-personalizer is not affiliated with Anthropic, OpenAI or Google; their stored formats can change. `learn --forget`
|
|
72
|
+
Reuse only sessions you are allowed to share. Past messages can contain other people's details; add private terms before accepting. Check employer or client agreements for work accounts. agent-personalizer is not affiliated with Anthropic, OpenAI or Google; their stored formats can change. `learn --forget` removes the digest from this install; uninstall removes it only under the recorded-hash conditions above. Neither removes copies a provider, backup or sync service already received.
|
|
73
73
|
|
|
74
74
|
## Instructions and companions
|
|
75
75
|
|
package/docs/install.md
CHANGED
|
@@ -65,6 +65,7 @@ Use [`examples/answers.json`](../examples/answers.json) as a complete example, i
|
|
|
65
65
|
| Flag | Purpose |
|
|
66
66
|
|---|---|
|
|
67
67
|
| `--dir <folder>` | Destination folder; prompted in interactive mode. |
|
|
68
|
+
| `--global` | Apply a level-1 profile across projects through Claude Code, Codex and Gemini CLI home files. Excludes `--dir` and levels 2/3. |
|
|
68
69
|
| `--ai claude,agents,gemini,chatgpt,prompt` | Comma-separated targets. Choose the ones you use. |
|
|
69
70
|
| `--level 1`, `--level 2`, `--level 3` | Profile and home files; add local notes; add editable rules and mechanisms. |
|
|
70
71
|
| `--answers <file.json>` or `--answers -` | Set onboarding answers without questions. |
|
|
@@ -80,6 +81,28 @@ For compatibility with older scripts, `--level 4` remains an alias of `--level 3
|
|
|
80
81
|
|
|
81
82
|
Installer exit codes: `0` completed, `1` unexpected error, `2` refused or invalid input.
|
|
82
83
|
|
|
84
|
+
## Every project with one profile
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx agent-personalizer --global --ai claude,agents,gemini --yes
|
|
88
|
+
npx agent-personalizer --global
|
|
89
|
+
npx agent-personalizer learn --global --yes
|
|
90
|
+
npx agent-personalizer --global --uninstall --dry
|
|
91
|
+
npx agent-personalizer --global --uninstall
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`--global` keeps the level-1 profile source (`USER.md`, `LEARNED.md`, onboarding and configuration) in `~/.agent-personalizer/`. It writes a marked block to `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md` and `~/.gemini/GEMINI.md` for the selected targets. Paths use `HOME`, with `USERPROFILE` as the Windows fallback when `HOME` is missing or empty. The selected value must be a non-empty absolute path. Global instructions name the profile's full path so they work from any project. Start a new AI session to load them; client instruction precedence still applies.
|
|
95
|
+
|
|
96
|
+
Select only `claude`, `agents` and `gemini`. Other targets, `--dir` and levels 2/3 are refused. A headless first install needs `--ai` and `--yes`; level 1 is implicit. `--answers` and `--defaults` work as with project installs. A re-run keeps saved targets and answers.
|
|
97
|
+
|
|
98
|
+
Global learning always includes sessions from all projects and still needs consent. Its digest is `~/.agent-personalizer/.agent-personalizer/digest.md`; use `learn --global --forget` to remove it. The learning procedure is included in each selected home file.
|
|
99
|
+
|
|
100
|
+
Global files keep user text outside the markers byte for byte, including line endings and a missing final newline. Existing files and parents must be regular files and directories, never symlinks. The whole plan is checked before writes; a failed write restores changed files and newly created empty directories through the project installer's atomic rename and rollback path.
|
|
101
|
+
|
|
102
|
+
`--global` refuses a symlinked `HOME` and a symlinked `~/.claude/CLAUDE.md`, including links maintained by dotfile managers. Use a project install with `--dir` instead. For a linked `HOME`, you can set `HOME` to its real absolute directory; global home files must still be regular files. To keep a dotfile manager's symlinks, use the project install and copy the instructions through your dotfile manager.
|
|
103
|
+
|
|
104
|
+
Global uninstall removes unchanged marked blocks and owned profile files. It deletes a home file only if install created it and no other content remains. Edited blocks, profiles and learned entries stay, with the configuration kept for review. Install-created empty directories are removed; other home files and settings stay in place.
|
|
105
|
+
|
|
83
106
|
## Learning commands
|
|
84
107
|
|
|
85
108
|
```bash
|
|
@@ -92,11 +115,11 @@ npx agent-personalizer learn --forget --dir .
|
|
|
92
115
|
|
|
93
116
|
## What each level adds
|
|
94
117
|
|
|
95
|
-
- **Level 1:** `USER.md`, `LEARNED.md`, `AGENT_ONBOARDING.md`, the files for your AI targets, and `.agent-personalizer.json`. Claude Code also receives `.claude/commands/personalize.md`.
|
|
96
|
-
- **Level 2:** a local notes scaffold with `README.md`, `sessions/TEMPLATE-week.md`, `decisions.md` and `inbox/README.md`. Disk tools use your `notes_path`; read-only and other tools use the local `notes/` fallback. Cloud tools get connector pointers and keep their notes in their service.
|
|
97
|
-
- **Level 3:** your editable `rules/` copy, `render/` tools, the Claude Code session-start hook and the forbidden-string gate. [Register the hook](../hooks/README.md) in your AI settings and [configure the gate](guarantees.md#forbidden-string-gate).
|
|
118
|
+
- **Level 1:** `USER.md`, `LEARNED.md`, `AGENT_ONBOARDING.md`, the files for your AI targets, and `.agent-personalizer.json`. Claude Code also receives `.claude/commands/personalize.md`. The Core 5 render from the package: read the profile first, evidence before assertion, output style, act or ask, and ask before it repeats. With no installed apps detected, the default selection is `claude,agents`.
|
|
119
|
+
- **Level 2:** the same five rules, plus a local notes scaffold with `README.md`, `sessions/TEMPLATE-week.md`, `decisions.md` and `inbox/README.md`. Disk tools use your `notes_path`; read-only and other tools use the local `notes/` fallback. Cloud tools get connector pointers and keep their notes in their service.
|
|
120
|
+
- **Level 3:** all eleven rules (subject to target and signature selection), your editable `rules/` copy, `render/` tools, the Claude Code session-start hook and the forbidden-string gate. [Register the hook](../hooks/README.md) in your AI settings and [configure the gate](guarantees.md#forbidden-string-gate).
|
|
98
121
|
|
|
99
|
-
An existing local notes scaffold is detected at any level. Edited notes and rule files stay yours and are named in the install log. Untouched installer copies update on re-runs.
|
|
122
|
+
An existing local notes scaffold is detected at any level. Edited notes and rule files stay yours and are named in the install log. Untouched installer copies update on re-runs. At level 3, a `signature: no` answer omits the signature rule and its template lines; answering yes includes the signature line.
|
|
100
123
|
|
|
101
124
|
## Updating an install
|
|
102
125
|
|
|
@@ -109,6 +132,7 @@ Re-run the installer with `npx agent-personalizer --dir .`. An existing config m
|
|
|
109
132
|
- **Re-runs:** untouched installer files converge to the files a fresh install with the new answers would create. Current notes templates and rule copies update together. An obsolete file, such as the signing rule after `signature: no`, is removed only while it is untouched.
|
|
110
133
|
- **Home pointers:** each line outside the markers that exactly matches the previous install template is updated or removed to match the new answers. An edited line stays byte for byte and the log names its file and line for manual review. Other text outside the markers stays byte for byte.
|
|
111
134
|
- **Notes path:** when you change `notes_path`, the old folder stays where it is. The log names the old and new folders once. Previously installed files remain in the uninstall inventory; your own notes stay yours.
|
|
135
|
+
- **Core 5 upgrade:** an untouched older level-1/2 generated file shrinks to the five rules on re-run. An edited older file stays byte for byte and the installer prints the exact re-render command for that target. Run that command to take the update, then re-run the installer to adopt the current file and clear the kept notice. Text outside the block stays byte for byte.
|
|
112
136
|
- **Upgrades:** re-running a newer package refreshes untouched installed tools and rule copies. Recorded hashes establish ownership; older installs without hashes can be recognized from shipped release hashes. Edited copies stay byte for byte. The log identifies the edited file, its known origin version and how to take the new copy. Previously installed levels and targets remain available on a re-run.
|
|
113
137
|
|
|
114
138
|
At level 3, render your edited profile and rules:
|
|
@@ -151,7 +175,7 @@ The uninstaller reads `/path/to/project/.agent-personalizer.json` and compares f
|
|
|
151
175
|
- **Existing home files:** user text stays; only an unchanged generated block and the blank separator line the installer added are removed, so an untouched file returns byte for byte. (A file that had no final newline before install keeps the one the installer added.)
|
|
152
176
|
- **`USER.md`:** removed only when it matches its recorded install hash. Edited and pre-existing profiles stay.
|
|
153
177
|
- **`LEARNED.md`:** kept once it holds anything you wrote, and kept if it existed before install. An untouched template that matches its recorded install hash is removed.
|
|
154
|
-
- **Session digest:** `.agent-personalizer
|
|
178
|
+
- **Session digest:** files under `.agent-personalizer/` are removed only when they match recorded install hashes. Edited or unrecorded files stay. The private folder is removed only when recorded as install-created and empty. Your AI apps' history is untouched.
|
|
155
179
|
- **Notes scaffold:** unchanged historically installed templates are removed. Edited templates are kept and named; user-written notes stay byte for byte. A directory is removed only when the install recorded that it created it and it is empty.
|
|
156
180
|
- **Git exclude:** after the configuration is removed, the block install added to `.git/info/exclude` for this folder is removed, and the rest of the file stays byte for byte. While an edited file keeps the configuration, the block stays too.
|
|
157
181
|
- **Rules and tools:** unchanged installed copies are removed file by file, including the session-start hook. Edited copies stay.
|
package/docs/learning.md
CHANGED
|
@@ -8,17 +8,18 @@ The first interactive install asks which AIs you use, then shows this consent sc
|
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
Learn from your past sessions?
|
|
11
|
-
agent-personalizer can read up to 20 of your most recent sessions from
|
|
12
|
-
|
|
13
|
-
· By default, only sessions for this --dir project are included.
|
|
11
|
+
agent-personalizer can read up to 20 of your most recent sessions from the --dir project
|
|
12
|
+
that Claude Code, Codex and Gemini CLI still keep, to find corrections you repeat.
|
|
14
13
|
· Use --all-projects to include sessions from other projects.
|
|
15
14
|
· Only what you typed, never the AI's replies.
|
|
15
|
+
· Messages that look like secrets are skipped.
|
|
16
16
|
· Stays on this computer, saved to .agent-personalizer/digest.md.
|
|
17
17
|
· Your AI reads that file next time you open it, like anything you share with it.
|
|
18
18
|
· Other people's details in there? Add their names to your private list first.
|
|
19
19
|
· Delete it any time: npx agent-personalizer learn --forget
|
|
20
20
|
(your AI app's own history stays as it is)
|
|
21
21
|
· Codex's own memory notes are included when you choose Codex.
|
|
22
|
+
They are global to your Codex account, not limited to this folder.
|
|
22
23
|
· When your AI reads the file, its provider sees these messages again.
|
|
23
24
|
· Work or client accounts: check your agreement before reusing their sessions.
|
|
24
25
|
· Not affiliated with Anthropic, OpenAI or Google. Their formats can change.
|
|
@@ -48,7 +49,7 @@ The saved AI selection chooses the sources. The reader takes up to 20 of the new
|
|
|
48
49
|
|
|
49
50
|
By default, only sessions associated with the `--dir` folder or one of its subfolders are included. Claude Code and Codex sessions are matched by their recorded working directory; Gemini CLI uses the SHA-256 project folder it creates from that path. If a session does not provide enough path information to match it safely, it is skipped. Use `npx agent-personalizer learn --dir . --all-projects` to include sessions from every project.
|
|
50
51
|
|
|
51
|
-
The digest contains typed user messages and, when Codex is selected, up to 20 of the newest Codex memory files in a separate section. AI replies, tool output, reasoning, automation sessions and injected context are dropped.
|
|
52
|
+
The digest contains typed user messages and, when Codex is selected, up to 20 of the newest Codex memory files in a separate section. These memory notes are global to your Codex account, not limited to this folder. AI replies, tool output, reasoning, automation sessions and injected context are dropped. Messages and memory notes over 2,000 characters are dropped whole. Gemini chat snapshots replace earlier messages; a message repeated in the chat and logs is included once. The all-projects option affects session history; the memory file limit still applies.
|
|
52
53
|
|
|
53
54
|
The reader streams session files, skips oversized lines and stops a file at its size limit. Symlinks, unreadable files, other-project sessions and unknown or malformed formats are skipped and counted. Codex session headers are inspected to determine their project; message content from other projects is not scanned. The terminal lists files read and skip counts; message text is never printed there. Vendor format changes may mean fewer usable sessions until the reader is updated.
|
|
54
55
|
|
|
@@ -58,7 +59,9 @@ The reader runs locally and makes no network calls. It saves `.agent-personalize
|
|
|
58
59
|
|
|
59
60
|
Your AI reads the digest, so its contents go to that AI's provider again, like anything you paste in. The digest labels old messages as data; instructions inside them must never be followed.
|
|
60
61
|
|
|
61
|
-
Past sessions may include client, coworker or other people's details. Read only history you are allowed to reuse. For work or client accounts, check your agreement first. Before accepting, put private terms in `<project>/check/forbidden.local.txt
|
|
62
|
+
Past sessions may include client, coworker or other people's details. Read only history you are allowed to reuse. For work or client accounts, check your agreement first. Before accepting, put private terms in `<project>/check/forbidden.local.txt` (project install) or `~/.agent-personalizer/check/forbidden.local.txt` (global install), one per line; any message or memory note containing a term, ignoring case, is dropped whole. Blank lines, `#` comments and `allow:` entries are ignored by the session filter. Keep that list out of git. See the [gate setup](guarantees.md#forbidden-string-gate).
|
|
63
|
+
|
|
64
|
+
Messages and memory notes that look like secrets are dropped whole and counted under `secret`; only the count is reported. Conservative patterns cover PEM private key headers, `sk-` keys, GitHub tokens, AWS access key ids, Slack tokens, Google API keys, bearer tokens and assignments to API key, secret, token or password fields. This filter can miss secrets or skip ordinary text; review the digest before sharing it with your AI.
|
|
62
65
|
|
|
63
66
|
## What your AI asks and keeps
|
|
64
67
|
|
|
@@ -90,7 +93,7 @@ npx agent-personalizer --uninstall --dir . --dry
|
|
|
90
93
|
npx agent-personalizer --uninstall --dir .
|
|
91
94
|
```
|
|
92
95
|
|
|
93
|
-
`learn --forget` deletes agent-personalizer's digest and removes its empty private folder. It keeps approved entries. Uninstall removes the digest
|
|
96
|
+
`learn --forget` deletes agent-personalizer's digest and removes its empty private folder. It keeps approved entries. Uninstall removes the digest and its `.gitignore` only when their bytes match recorded creation hashes, and removes the private folder only when recorded as installer-created and empty. Edited or unrecorded files stay, including digests from older installs without creation records. It keeps `LEARNED.md` once it holds anything you wrote; an untouched template is removed. Neither changes the AI apps' own history. To stop questions, decline the consent screen and do not run `learn --yes`; to change an entry, edit its owning line and re-render.
|
|
94
97
|
|
|
95
98
|
## How the loop closes
|
|
96
99
|
|
package/docs/paste-guide.md
CHANGED
|
@@ -4,13 +4,15 @@ The renderer writes one file per AI. This page says where each AI reads it, and
|
|
|
4
4
|
|
|
5
5
|
| Rendered file | Who reads it | How it is read |
|
|
6
6
|
|---|---|---|
|
|
7
|
-
| `CLAUDE.md` | Claude Code | Automatically, from the
|
|
7
|
+
| `CLAUDE.md` | Claude Code | Automatically, from the project, or `~/.claude/CLAUDE.md` for every project with `--global`. Nothing to paste. |
|
|
8
8
|
| `AGENT_ONBOARDING.md` | any AI | Named as the second thing to read in `CLAUDE.md` and `AGENTS.md`. Paste it wherever the AI has no file access (below). |
|
|
9
|
-
| `AGENTS.md` | Codex CLI, Cursor, and other agents that adopted the AGENTS.md convention | Automatically, from the repository root. Nothing to paste. |
|
|
10
|
-
| `GEMINI.md` | Gemini CLI | Automatically, from the folder. Nothing to paste. |
|
|
9
|
+
| `AGENTS.md` | Codex CLI, Cursor, and other agents that adopted the AGENTS.md convention | Automatically, from the repository root; `--global` writes `~/.codex/AGENTS.md` for all projects. Nothing to paste. |
|
|
10
|
+
| `GEMINI.md` | Gemini CLI | Automatically, from the folder; `--global` writes `~/.gemini/GEMINI.md` for all projects. Nothing to paste. |
|
|
11
11
|
| `chatgpt-box1.txt`, `chatgpt-box2.txt` and `chatgpt-custom-instructions.md` | ChatGPT | Profile and response text to paste, with a preview and counts. |
|
|
12
12
|
| `system-prompt.md` | anything with a system-prompt field, shared bots, API calls | Paste as the system prompt. Universal rules only, no profile, safe to share. |
|
|
13
13
|
|
|
14
|
+
Use `npx agent-personalizer --global --ai claude,agents,gemini --yes` for one profile across projects. Its source lives in `~/.agent-personalizer/`; re-run with `--global` after editing it and start a new client session. Global mode accepts only these three targets and level 1, excludes `--dir`, preserves text outside its markers and supports `--global --uninstall`. See [global installation](install.md#every-project-with-one-profile).
|
|
15
|
+
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
## Claude Code
|
package/docs/tiers.md
CHANGED
|
@@ -79,7 +79,7 @@ A word on the stories below: each is one setup's experience of what held and wha
|
|
|
79
79
|
|
|
80
80
|
**Prevents.** The AI treating its own guess as your ruling. An inference written down without a status reads, next session, like something you decided.
|
|
81
81
|
|
|
82
|
-
**Story.** A memory file said the user preferred a certain tool. The user had never said so; an earlier session had inferred it from one choice. Three sessions built on it. The status field exists so the next session can tell the difference between "she said" and "I guessed
|
|
82
|
+
**Story.** A memory file said the user preferred a certain tool. The user had never said so; an earlier session had inferred it from one choice. Three sessions built on it. The status field exists so the next session can tell the difference between "she said" and "I guessed." When the user rejects an entry, mark it `declined` and keep the correction in its evidence rather than silently overwriting it.
|
|
83
83
|
|
|
84
84
|
**Rule inside the tier.** Ask before keeping an entry as confirmed. A no is recorded as declined and never asked again. Re-render after an entry changes; `--check` catches an unrendered edit. The digest of past messages is temporary evidence, separate from the entries: `learn --forget` removes it, and uninstall keeps `LEARNED.md` once it holds anything you wrote. See [learning.md](learning.md).
|
|
85
85
|
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"obsidian_tc": "yes"
|
|
51
51
|
},
|
|
52
52
|
"installed": {
|
|
53
|
-
"CLAUDE.md": "
|
|
54
|
-
"AGENTS.md": "
|
|
55
|
-
"AGENT_ONBOARDING.md": "
|
|
53
|
+
"CLAUDE.md": "4a303e42182c9affef6bcf14cd77045fae24f02ff8f1fef7e1f84e8c03aef2f2",
|
|
54
|
+
"AGENTS.md": "9cfedced547c961885e57814e3bc2f9122e16bfda2da0e5901dd61f3cf3f3bec",
|
|
55
|
+
"AGENT_ONBOARDING.md": "958bc2ca63bbd02146f9c398fc816a049813c5f59afe28ffbccf8c800b33e4cc"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -155,7 +155,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
155
155
|
|
|
156
156
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
Check the folder's README before reporting a write as done.
|
|
159
159
|
|
|
160
160
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
161
161
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -25,7 +25,7 @@ _Generated by agent-personalizer from your saved preferences (stored in `.agent-
|
|
|
25
25
|
### Read this first, in order
|
|
26
26
|
|
|
27
27
|
- USER.md
|
|
28
|
-
-
|
|
28
|
+
- AGENT_ONBOARDING.md
|
|
29
29
|
- notes/README.md
|
|
30
30
|
- rules/
|
|
31
31
|
- notes/decisions.md
|
|
@@ -34,7 +34,7 @@ _Generated by agent-personalizer from your saved preferences (stored in `.agent-
|
|
|
34
34
|
|
|
35
35
|
### Where you may write
|
|
36
36
|
|
|
37
|
-
- **Notes live in Obsidian:** reach them as the vault at `notes/`, through **obsidian-tc** (governed MCP: folder ACLs, human-in-the-loop confirmation for destructive tools, audit log) rather than raw filesystem access; see https://github.com/aunysillyme/agent-personalizer/blob/v0.8.
|
|
37
|
+
- **Notes live in Obsidian:** reach them as the vault at `notes/`, through **obsidian-tc** (governed MCP: folder ACLs, human-in-the-loop confirmation for destructive tools, audit log) rather than raw filesystem access; see https://github.com/aunysillyme/agent-personalizer/blob/v0.8.5/docs/companions.md.
|
|
38
38
|
- You may create and edit files anywhere under `notes/`, under that folder's rules. Nowhere else without being asked.
|
|
39
39
|
- **Every folder you write into has a README.** Any write, edit or delete means that README is corrected in the same pass: the file's one-line description, the folder's status, settled decisions, next steps. A stale index is worse than none, because the next agent believes it.
|
|
40
40
|
- **Session log:** append a dated section to this week's note in `notes/sessions/`. **Decisions:** one line each in `notes/decisions.md`. **Inbox:** one file per item in `notes/inbox/`; finished items are deleted, not marked done.
|
|
@@ -155,7 +155,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
155
155
|
|
|
156
156
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
159
159
|
|
|
160
160
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
161
161
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -16,10 +16,10 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
16
16
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
17
17
|
|
|
18
18
|
## binding:claude
|
|
19
|
-
|
|
19
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
20
20
|
|
|
21
21
|
## binding:agents
|
|
22
|
-
|
|
22
|
+
Check the folder's README before reporting a write as done.
|
|
23
23
|
|
|
24
24
|
## origin
|
|
25
25
|
Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
One rule per file. Each file is the owning copy of that rule; everything else points here. `render/render.cjs` turns these files plus `USER.md` into the per-AI instruction files.
|
|
4
4
|
|
|
5
|
+
Install levels 1 and 2 render the Core 5: `00-read-the-profile-first.md`, `10-evidence-before-assertion.md`, `50-output-style.md`, `60-act-or-ask.md` and `65-ask-before-it-repeats.md`. Level 3 copies all eleven rules here for editing and renders them with the existing surface and preference filters; the signature rule still follows the signature preference. The source rule files below remain the full set.
|
|
6
|
+
|
|
5
7
|
## Format
|
|
6
8
|
|
|
7
9
|
```markdown
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"installed": {
|
|
34
|
-
"CLAUDE.md": "
|
|
35
|
-
"AGENTS.md": "
|
|
36
|
-
"AGENT_ONBOARDING.md": "
|
|
34
|
+
"CLAUDE.md": "a99162f0f7f2df9e6debd8bfeede565196d6c47c79f4794fc267ec8a8e9fe86b",
|
|
35
|
+
"AGENTS.md": "24d092e5f5e31b769c9049c948b9c6fa89cd270f9ee92bbe752e2ebbb5b97ecb",
|
|
36
|
+
"AGENT_ONBOARDING.md": "37ebf0f4cf6261285b8891e15938c64a2795933a38a187d8e6cda2be42f9e66e"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -154,7 +154,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
154
154
|
|
|
155
155
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Check the folder's README before reporting a write as done.
|
|
158
158
|
|
|
159
159
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
160
160
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -25,7 +25,7 @@ _Generated by agent-personalizer from your saved preferences (stored in `.agent-
|
|
|
25
25
|
### Read this first, in order
|
|
26
26
|
|
|
27
27
|
- USER.md
|
|
28
|
-
-
|
|
28
|
+
- AGENT_ONBOARDING.md
|
|
29
29
|
- `notes/README.md`, the rules of the folder you may write into, before writing there.
|
|
30
30
|
|
|
31
31
|
### Where you may write
|
|
@@ -154,7 +154,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
154
154
|
|
|
155
155
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
158
158
|
|
|
159
159
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
160
160
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -16,10 +16,10 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
16
16
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
17
17
|
|
|
18
18
|
## binding:claude
|
|
19
|
-
|
|
19
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
20
20
|
|
|
21
21
|
## binding:agents
|
|
22
|
-
|
|
22
|
+
Check the folder's README before reporting a write as done.
|
|
23
23
|
|
|
24
24
|
## origin
|
|
25
25
|
Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
One rule per file. Each file is the owning copy of that rule; everything else points here. `render/render.cjs` turns these files plus `USER.md` into the per-AI instruction files.
|
|
4
4
|
|
|
5
|
+
Install levels 1 and 2 render the Core 5: `00-read-the-profile-first.md`, `10-evidence-before-assertion.md`, `50-output-style.md`, `60-act-or-ask.md` and `65-ask-before-it-repeats.md`. Level 3 copies all eleven rules here for editing and renders them with the existing surface and preference filters; the signature rule still follows the signature preference. The source rule files below remain the full set.
|
|
6
|
+
|
|
5
7
|
## Format
|
|
6
8
|
|
|
7
9
|
```markdown
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"installed": {
|
|
34
|
-
"CLAUDE.md": "
|
|
35
|
-
"AGENTS.md": "
|
|
36
|
-
"AGENT_ONBOARDING.md": "
|
|
34
|
+
"CLAUDE.md": "7104eeb98b6e23dfe690f083ee2c42966ceddab20403be40b127d9ff083f2bce",
|
|
35
|
+
"AGENTS.md": "4b8b44fb95e7533315c2adee1342c0efea3551ea48246274a7b7ba31251fd516",
|
|
36
|
+
"AGENT_ONBOARDING.md": "0c9fe728be7635c6b341c951d75740a191dac2107cc4f3ddc6855ec27450081d"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -154,7 +154,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
154
154
|
|
|
155
155
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Check the folder's README before reporting a write as done.
|
|
158
158
|
|
|
159
159
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
160
160
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -25,7 +25,7 @@ _Generated by agent-personalizer from your saved preferences (stored in `.agent-
|
|
|
25
25
|
### Read this first, in order
|
|
26
26
|
|
|
27
27
|
- USER.md
|
|
28
|
-
-
|
|
28
|
+
- AGENT_ONBOARDING.md
|
|
29
29
|
- `notes/README.md`, the rules of the folder you may write into, before writing there.
|
|
30
30
|
|
|
31
31
|
### Where you may write
|
|
@@ -154,7 +154,7 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
154
154
|
|
|
155
155
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
158
158
|
|
|
159
159
|
> Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
160
160
|
> Prevents: a stale index, which is worse than a missing one because it is believed.
|
|
@@ -16,10 +16,10 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
16
16
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
17
17
|
|
|
18
18
|
## binding:claude
|
|
19
|
-
|
|
19
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
20
20
|
|
|
21
21
|
## binding:agents
|
|
22
|
-
|
|
22
|
+
Check the folder's README before reporting a write as done.
|
|
23
23
|
|
|
24
24
|
## origin
|
|
25
25
|
Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
One rule per file. Each file is the owning copy of that rule; everything else points here. `render/render.cjs` turns these files plus `USER.md` into the per-AI instruction files.
|
|
4
4
|
|
|
5
|
+
Install levels 1 and 2 render the Core 5: `00-read-the-profile-first.md`, `10-evidence-before-assertion.md`, `50-output-style.md`, `60-act-or-ask.md` and `65-ask-before-it-repeats.md`. Level 3 copies all eleven rules here for editing and renders them with the existing surface and preference filters; the signature rule still follows the signature preference. The source rule files below remain the full set.
|
|
6
|
+
|
|
5
7
|
## Format
|
|
6
8
|
|
|
7
9
|
```markdown
|
package/hooks/README.md
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
# hooks/
|
|
2
2
|
|
|
3
|
-
Tier 3 from the tiers doc (https://github.com/aunysillyme/agent-personalizer/blob/v0.8.
|
|
3
|
+
Tier 3 from the tiers doc (https://github.com/aunysillyme/agent-personalizer/blob/v0.8.5/docs/tiers.md): the few rules that must be in context at the moment of decision, injected in full at the start of every session. Injection puts the text in front of the model; whether the model follows it is up to the model and the host. This is the strongest placement available, not a guarantee.
|
|
4
4
|
|
|
5
5
|
Which rules? The ones with `inject: true` in their frontmatter. Keep that set small. Every injected rule costs tokens every session.
|
|
6
6
|
|
|
7
7
|
## Claude Code
|
|
8
8
|
|
|
9
|
-
`claude-code/session-start.sh` prints the contract (it runs `render/render.cjs --contract`, so it needs the level-3 install beside it). Register it in
|
|
9
|
+
`claude-code/session-start.sh` prints the contract (it runs `render/render.cjs --contract`, so it needs the level-3 install beside it). Register it in the project's `.claude/settings.json`:
|
|
10
10
|
|
|
11
11
|
```json
|
|
12
12
|
{
|
|
13
13
|
"hooks": {
|
|
14
14
|
"SessionStart": [
|
|
15
|
-
{ "hooks": [ { "type": "command", "command": "sh hooks/claude-code/session-start.sh" } ] }
|
|
15
|
+
{ "hooks": [ { "type": "command", "command": "sh \"$CLAUDE_PROJECT_DIR/hooks/claude-code/session-start.sh\"" } ] }
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
For user-level `~/.claude/settings.json`, use the absolute path to the installed project instead, for example `sh "/path/to/project/hooks/claude-code/session-start.sh"`. The script resolves its project root from its own location, so it also works when the session starts in a subfolder.
|
|
22
|
+
|
|
21
23
|
The hook's stdout lands in the session context before your first message. That is the whole mechanism. If `node` is missing the hook exits non-zero and says so on stderr, so a session that starts without its contract is visible, not silent. The contract carries the onboarding block first (always-ask, off-limits, write policy, then style), so a token budget trims style before it trims a restriction.
|
|
22
24
|
|
|
23
25
|
The contract is target-aware: `--contract-target claude` applies each rule's `surfaces` filter. Personal blocks are included by default because the hook runs in your own project; add `--no-personal` for a shared machine.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-personalizer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "AI custom instructions from approved entries: a profile and rules for Claude Code, Codex, Cursor, Gemini CLI and ChatGPT, kept in sync from one source.",
|
|
5
5
|
"author": "aunysillyme (https://github.com/aunysillyme)",
|
|
6
6
|
"license": "MIT",
|
package/render/onboarding.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
DOCS points at the matching tag on GitHub so an installed copy never links to a file the
|
|
18
18
|
destination does not have.
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = '0.8.
|
|
20
|
+
const VERSION = '0.8.5';
|
|
21
21
|
const DOCS = `https://github.com/aunysillyme/agent-personalizer/blob/v${VERSION}/docs`;
|
|
22
22
|
|
|
23
23
|
/* THE single source for notes tools. Add a tool here and nowhere else: the saved choice option, the
|
|
@@ -173,6 +173,9 @@ function validate(input) {
|
|
|
173
173
|
// no "..", no empty segment, no backslash, nothing but [A-Za-z0-9._ -] per segment.
|
|
174
174
|
if (kindOf(out) === 'disk' && !SAFE_REL.test(out.notes_path))
|
|
175
175
|
throw new Error(`"notes_path" for ${out.notes_tool} must be a relative folder path such as "notes" or "docs/vault" (letters, digits, space, . _ -, segments joined by /; no leading /, no ..)`);
|
|
176
|
+
const reserved = out.notes_path.split('/').find(segment => ['.git', '.github', 'node_modules'].includes(segment.toLowerCase()));
|
|
177
|
+
if (kindOf(out) === 'disk' && reserved)
|
|
178
|
+
throw new Error(`"notes_path" must not contain the reserved segment "${reserved}"`);
|
|
176
179
|
const owned = ['.agent-personalizer', '.agent-personalizer.json', '.claude', 'render', 'rules', 'check', 'hooks', 'USER.md', 'LEARNED.md', 'CLAUDE.md', 'AGENTS.md', 'GEMINI.md', 'AGENT_ONBOARDING.md', 'system-prompt.md', 'chatgpt-custom-instructions.md', 'chatgpt-box1.txt', 'chatgpt-box2.txt'];
|
|
177
180
|
if (kindOf(out) === 'disk' && owned.some(p => out.notes_path.toLowerCase() === p.toLowerCase() || out.notes_path.toLowerCase().startsWith(p.toLowerCase() + '/')))
|
|
178
181
|
throw new Error('"notes_path" must be outside agent-personalizer tool-owned paths, including .agent-personalizer/');
|
|
@@ -361,7 +364,7 @@ _Generated by agent-personalizer from your saved preferences (stored in \`.agent
|
|
|
361
364
|
|
|
362
365
|
### Read this first, in order
|
|
363
366
|
|
|
364
|
-
${bullets(a.read_first.map(
|
|
367
|
+
${bullets(a.read_first.map(entryMd), 'USER.md')}
|
|
365
368
|
- ${pending ? `Nothing else yet: there is no notes folder to read, and no folder README (${notesLater(base)} and its README). See § Where you may write below.` : tool.kind === 'cloud' ? `The index ${unit} of "${md(a.notes_path)}", before writing there.` : `\`${base}/README.md\`, the rules of the folder you may write into, before writing there.`}
|
|
366
369
|
${a.tracker !== 'none' ? `- The task tracker (${md(a.tracker)}): what is open and what is already decided, before proposing work.\n` : ''}
|
|
367
370
|
### Where you may write
|
|
@@ -449,7 +452,7 @@ function contractBlock(a, opts) {
|
|
|
449
452
|
`Always ask before: ${a.always_ask.join(', ') || 'nothing declared'}.`,
|
|
450
453
|
a.off_limits.length ? `Off limits in any output: ${a.off_limits.map(md).join(', ')}.` : null,
|
|
451
454
|
writesLine(a, opts),
|
|
452
|
-
files ? `Read first: ${a.read_first.map(
|
|
455
|
+
files ? `Read first: ${a.read_first.map(entryMd).join(' → ')}.` : null,
|
|
453
456
|
`Directness: ${label(Q.tone, a.tone)}. Length: ${label(Q.length, a.length)}. When wrong: ${label(Q.mistakes, a.mistakes)}. When unsure: ${youLabel(Q.unsure, a.unsure)}.`,
|
|
454
457
|
`Open with ${label(Q.lead_with, a.lead_with)}; ${label(Q.structure, a.structure)}; evidence ${label(Q.evidence, a.evidence)}.${a.signature === 'yes' ? ' Sign every edit to a note (one `Last edited by:` line, overwritten).' : ''}`,
|
|
455
458
|
a.never.length ? `Never: ${a.never.map(md).join('; ')}.` : null,
|
package/render/render.cjs
CHANGED
|
@@ -83,6 +83,7 @@ const BINDINGS = new Set(Object.values(TARGETS).map(t => t.binding).filter(Boole
|
|
|
83
83
|
const SECTION_RE = /^(universal|personal|origin|binding:[a-z]+)$/;
|
|
84
84
|
const META_KEYS = new Set(['id', 'title', 'inject', 'surfaces', 'requires']);
|
|
85
85
|
const RULE_FILE_RE = /^\d{2}-[A-Za-z0-9._-]+\.md$/;
|
|
86
|
+
const CORE_RULE_FILES = new Set(['00-read-the-profile-first.md', '10-evidence-before-assertion.md', '50-output-style.md', '60-act-or-ask.md', '65-ask-before-it-repeats.md']);
|
|
86
87
|
|
|
87
88
|
|
|
88
89
|
const VALUE_OPTS = ['--dir', '--targets', '--contract-target', '--rules'];
|
|
@@ -283,7 +284,12 @@ function loadRules(root, explicit) {
|
|
|
283
284
|
function loadProfile(root) {
|
|
284
285
|
const p = path.join(root, 'USER.md');
|
|
285
286
|
if (!fs.existsSync(p) && !(() => { try { fs.lstatSync(p); return true; } catch (_) { return false; } })()) return null;
|
|
286
|
-
|
|
287
|
+
return profileFromSource(readSource(p, 'USER.md'));
|
|
288
|
+
}
|
|
289
|
+
function profileFromSource(source) {
|
|
290
|
+
if (typeof source !== 'string') die('USER.md: profile source must be text');
|
|
291
|
+
const text = source.replace(/^\ufeff/, '').replace(/\r\n/g, '\n');
|
|
292
|
+
rejectMarkers(text, 'USER.md');
|
|
287
293
|
fenceMap(text.split('\n'), 'USER.md'); // an unterminated fence in the profile is an error, not a surprise later
|
|
288
294
|
return { source: text, body: text.replace(/^#\s+USER\.md\s*\n/, '').replace(/\n---\n\*Template from agent-personalizer[^\n]*\n?$/, '').trim() };
|
|
289
295
|
}
|
|
@@ -321,6 +327,7 @@ function rulesFor(rules, key, answers) {
|
|
|
321
327
|
return rules.filter(r => (!Array.isArray(r.meta.surfaces) || r.meta.surfaces.includes(key))
|
|
322
328
|
&& (!r.meta.requires || a[r.meta.requires.answer] === r.meta.requires.value));
|
|
323
329
|
}
|
|
330
|
+
const rulesAtLevel = (rules, cfg) => cfg && (cfg.level === 1 || cfg.level === 2) ? rules.filter(r => CORE_RULE_FILES.has(r.file)) : rules;
|
|
324
331
|
const answersOf = (cfg) => (cfg && cfg.onboarding) ? cfg.onboarding : null;
|
|
325
332
|
/* Do the notes pointers in a rendered file name something that is there? The README is the file the
|
|
326
333
|
AI is told to read before it writes, and the level-2 scaffold creates it with the folder, so its
|
|
@@ -363,6 +370,7 @@ function renderTarget(key, target, profile, rules, cfg, root, learned) {
|
|
|
363
370
|
if (!cfg || !cfg.onboarding) die(`target "${key}": no onboarding answers in .agent-personalizer.json. Run the installer, or pass --answers <file>`);
|
|
364
371
|
return onboarding.renderOnboarding(cfg.onboarding, { notesScaffolded: notesScaffolded(root, cfg.onboarding) });
|
|
365
372
|
}
|
|
373
|
+
rules = rulesAtLevel(rules, cfg);
|
|
366
374
|
const answers = answersOf(cfg);
|
|
367
375
|
const lines = [`## ${target.header}`, '', '_Generated by agent-personalizer from `USER.md`, `LEARNED.md`, `rules/` and your saved preferences. Edit those, then re-render. Do not edit between the markers._', ''];
|
|
368
376
|
if (target.boxes) {
|
|
@@ -480,7 +488,7 @@ function main() {
|
|
|
480
488
|
const target = TARGETS[key];
|
|
481
489
|
const withPersonal = target.personal && !arg('--no-personal', false);
|
|
482
490
|
const cfgC = readConfig(root);
|
|
483
|
-
const inject = rulesFor(rules, key, answersOf(cfgC)).filter(r => r.meta.inject === true);
|
|
491
|
+
const inject = rulesFor(rulesAtLevel(rules, cfgC), key, answersOf(cfgC)).filter(r => r.meta.inject === true);
|
|
484
492
|
const out = [`[agent-personalizer] Session-start contract for ${key}. Injected in full at the start of every session so these rules are in context at the moment of decision.`, ''];
|
|
485
493
|
if (cfgC && cfgC.onboarding && withPersonal) out.push(onboarding.contractBlock(cfgC.onboarding, { notesScaffolded: notesScaffolded(root, cfgC.onboarding) }), '');
|
|
486
494
|
for (const r of inject) {
|
|
@@ -672,10 +680,10 @@ function preflightSources(root) {
|
|
|
672
680
|
|
|
673
681
|
/* Pure output planning for uninstall. Uses this package's renderer, never executable code from
|
|
674
682
|
the installed folder. The caller preflights all paths before asking for these bytes. */
|
|
675
|
-
function renderedContents(root, cfg) {
|
|
683
|
+
function renderedContents(root, cfg, options = {}) {
|
|
676
684
|
const rules = loadRules(root, null);
|
|
677
|
-
const profile = loadProfile(root);
|
|
678
|
-
const learned = readLearned(root);
|
|
685
|
+
const profile = Object.hasOwn(options, 'profileSource') ? profileFromSource(options.profileSource) : loadProfile(root);
|
|
686
|
+
const learned = options.learned || readLearned(root);
|
|
679
687
|
renderTarget.boxes = null;
|
|
680
688
|
renderTarget.overBudget = [];
|
|
681
689
|
return cfg.targets.flatMap(key => {
|
|
@@ -695,5 +703,5 @@ function renderedContents(root, cfg) {
|
|
|
695
703
|
/* parseFrontmatter and parseSections are exported so another renderer can read the same rule-file
|
|
696
704
|
format with the same validation (for example one that renders CLAUDE.md sections and session-start
|
|
697
705
|
hook bodies from rules in this format). Set DIE_THROWS to get a Refusal instead of an exit. */
|
|
698
|
-
module.exports = { readLearned, pendingDigest, main, fenceMap, markerState, splice, between, preflightSources, parseFrontmatter, parseSections, readConfig, validatePreservedTargets, renderedContents, Refusal, DIE_THROWS: false };
|
|
706
|
+
module.exports = { CORE_RULE_FILES, readLearned, pendingDigest, main, fenceMap, markerState, splice, between, preflightSources, parseFrontmatter, parseSections, readConfig, validatePreservedTargets, renderedContents, Refusal, DIE_THROWS: false };
|
|
699
707
|
if (require.main === module) main();
|
|
@@ -16,10 +16,10 @@ In practice: when you change a file in a folder, fix that folder's README in the
|
|
|
16
16
|
Never hand-type fields the system derives (an `updated:` date pulled from version control, for instance). Edit the prose, not the derived keys.
|
|
17
17
|
|
|
18
18
|
## binding:claude
|
|
19
|
-
|
|
19
|
+
Restate this rule in each folder's README so the folder carries its own contract.
|
|
20
20
|
|
|
21
21
|
## binding:agents
|
|
22
|
-
|
|
22
|
+
Check the folder's README before reporting a write as done.
|
|
23
23
|
|
|
24
24
|
## origin
|
|
25
25
|
Written after: an AI trusted a folder index that described a file deleted two weeks earlier, and built a plan on it. Agents read a notes folder by trusting the index over the files, because that is what an index is for.
|
package/rules/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
One rule per file. Each file is the owning copy of that rule; everything else points here. `render/render.cjs` turns these files plus `USER.md` into the per-AI instruction files.
|
|
4
4
|
|
|
5
|
+
Install levels 1 and 2 render the Core 5: `00-read-the-profile-first.md`, `10-evidence-before-assertion.md`, `50-output-style.md`, `60-act-or-ask.md` and `65-ask-before-it-repeats.md`. Level 3 copies all eleven rules here for editing and renders them with the existing surface and preference filters; the signature rule still follows the signature preference. The source rule files below remain the full set.
|
|
6
|
+
|
|
5
7
|
## Format
|
|
6
8
|
|
|
7
9
|
```markdown
|