agent-personalizer 0.8.4 → 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 CHANGED
@@ -2,10 +2,26 @@
2
2
 
3
3
  All notable changes to this repo. Format after [Keep a Changelog](https://keepachangelog.com/en/2.0.0/) 2.0.0; versions follow [SemVer](https://semver.org/). Dates are the day the change was pushed.
4
4
 
5
- Every entry names the adversarial audit round that produced it where one did. Audits are read-only passes against `AUDIT_BRIEF.md`; every finding is reproduced before its fix.
5
+ Every entry names the adversarial audit round that produced it where one did. Audits are read-only passes against the stated release scope; every finding is reproduced before its fix.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.8.5] - 2026-10-29
10
+
11
+ ### Fixed
12
+
13
+ - Audit 2026-10-29: find Claude Code sessions for project paths with spaces, dots and underscores while retaining legacy folder names.
14
+ - Audit 2026-10-29: skip whole messages and Codex memory notes that match conservative secret patterns, reporting only the skip count.
15
+ - Audit 2026-10-29: apply the 2,000-character message cap to Codex memory notes, retaining private-term filtering and the 20-file cap.
16
+ - Audit 2026-10-29: disclose global Codex memory scope and secret skips in consent, and document both project and global private lists.
17
+ - Audit 2026-10-29: preserve intra-word underscores in read-first filenames while escaping hostile Markdown.
18
+ - Audit 2026-10-29: refuse local notes paths containing .git, .github or node_modules segments, ignoring case.
19
+ - Audit 2026-10-29: remove the uninstalled folder-template path from rendered home files and refresh all three examples.
20
+ - Audit 2026-10-29: register the project session-start hook through CLAUDE_PROJECT_DIR so it runs from subfolders, and explain user-level absolute paths.
21
+ - Audit 2026-10-29: align memory status, global learning help, level errors, AI target contribution steps and symlink guidance with supported behaviour; remove the inaccessible audit-brief citation.
22
+ - Audit 2026-10-29: warn that profile and off-limits names enter home files that may be committed.
23
+ - Audit 2026-10-29: use short temporary bases for session-path fixtures so deep TMPDIR paths do not cause false failures.
24
+
9
25
  ## [0.8.4] - 2026-10-28
10
26
 
11
27
  ### Added
@@ -331,7 +347,8 @@ Thirteen issues (#3 to #15) filed against `5972b32` by an independent installati
331
347
  - Installer: safe destination resolution, strict options, duplicate `--ai` refused, `--dir` created one level at a time.
332
348
  - Harness: exact exit codes, adversarial fixtures, fault injection for the rollback path.
333
349
 
334
- [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.4...HEAD
350
+ [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.5...HEAD
351
+ [0.8.5]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.4...v0.8.5
335
352
  [0.8.4]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.3...v0.8.4
336
353
  [0.8.3]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.2...v0.8.3
337
354
  [0.8.2]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.1...v0.8.2
package/CONTRIBUTING.md CHANGED
@@ -10,7 +10,7 @@ Contributions are welcome: a **new AI target**, a **notes tool**, an **example u
10
10
  ## Running the checks
11
11
 
12
12
  ```bash
13
- npm test # sh test/run.sh: 98 checks, exact exit codes, Linux and macOS
13
+ npm test # sh test/run.sh: 99 checks, exact exit codes, Linux and macOS
14
14
  node test/rollback.test.js "$(mktemp -d)" # after copying examples/freelance-illustrator into it
15
15
  node check/gate.cjs --self-test
16
16
  ```
@@ -26,7 +26,7 @@ The privacy gate (`check/gate.cjs` against a real list) needs a local `check/for
26
26
  ## Adding a notes tool or an AI target
27
27
 
28
28
  - A notes tool is ONE entry in the `TOOL` table at the top of `render/onboarding.cjs` (`kind`, `label`, `name`, `reach`, `posture`); the interview option, the validation and the write section all derive from it. Then a row in `docs/companions.md`, and an installer hint in `bin/agent-personalizer.js` if the tool needs one. Check 60 in the harness iterates every option; add yours to the right loop. Check 74 asserts the interview options equal the table's keys.
29
- - An AI target is an entry in `render/targets.json` plus a row in `docs/paste-guide.md`. If it has a binding, add `binding:<name>` blocks to the rules that need one; unknown binding names are refused.
29
+ - An AI target needs an entry in `render/targets.json`, a row in `docs/paste-guide.md`, and updates to the hardcoded AI lists: `AIS` and `AI_LABEL` in `bin/agent-personalizer.js`, the supported targets in `bin/global.cjs`, the learning and contract target lists in `render/render.cjs`, and `SOURCE` in `bin/learn.cjs`. Set the target's supported modes and local session source where applicable. If it has a binding, add `binding:<name>` blocks to the rules that need one; unknown binding names are refused.
30
30
 
31
31
  ## Pull requests
32
32
 
package/README.md CHANGED
@@ -211,7 +211,7 @@ Contributions are welcome: a new AI target, a notes tool, an example user, or a
211
211
 
212
212
  Pull requests are accepted under the [contributor license agreement](CLA.md); the checkbox in the pull request template records your agreement.
213
213
 
214
- The harness (`test/run.sh: 98 checks`) tests exact exit codes and adversarial fixtures. The real forbidden-list check stays local and prints a skip when the private list is absent.
214
+ The harness (`test/run.sh: 99 checks`) tests exact exit codes and adversarial fixtures. The real forbidden-list check stays local and prints a skip when the private list is absent.
215
215
 
216
216
  ## License
217
217
 
package/SECURITY.md CHANGED
@@ -18,4 +18,4 @@ In scope: `bin/`, including session reading, learning and removal, `render/`, `c
18
18
 
19
19
  ## What is already done
20
20
 
21
- Every release passes an adversarial read-only audit (see `CHANGELOG.md`, each entry names its round) and a 98-check harness with exact exit codes, on Linux and macOS in CI. The deferred residuals are stated in the code headers: TOCTOU between check and write, unicode look-alikes in the gate, the named `--dir` being followed once via realpath, and a hard process kill between two renames. On Windows, `O_NOFOLLOW` is unavailable to the flag the uninstaller opens tracked files with; nothing depends on it there, because the delete loop re-probes every path with `lstat` immediately before each unlink, so no destructive path exists without it.
21
+ Every release passes an adversarial read-only audit (see `CHANGELOG.md`, each entry names its round) and a 99-check harness with exact exit codes, on Linux and macOS in CI. The deferred residuals are stated in the code headers: TOCTOU between check and write, unicode look-alikes in the gate, the named `--dir` being followed once via realpath, and a hard process kill between two renames. On Windows, `O_NOFOLLOW` is unavailable to the flag the uninstaller opens tracked files with; nothing depends on it there, because the delete loop re-probes every path with `lstat` immediately before each unlink, so no destructive path exists without it.
@@ -41,6 +41,7 @@ const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).vers
41
41
  npx agent-personalizer --uninstall --dir <folder> [--dry]
42
42
 
43
43
  npx agent-personalizer learn [--dir <folder>] [--all-projects] [--yes]
44
+ npx agent-personalizer learn --global [--yes]
44
45
  npx agent-personalizer learn --forget [--dir <folder>]
45
46
 
46
47
  First interactive install: choose your AIs, then choose whether to read your recent sessions.
@@ -294,7 +295,7 @@ async function main() {
294
295
  .filter(([folder]) => fs.existsSync(path.join(home, folder))).map(([, ai]) => ai) : [];
295
296
  ais = await ask('\nAIs', ais || (found.length ? found.join(',') : 'claude,agents'));
296
297
  }
297
- if (!/^[1-4]$/.test(String(level))) die('level must be exactly 1, 2 or 3');
298
+ if (!/^[1-4]$/.test(String(level))) die('level must be 1, 2 or 3 (4 is accepted as 3)');
298
299
  level = Number(level);
299
300
  if (level === 4) console.log('note: --level 4 installs exactly what --level 3 installs. For model routing, see https://github.com/aunysillyme/model-orchestrator');
300
301
  const targets = String(ais || '').split(',').map(s => s.trim()).filter(Boolean);
@@ -86,7 +86,7 @@ function protect(root, log = console.log) {
86
86
  const tracked = git(where.top, ['ls-files', '--', ...PRIVATE.map(p => where.prefix ? `${where.prefix}/${p}` : p)]).out.split('\n').filter(Boolean);
87
87
  if (tracked.length) log(`WARNING: git already tracks ${tracked.join(', ')}; an exclude cannot hide a tracked file. Run git rm --cached on it if it should stay private.`);
88
88
  const shared = SHARED_PERSONAL.filter(p => fs.existsSync(path.join(root, p)));
89
- if (shared.length) log(`NOTE: ${shared.join(', ')} carry your profile, entries or answers and stay committable, since projects often share them. Review them before committing.`);
89
+ if (shared.length) log(`NOTE: ${shared.join(', ')} carry your profile, entries and answers, including names under off-limits. CLAUDE.md, AGENTS.md and GEMINI.md may be committed. Review them before committing.`);
90
90
  }
91
91
 
92
92
  function unprotect(root, { dry = false, log = console.log } = {}) {
package/bin/learn.cjs CHANGED
@@ -21,12 +21,14 @@ agent-personalizer can read up to 20 of your most recent sessions from ${scope}
21
21
  that Claude Code, Codex and Gemini CLI still keep, to find corrections you repeat.
22
22
  · ${scopeHint}
23
23
  · Only what you typed, never the AI's replies.
24
+ · Messages that look like secrets are skipped.
24
25
  · Stays on this computer, saved to .agent-personalizer/digest.md.
25
26
  · Your AI reads that file next time you open it, like anything you share with it.
26
27
  · Other people's details in there? Add their names to your private list first.
27
28
  · Delete it any time: npx agent-personalizer learn --forget
28
29
  (your AI app's own history stays as it is)
29
30
  · Codex's own memory notes are included when you choose Codex.
31
+ They are global to your Codex account, not limited to this folder.
30
32
  · When your AI reads the file, its provider sees these messages again.
31
33
  · Work or client accounts: check your agreement before reusing their sessions.
32
34
  · Not affiliated with Anthropic, OpenAI or Google. Their formats can change.
package/bin/sessions.cjs CHANGED
@@ -17,7 +17,7 @@ function bump(state, reason, count = 1) {
17
17
 
18
18
  function claudeProjectNames(projectDir) {
19
19
  const absolute = path.resolve(projectDir);
20
- return [...new Set([absolute.replace(/[\\/]/g, '-'), absolute.replace(/[:\\/]/g, '-')])];
20
+ return [...new Set([absolute.replace(/[\\/]/g, '-'), absolute.replace(/[:\\/]/g, '-'), absolute.replace(/[^a-zA-Z0-9]/g, '-'), absolute.replace(/[^a-zA-Z0-9_]/g, '-')])];
21
21
  }
22
22
 
23
23
  function belongsToProject(cwd, projectDir) {
@@ -29,6 +29,17 @@ function belongsToProject(cwd, projectDir) {
29
29
  /* Both sides are compared in NFC and lower case: macOS often stores accents decomposed (NFD),
30
30
  which would otherwise let a listed name through. Audit 0.8.0 F2. */
31
31
  const CTRL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
32
+ const SECRETS = [
33
+ /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY-----/i,
34
+ /sk-[A-Za-z0-9_-]{20,}/,
35
+ /(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]+/,
36
+ /AKIA[A-Z0-9]{16}/,
37
+ /xox[baprs]-[A-Za-z0-9-]+/,
38
+ /AIza[A-Za-z0-9_-]{20,}/,
39
+ /Bearer\s+[A-Za-z0-9._~+\/-]{20,}/i,
40
+ /(?:api[_-]?key|secret|token|password|passwd)["']?\s*[:=]\s*\S{8,}/i
41
+ ];
42
+ const secretMatch = text => SECRETS.some(pattern => pattern.test(String(text).replace(CTRL, '')));
32
43
  const fold = (text) => String(text).replace(CTRL, '').normalize('NFC').toLowerCase();
33
44
  const compact = (text) => fold(text).replace(/\s+/g, '');
34
45
  function privateMatch(text, terms) {
@@ -60,6 +71,7 @@ function cutContextBlocks(text) {
60
71
 
61
72
  function typedText(items, state) {
62
73
  if (!items.length) { bump(state, 'non_typed'); return null; }
74
+ if (secretMatch(items.join('\n')) || secretMatch(items.join(''))) { bump(state, 'secret'); return null; }
63
75
  // A private match drops the whole message, including its other text items.
64
76
  if (privateMatch(items.join('\n'), state.privateTerms) || privateMatch(items.join(''), state.privateTerms)) { bump(state, 'private_match'); return null; }
65
77
  const kept = [];
@@ -73,6 +85,7 @@ function typedText(items, state) {
73
85
  if (text) kept.push(text);
74
86
  }
75
87
  const text = kept.join('\n');
88
+ if (secretMatch(text) || secretMatch(kept.join(''))) { bump(state, 'secret'); return null; }
76
89
  if (privateMatch(text, state.privateTerms) || privateMatch(kept.join(''), state.privateTerms)) { bump(state, 'private_match'); return null; }
77
90
  if (!text) { bump(state, 'empty_message'); return null; }
78
91
  if (text.length > 2000) { bump(state, 'long_message'); return null; }
@@ -423,7 +436,9 @@ async function readMemory(file, state) {
423
436
  if (!await scanLines(file.file, state, line => lines.push(line))) return null;
424
437
  const text = lines.join('\n').replace(CTRL, '').trim();
425
438
  if (!text) return null;
439
+ if (secretMatch(text)) { bump(state, 'secret'); return null; }
426
440
  if (privateMatch(text, state.privateTerms)) { bump(state, 'private_match'); return null; }
441
+ if (text.length > 2000) { bump(state, 'long_message'); return null; }
427
442
  return { file: file.file, text, date: new Date(file.mtimeMs).toISOString() };
428
443
  }
429
444
 
package/docs/install.md CHANGED
@@ -99,6 +99,8 @@ Global learning always includes sessions from all projects and still needs conse
99
99
 
100
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
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
+
102
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.
103
105
 
104
106
  ## Learning commands
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 this
12
- project that Claude Code, Codex and Gemini CLI still keep, to find corrections you repeat.
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. Large likely pastes are dropped too. 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
+ 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`, one per line; any message 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).
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
 
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," and so a contradicted fact gets marked `superseded` with a pointer rather than silently overwritten.
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": "3ea7661f6ea1ad2f23072c20bc952ea0cf3d2acafdc486edee86f095266dc979",
54
- "AGENTS.md": "e870580a758b363c07e767e040f683e32890d0248726d0bcd4f0be0d83f3f423",
55
- "AGENT_ONBOARDING.md": "d4657e01cf5e8f1ac87e29e67e7bd1fe8a43152736611efc3f246ecc99aeb8b5"
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
- Same template. Check the index before reporting a write as done.
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
- - AGENT\_ONBOARDING.md
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.4/docs/companions.md.
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
19
+ Restate this rule in each folder's README so the folder carries its own contract.
20
20
 
21
21
  ## binding:agents
22
- Same template. Check the index before reporting a write as done.
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.
@@ -31,8 +31,8 @@
31
31
  ]
32
32
  },
33
33
  "installed": {
34
- "CLAUDE.md": "8bb89d845cd9471e5f357dd9c905f9dc5f4b83dc0531d14ba051b5691a884443",
35
- "AGENTS.md": "4ecab4f98605736f8b3185fa8df3a9484ba3d64d5312ece5d131c2316fab92d6",
36
- "AGENT_ONBOARDING.md": "94f4081f591bc7aac0921b53c21769e8e48cd85a52bc47f1abb09b1054c66bca"
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
- Same template. Check the index before reporting a write as done.
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
- - AGENT\_ONBOARDING.md
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
19
+ Restate this rule in each folder's README so the folder carries its own contract.
20
20
 
21
21
  ## binding:agents
22
- Same template. Check the index before reporting a write as done.
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.
@@ -31,8 +31,8 @@
31
31
  ]
32
32
  },
33
33
  "installed": {
34
- "CLAUDE.md": "6a058809841d4a98458b955c20373ea09740aface4f9465766dee64d54f5eee5",
35
- "AGENTS.md": "636fdb3ce93ca17f04e79200e618ccf9ad324abe8cbe7d6d3cc730eb744a433d",
36
- "AGENT_ONBOARDING.md": "08103273f0edea5da6c38ed79ce51113a9f040f98f357badc95b3f4e6fcfbcc3"
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
- Same template. Check the index before reporting a write as done.
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
- - AGENT\_ONBOARDING.md
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
19
+ Restate this rule in each folder's README so the folder carries its own contract.
20
20
 
21
21
  ## binding:agents
22
- Same template. Check the index before reporting a write as done.
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/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.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.
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 `.claude/settings.json` (project) or `~/.claude/settings.json` (global):
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.4",
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",
@@ -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.4';
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(md), 'USER.md')}
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(md).join(' → ')}.` : null,
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,
@@ -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
- Template: `templates/FOLDER_README.md`. The rule is restated inside the template so a folder carries its own contract.
19
+ Restate this rule in each folder's README so the folder carries its own contract.
20
20
 
21
21
  ## binding:agents
22
- Same template. Check the index before reporting a write as done.
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.