agent-personalizer 0.8.2 → 0.8.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/CHANGELOG.md +29 -1
- package/README.md +23 -12
- package/RELEASING.md +7 -1
- package/SECURITY.md +3 -1
- package/bin/agent-personalizer.js +130 -81
- 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 +2 -2
- package/bin/sessions.cjs +48 -15
- package/bin/uninstall.cjs +2 -1
- package/docs/guarantees.md +2 -2
- package/docs/install.md +27 -5
- package/docs/learning.md +1 -1
- package/docs/paste-guide.md +5 -3
- package/examples/freelance-illustrator/.agent-personalizer.json +1 -1
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +1 -1
- package/examples/freelance-illustrator/rules/README.md +2 -0
- package/examples/lab-technician/rules/README.md +2 -0
- package/examples/product-designer/rules/README.md +2 -0
- package/hooks/README.md +1 -1
- package/llms.txt +8 -2
- package/package.json +1 -1
- package/render/onboarding.cjs +1 -1
- package/render/render.cjs +14 -6
- package/rules/README.md +2 -0
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,26 @@ 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 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.
|
|
103
|
+
|
|
83
104
|
## Learning commands
|
|
84
105
|
|
|
85
106
|
```bash
|
|
@@ -92,11 +113,11 @@ npx agent-personalizer learn --forget --dir .
|
|
|
92
113
|
|
|
93
114
|
## What each level adds
|
|
94
115
|
|
|
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).
|
|
116
|
+
- **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`.
|
|
117
|
+
- **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.
|
|
118
|
+
- **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
119
|
|
|
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.
|
|
120
|
+
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
121
|
|
|
101
122
|
## Updating an install
|
|
102
123
|
|
|
@@ -109,6 +130,7 @@ Re-run the installer with `npx agent-personalizer --dir .`. An existing config m
|
|
|
109
130
|
- **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
131
|
- **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
132
|
- **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.
|
|
133
|
+
- **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
134
|
- **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
135
|
|
|
114
136
|
At level 3, render your edited profile and rules:
|
|
@@ -151,7 +173,7 @@ The uninstaller reads `/path/to/project/.agent-personalizer.json` and compares f
|
|
|
151
173
|
- **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
174
|
- **`USER.md`:** removed only when it matches its recorded install hash. Edited and pre-existing profiles stay.
|
|
153
175
|
- **`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
|
|
176
|
+
- **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
177
|
- **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
178
|
- **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
179
|
- **Rules and tools:** unchanged installed copies are removed file by file, including the session-start hook. Edited copies stay.
|
package/docs/learning.md
CHANGED
|
@@ -90,7 +90,7 @@ npx agent-personalizer --uninstall --dir . --dry
|
|
|
90
90
|
npx agent-personalizer --uninstall --dir .
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
`learn --forget` deletes agent-personalizer's digest and removes its empty private folder. It keeps approved entries. Uninstall removes the digest
|
|
93
|
+
`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
94
|
|
|
95
95
|
## How the loop closes
|
|
96
96
|
|
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
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"installed": {
|
|
53
53
|
"CLAUDE.md": "3ea7661f6ea1ad2f23072c20bc952ea0cf3d2acafdc486edee86f095266dc979",
|
|
54
54
|
"AGENTS.md": "e870580a758b363c07e767e040f683e32890d0248726d0bcd4f0be0d83f3f423",
|
|
55
|
-
"AGENT_ONBOARDING.md": "
|
|
55
|
+
"AGENT_ONBOARDING.md": "d4657e01cf5e8f1ac87e29e67e7bd1fe8a43152736611efc3f246ecc99aeb8b5"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -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.4/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.
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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,6 +1,6 @@
|
|
|
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.4/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
|
|
package/llms.txt
CHANGED
|
@@ -20,6 +20,14 @@ Session data stays local until the user's AI reads it and sends it to its provid
|
|
|
20
20
|
- [Companion tools](https://github.com/aunysillyme/agent-personalizer/blob/main/docs/companions.md): Notes connectors and enforcement tools.
|
|
21
21
|
- [Guarantees](https://github.com/aunysillyme/agent-personalizer/blob/main/docs/guarantees.md): What the code enforces and how instructions reach the AI.
|
|
22
22
|
|
|
23
|
+
<!-- set:start -->
|
|
24
|
+
## Part of a set
|
|
25
|
+
|
|
26
|
+
- [model-orchestrator](https://github.com/aunysillyme/model-orchestrator): Model router for AI coding agents: routes routine work to cheaper models with routing rules, 8 subagents, hooks and a CLI runner
|
|
27
|
+
- [repo-build-skill](https://github.com/aunysillyme/repo-build-skill): Skill pack that teaches your AI to build, release and launch a GitHub repo: stack pick, README, AGENTS.md, llms.txt, repo SEO and AEO, trusted publishing.
|
|
28
|
+
- [website-build-skill](https://github.com/aunysillyme/website-build-skill): A skill pack that turns your AI into an expert website builder: current research, design, code, accessibility, speed, SEO and security, alone or as a team.
|
|
29
|
+
<!-- set:end -->
|
|
30
|
+
|
|
23
31
|
## Optional
|
|
24
32
|
|
|
25
33
|
- [Agent contributor instructions](https://github.com/aunysillyme/agent-personalizer/blob/main/AGENTS.md): Repository rules and verification.
|
|
@@ -31,5 +39,3 @@ Session data stays local until the user's AI reads it and sends it to its provid
|
|
|
31
39
|
- [Support](https://github.com/aunysillyme/agent-personalizer/blob/main/SUPPORT.md): Where to ask questions, report bugs, request features and report security issues privately.
|
|
32
40
|
- [Maintainers](https://github.com/aunysillyme/agent-personalizer/blob/main/MAINTAINERS.md): Who owns reviews, releases and support routes.
|
|
33
41
|
- [Releasing](https://github.com/aunysillyme/agent-personalizer/blob/main/RELEASING.md): Version sites, checks, tags, provenance and publication steps.
|
|
34
|
-
- [model-orchestrator](https://github.com/aunysillyme/model-orchestrator): Model router for AI coding agents: routes routine work to cheaper models with routing rules, 8 subagents, hooks and a CLI runner.
|
|
35
|
-
- [website-build-skill](https://github.com/aunysillyme/website-build-skill): A skill pack that teaches your AI current website-building expertise: research, design, code, accessibility, performance, search and security.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-personalizer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
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.4';
|
|
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
|
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();
|
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
|