agent-personalizer 0.7.2 → 0.8.1

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/README.md +23 -14
  3. package/SECURITY.md +3 -1
  4. package/bin/agent-personalizer.js +90 -106
  5. package/bin/git-exclude.cjs +108 -0
  6. package/bin/install-plan.cjs +3 -0
  7. package/bin/known-hashes.json +54 -0
  8. package/bin/learn.cjs +210 -0
  9. package/bin/sessions.cjs +448 -0
  10. package/bin/uninstall.cjs +51 -7
  11. package/check/gate.cjs +4 -3
  12. package/docs/README.md +2 -1
  13. package/docs/companions.md +2 -2
  14. package/docs/guarantees.md +17 -6
  15. package/docs/install.md +31 -20
  16. package/docs/learning.md +103 -0
  17. package/docs/paste-guide.md +4 -4
  18. package/docs/tiers.md +4 -4
  19. package/examples/freelance-illustrator/.agent-personalizer.json +3 -3
  20. package/examples/freelance-illustrator/AGENTS.md +67 -3
  21. package/examples/freelance-illustrator/AGENT_ONBOARDING.md +4 -7
  22. package/examples/freelance-illustrator/CLAUDE.md +67 -3
  23. package/examples/freelance-illustrator/LEARNED.md +14 -0
  24. package/examples/freelance-illustrator/USER.md +6 -1
  25. package/examples/freelance-illustrator/rules/00-read-the-profile-first.md +1 -1
  26. package/examples/freelance-illustrator/rules/65-ask-before-it-repeats.md +18 -0
  27. package/examples/freelance-illustrator/rules/70-their-words-point-at-the-thing.md +15 -0
  28. package/examples/freelance-illustrator/rules/80-symptoms-are-not-causes.md +15 -0
  29. package/examples/freelance-illustrator/rules/90-surface-what-they-cant-see.md +15 -0
  30. package/examples/freelance-illustrator/rules/README.md +59 -0
  31. package/examples/lab-technician/.agent-personalizer.json +38 -0
  32. package/examples/lab-technician/AGENTS.md +243 -0
  33. package/examples/lab-technician/AGENT_ONBOARDING.md +64 -0
  34. package/examples/lab-technician/CLAUDE.md +247 -0
  35. package/examples/lab-technician/LEARNED.md +14 -0
  36. package/examples/lab-technician/USER.md +53 -0
  37. package/examples/lab-technician/notes/README.md +26 -0
  38. package/examples/lab-technician/notes/decisions.md +4 -0
  39. package/examples/lab-technician/notes/inbox/2026-10-06-observation-table.md +3 -0
  40. package/examples/lab-technician/notes/inbox/README.md +7 -0
  41. package/examples/lab-technician/notes/sessions/2026-W41.md +7 -0
  42. package/examples/lab-technician/rules/00-read-the-profile-first.md +24 -0
  43. package/examples/lab-technician/rules/10-evidence-before-assertion.md +24 -0
  44. package/examples/lab-technician/rules/20-one-owner-per-rule.md +24 -0
  45. package/examples/lab-technician/rules/30-folder-index-is-part-of-the-change.md +26 -0
  46. package/examples/lab-technician/rules/40-sign-every-edit.md +25 -0
  47. package/examples/lab-technician/rules/50-output-style.md +21 -0
  48. package/examples/lab-technician/rules/60-act-or-ask.md +30 -0
  49. package/examples/lab-technician/rules/65-ask-before-it-repeats.md +18 -0
  50. package/examples/lab-technician/rules/70-their-words-point-at-the-thing.md +15 -0
  51. package/examples/lab-technician/rules/80-symptoms-are-not-causes.md +15 -0
  52. package/examples/lab-technician/rules/90-surface-what-they-cant-see.md +15 -0
  53. package/examples/lab-technician/rules/README.md +59 -0
  54. package/examples/product-designer/.agent-personalizer.json +38 -0
  55. package/examples/product-designer/AGENTS.md +243 -0
  56. package/examples/product-designer/AGENT_ONBOARDING.md +63 -0
  57. package/examples/product-designer/CLAUDE.md +247 -0
  58. package/examples/product-designer/LEARNED.md +14 -0
  59. package/examples/product-designer/USER.md +53 -0
  60. package/examples/product-designer/notes/README.md +26 -0
  61. package/examples/product-designer/notes/decisions.md +4 -0
  62. package/examples/product-designer/notes/inbox/2026-10-06-cancellation-wording.md +8 -0
  63. package/examples/product-designer/notes/inbox/README.md +7 -0
  64. package/examples/product-designer/notes/sessions/2026-W41.md +7 -0
  65. package/examples/product-designer/rules/00-read-the-profile-first.md +24 -0
  66. package/examples/product-designer/rules/10-evidence-before-assertion.md +24 -0
  67. package/examples/product-designer/rules/20-one-owner-per-rule.md +24 -0
  68. package/examples/product-designer/rules/30-folder-index-is-part-of-the-change.md +26 -0
  69. package/examples/product-designer/rules/40-sign-every-edit.md +25 -0
  70. package/examples/product-designer/rules/50-output-style.md +21 -0
  71. package/examples/product-designer/rules/60-act-or-ask.md +30 -0
  72. package/examples/product-designer/rules/65-ask-before-it-repeats.md +18 -0
  73. package/examples/product-designer/rules/70-their-words-point-at-the-thing.md +15 -0
  74. package/examples/product-designer/rules/80-symptoms-are-not-causes.md +15 -0
  75. package/examples/product-designer/rules/90-surface-what-they-cant-see.md +15 -0
  76. package/examples/product-designer/rules/README.md +59 -0
  77. package/hooks/README.md +1 -1
  78. package/llms.txt +6 -2
  79. package/package.json +2 -2
  80. package/render/onboarding.cjs +115 -45
  81. package/render/render.cjs +98 -39
  82. package/rules/00-read-the-profile-first.md +1 -1
  83. package/rules/65-ask-before-it-repeats.md +18 -0
  84. package/rules/70-their-words-point-at-the-thing.md +15 -0
  85. package/rules/80-symptoms-are-not-causes.md +15 -0
  86. package/rules/90-surface-what-they-cant-see.md +15 -0
  87. package/rules/README.md +4 -0
  88. package/templates/LEARNED.md +11 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,40 @@ Every entry names the adversarial audit round that produced it where one did. Au
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.8.1] - 2026-10-17
10
+
11
+ ### Fixed
12
+
13
+ - Re-render keeps user text outside generated blocks out of whole-file ownership updates and leaves legacy configurations without `installed` on the legacy removal path, so uninstall retains added instructions and removes untouched legacy targets (Codex audit 2026-10-17, F1; agy audit, A3).
14
+ - Local notes paths inside tool-owned paths are refused, `learn` preserves edited or pre-existing `.agent-personalizer/.gitignore` and `digest.md` files without adopting their hashes, and uninstall keeps unrecorded or edited digest-folder files (Codex audit 2026-10-17, F2; agy audit, A5).
15
+ - Renderer ownership configuration writes share target staging and rollback, with clean diagnostics on failure (Codex audit 2026-10-17, F3).
16
+ - Session and Codex memory privacy filtering strips control characters before matching and checks the final text after context removal, including private terms rejoined across newlines, item boundaries or spaces (Codex audit 2026-10-17, F4; agy audit, A1 and A6).
17
+ - ChatGPT exports every declined entry in full and reports overflow; `--strict` refuses over-budget lists before writing (Codex audit 2026-10-17, F5).
18
+ - Render, drift checks and uninstall strip a leading UTF-8 BOM before fence, marker and `LEARNED.md` parsing while preserving it byte for byte on output (Codex audit 2026-10-17, F6; agy audit, A2 and A4).
19
+ - The demo recorder follows the current folder, AI selection and default-No session-consent prompts (Codex audit 2026-10-17, F7).
20
+ - Uninstall restores a pre-existing home file byte for byte: it removes the blank separator line install added along with the block. An untouched `LEARNED.md` template is removed, and `.agent-personalizer.json` is removed when only stripped home files remain (#32).
21
+ - Inside a git repo, install adds `USER.md`, `LEARNED.md`, `.agent-personalizer.json` and the ChatGPT paste files to `.git/info/exclude` in one marked block per install folder, and notes that the home files carry your profile. Uninstall removes the block (#30).
22
+ - Learning reads sessions from the current project by default; `--all-projects` explicitly includes sessions from other projects (#31).
23
+ - The F5 historical-install check skips when its version tags are absent, including in shallow clones, and reports the skip separately from a pass (#34).
24
+
25
+ ## [0.8.0] - 2026-10-06
26
+
27
+ ### Added
28
+
29
+ - Consent-gated local readers for recent Claude Code, Codex and Gemini CLI sessions, plus Codex memory notes. Readers stream bounded input, keep typed messages, skip automation and unsafe paths, and filter private-list matches without printing message text.
30
+ - `learn` collects new evidence after a yes; `learn --forget` deletes the local digest without touching AI app history. The digest labels messages as data and stays in a gitignored local folder.
31
+ - `LEARNED.md` at every install level owns confirmed, proposed and declined entries. Confirmed entries reach every personal AI target, declined entries tell the AI never to ask again, and `--check` detects unrendered entry edits.
32
+ - One shared procedure asks up to five questions with counts and quotes from an unhandled digest. Claude Code receives `/personalize`; Codex and Gemini CLI receive the same flow in their home files.
33
+ - Four rules with origin stories: Ask before it repeats, Their words point at the thing, Symptoms are not causes, and Surface what they can't see.
34
+ - Learning and privacy documentation, synthetic session fixtures, and two more invented example users with different entries.
35
+
36
+ ### Changed
37
+
38
+ - The first interactive install asks only for the folder when needed, selected AIs and consent. AIs found locally are pre-selected, level 1 is the default, and session consent defaults to No. The personal questionnaire is gone; `--full` and `--quick` remain accepted no-ops.
39
+ - Re-runs ask nothing and preserve saved settings, including legacy name, pronouns, work and focus answers. Non-default legacy identity values remain in the generated profile's "About me" section.
40
+ - Uninstall always keeps `LEARNED.md` and removes the digest. Non-interactive installs never read sessions; scripted consent uses `learn --yes`.
41
+ - Privacy guidance explains local session access, AI provider visibility, other people's details, work accounts, private-list filtering and undo.
42
+
9
43
  ## [0.7.2] - 2026-10-06
10
44
 
11
45
  ### Changed
@@ -265,7 +299,9 @@ Thirteen issues (#3 to #15) filed against `5972b32` by an independent installati
265
299
  - Installer: safe destination resolution, strict options, duplicate `--ai` refused, `--dir` created one level at a time.
266
300
  - Harness: exact exit codes, adversarial fixtures, fault injection for the rollback path.
267
301
 
268
- [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.2...HEAD
302
+ [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.1...HEAD
303
+ [0.8.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.0...v0.8.1
304
+ [0.8.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.2...v0.8.0
269
305
  [0.7.2]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.1...v0.7.2
270
306
  [0.7.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.0...v0.7.1
271
307
  [0.7.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.6.5...v0.7.0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/agent-personalizer.svg)](https://www.npmjs.com/package/agent-personalizer) [![harness](https://github.com/aunysillyme/agent-personalizer/actions/workflows/harness.yml/badge.svg)](https://github.com/aunysillyme/agent-personalizer/actions/workflows/harness.yml) [![release](https://img.shields.io/github/v/tag/aunysillyme/agent-personalizer?label=release)](https://github.com/aunysillyme/agent-personalizer/blob/main/CHANGELOG.md) [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
4
 
5
- **Answer a few questions once, and every AI you use gets the same profile and the rules it can carry:** Claude Code, Codex, Cursor, Gemini CLI and ChatGPT, rendered from one source and kept in sync.
5
+ **Every AI you use gets the same profile and the rules it can carry:** Claude Code, Codex, Cursor, Gemini CLI and ChatGPT, rendered from one source and kept in sync.
6
6
 
7
7
  **The problem:** Custom instructions live in each app separately, drift apart and fade over a long chat.
8
8
 
@@ -21,6 +21,8 @@ npx agent-personalizer
21
21
  | Part | What it gives you |
22
22
  |---|---|
23
23
  | `USER.md` | Your profile, communication preferences and how firmly you mean things. It owns the profile in every profile export. |
24
+ | `LEARNED.md` | Entries you confirmed or declined, shared with every personal AI target you selected. |
25
+ | Local session digest | With your yes, recent typed messages your AI uses to ask up to five evidence-backed questions. |
24
26
  | `AGENT_ONBOARDING.md` | Your AI's reading order, writing policy, off-limits topics and approval steps. |
25
27
  | `CLAUDE.md` | Your profile and selected rules in Claude Code's project instruction file. |
26
28
  | `AGENTS.md` | Your profile and selected rules in the project file used by Codex and Cursor. |
@@ -39,6 +41,8 @@ npx agent-personalizer
39
41
 
40
42
  Start your AI in the installed project folder. Ask it which instruction file loaded and what your writing policy is. Confirm those answers against AGENT_ONBOARDING.md before the first write.
41
43
 
44
+ If you accepted session reading, Claude Code's `/personalize`, or the procedure in Codex and Gemini CLI's home files, asks up to five questions with a count and a short quote. Yes records a confirmed entry; no records a declined entry that is never asked again. Every approved entry reaches your selected personal AI files. As you work, a second correction of the same thing prompts one "Make it a rule?" question.
45
+
42
46
  For ChatGPT, open Settings → Personalization and enable customization. Copy the exported profile (`chatgpt-box1.txt`) and response instructions (`chatgpt-box2.txt`) into the fields your current interface provides, checking its displayed limits. Re-paste after updates; the [paste guide](docs/paste-guide.md) covers each app.
43
47
 
44
48
  File generation, re-runs and uninstall run in CI on Linux, macOS and Windows; your client's context view confirms loading on your setup.
@@ -55,11 +59,7 @@ Three open-source tools that work on their own and fit together:
55
59
 
56
60
  ## Choose your setup
57
61
 
58
- The short interview asks seven base questions, plus any that apply to your notes tool. Enter accepts each default. For the full interview, which asks up to 23 applicable questions:
59
-
60
- ```bash
61
- npx agent-personalizer --full
62
- ```
62
+ The first install asks for a folder if `--dir` is missing, then which AIs you use and whether it may read your past sessions. The AI choices are pre-selected from installed Claude Code, Codex and Gemini CLI folders; Enter accepts them. Consent defaults to No. Level 1 is the default; `--level` selects another. There is no questionnaire. Working preferences keep safe defaults and remain editable through `--answers` or the saved config.
63
63
 
64
64
  | Level | What you get |
65
65
  |---|---|
@@ -75,11 +75,17 @@ npx agent-personalizer --dir . --ai claude,agents --level 1 --yes --defaults
75
75
 
76
76
  Node 22 or 24 (active LTS) is recommended; 18 or later runs. Published on npm with provenance. [Installation](docs/install.md) covers scripted answers, every flag, notes tools and manual copying.
77
77
 
78
- The tool runs locally after `npx` fetches the package. The installer and renderer make no network calls, send no telemetry and read no environment variables. Writes stay inside the folder you name, with edited files preserved and named.
78
+ The tool runs locally after `npx` fetches the package. The installer and renderer make no network calls and send no telemetry. Writes stay inside the folder you name, with edited files preserved and named.
79
+
80
+ ## Privacy
81
+
82
+ With your yes, learning reads up to 20 recent sessions kept by your selected Claude Code, Codex or Gemini CLI apps, plus Codex memory notes. It keeps typed messages, drops AI replies and tool output, and saves one local `.agent-personalizer/digest.md` ignored by git. The terminal lists files and counts, never message text. Your AI reads the digest, so its contents go to that provider again, like anything you paste in.
83
+
84
+ Reuse only history you are allowed to share. Past sessions can include other people's details; put their names or other private terms in `check/forbidden.local.txt` before accepting. Check your agreement for work or client accounts. `npx agent-personalizer learn --forget` deletes the digest, and uninstall removes it too; both leave your AI apps' history alone. agent-personalizer is not affiliated with Anthropic, OpenAI or Google, and their saved formats can change. See [learning and privacy](docs/learning.md).
79
85
 
80
86
  ## Keep it in sync
81
87
 
82
- Re-run the installer to change answers or upgrade an install. Use the interview or supply a JSON file:
88
+ Re-run the installer to refresh an install. It asks nothing and keeps your saved AIs, level and answers. To change answers, supply a JSON file:
83
89
 
84
90
  ```bash
85
91
  npx agent-personalizer --dir . --ai claude,agents --level 1 --yes --answers my-answers.json
@@ -89,7 +95,9 @@ Untouched installer files update to what a fresh install with those answers woul
89
95
 
90
96
  `USER.md` updates while it remains an untouched installer profile. An edited or pre-existing profile stays the source for every profile export, including ChatGPT. Changed onboarding answers are named so you can carry them into your profile by hand.
91
97
 
92
- At level 3, edit `USER.md` or a source in `rules/`, then render and check:
98
+ `LEARNED.md` is user-owned from its first install and never overwritten by a re-run. To gather newer evidence, run `npx agent-personalizer learn --dir .`; each read needs consent.
99
+
100
+ At level 3, edit `USER.md`, `LEARNED.md` or a source in `rules/`, then render and check:
93
101
 
94
102
  ```bash
95
103
  node render/render.cjs --dir .
@@ -121,10 +129,10 @@ The gate checks file text and paths against that list. A missing or malformed li
121
129
 
122
130
  ## Companion tools
123
131
 
124
- Select your notes tool during the full interview:
132
+ Select your notes tool through saved onboarding answers or an answers file:
125
133
 
126
134
  ```bash
127
- npx agent-personalizer --full
135
+ npx agent-personalizer --dir . --answers my-answers.json
128
136
  ```
129
137
 
130
138
  [Companion setup](docs/companions.md) explains notes connectors and how to turn onboarding answers into tool permissions and approval steps.
@@ -146,7 +154,7 @@ Choose targets with `npx agent-personalizer --dir . --ai claude,agents,gemini,ch
146
154
 
147
155
  ### How do I update my AI profile or change an answer?
148
156
 
149
- For answers, run `npx agent-personalizer --dir . --ai claude,agents --level 1 --yes --answers my-answers.json`. At level 3, edit `USER.md` or `rules/`, then run `node render/render.cjs --dir .`; re-paste changed chat exports.
157
+ For answers, run `npx agent-personalizer --dir . --answers my-answers.json`. At level 3, edit `USER.md`, `LEARNED.md` or `rules/`, then run `node render/render.cjs --dir .`; re-paste changed chat exports.
150
158
 
151
159
  ### How do I check generated instructions for drift?
152
160
 
@@ -158,11 +166,11 @@ Re-run `npx agent-personalizer --dir . --ai claude,agents --level 3 --yes --defa
158
166
 
159
167
  ### How do I uninstall agent-personalizer and keep my notes?
160
168
 
161
- Preview with `npx agent-personalizer --uninstall --dir . --dry`, then run `npx agent-personalizer --uninstall --dir .`. Edited files and user-written notes stay, and the log names retained installed files.
169
+ Preview with `npx agent-personalizer --uninstall --dir . --dry`, then run `npx agent-personalizer --uninstall --dir .`. Edited files, user-written notes and a `LEARNED.md` with entries stay; the local digest is removed and untouched files return byte for byte.
162
170
 
163
171
  ## Uninstall
164
172
 
165
- Preview with --uninstall --dry. Removal compares recorded install hashes, keeps edited files and notes, and lists any hook registration you must remove.
173
+ Preview with --uninstall --dry. Removal compares recorded install hashes, keeps edited files, notes and a `LEARNED.md` with entries, removes the local digest, and lists any hook registration you must remove.
166
174
 
167
175
  ```bash
168
176
  npx agent-personalizer --uninstall --dir . --dry
@@ -176,6 +184,7 @@ The inventory covers every path recorded by any install run, including earlier n
176
184
  Start at the [documentation index](docs/README.md):
177
185
 
178
186
  - **[Install and uninstall](docs/install.md):** flags, scripted answers, re-runs, upgrades and removal.
187
+ - **[Learning and privacy](docs/learning.md):** consent, session sources, evidence-backed questions, entries and forgetting the digest.
179
188
  - **[Instruction tiers](docs/tiers.md):** where each kind of instruction belongs.
180
189
  - **[Paste guide](docs/paste-guide.md):** how each AI loads its files and how to activate exports.
181
190
  - **[Companions](docs/companions.md):** notes connectors and enforcement tools.
package/SECURITY.md CHANGED
@@ -6,11 +6,13 @@ This is a small local tool: it reads your files, writes files into a folder you
6
6
 
7
7
  Use GitHub's private vulnerability reporting on this repository (Security tab → "Report a vulnerability"). That opens a private advisory only the maintainer can see. Please do not open a public issue for anything that could let an installer or renderer write outside the folder the user named, read a file it should not, or let `check/forbidden.local.txt` reach a commit.
8
8
 
9
+ Report a leak of session data through that private route too; describe the reproduction with invented messages and keep real session text out of the report.
10
+
9
11
  You will get an acknowledgement within 7 days and a fix or a reasoned "won't fix" within 30. Credit is given in the changelog unless you ask otherwise.
10
12
 
11
13
  ## Scope
12
14
 
13
- In scope: `bin/agent-personalizer.js`, `render/`, `check/gate.cjs`, `hooks/`, the templates and the harness. Out of scope: the AI products this repo writes files for, and the companion tools it links to (report those to their own projects).
15
+ In scope: `bin/`, including session reading, learning and removal, `render/`, `check/gate.cjs`, `hooks/`, the templates and the harness. Out of scope: the AI products this repo writes files for, and the companion tools it links to (report those to their own projects).
14
16
 
15
17
  ## What is already done
16
18
 
@@ -1,39 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
  /*
4
- agent-personalizer installer.
5
-
6
- npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
7
- [--answers <file.json>] [--defaults] [--full] [--yes]
8
-
9
- Interactive when flags are missing and stdin is a terminal. Non-interactive with flags.
10
- The ONBOARDING INTERVIEW (how to talk to you, output shape, what to read first, where the AI
11
- may write, how to save, what to ask before doing) runs interactively, or takes --answers
12
- <file.json>, or --defaults / --yes to accept every default. The answers are stored under
13
- "onboarding" in .agent-personalizer.json and rendered to AGENT_ONBOARDING.md; USER.md is
14
- generated from the same answers when it does not exist yet.
15
- Level 1 writes USER.md, AGENT_ONBOARDING.md and the home file(s); the rules render into the home
16
- file from the package's own rules/ and nothing is copied, so the home files name no notes folder
17
- (level 2 creates it, and level 2+ repoints them). Level 3 copies rules/ (yours to edit from
18
- then on) with the renderer, hook and gate. .agent-personalizer.json stores only the answers that
19
- differ from the defaults.
20
- Writes only the chosen AIs and the highest installed level. Re-runs replace untouched
21
- installer-owned copies using recorded hashes, with a static release-hash fallback for older
22
- installs. Edited files and pointer lines are kept and named. Previous notes folders stay in
23
- place and in the uninstall inventory. The config is merged; USER.md is regenerated only
24
- when it still equals the previous answer render. All writes roll back if rendering fails.
25
- PREFLIGHT: every path is probed and every existing rendered target is decoded and its marker
26
- block checked BEFORE the first write, so a refusal leaves the folder as it was. The notes
27
- folder the scaffold creates and the home files point at is your notes_path (disk tools) or
28
- notes/ (the fallback); a cloud tool gets no local notes folder at all. Refuses to write through any
29
- symlink or outside the install folder (the folder you name is followed once, via realpath;
30
- nothing beneath it may be a symlink). Reads no environment variables. Writes no secrets.
31
-
4
+ Local installer with consent-gated session learning. First installs ask for the AIs and
5
+ consent; saved installs re-render without questions. Answers remain editable through
6
+ --answers or the config. The complete plan is validated before any writes, and render
7
+ failures restore every changed file. Paths beneath the chosen folder never use symlinks.
32
8
  exit codes: 0 ok · 1 unexpected error · 2 refused or invalid input
33
9
  */
34
10
  const fs = require('fs');
35
11
  const path = require('path');
36
12
  const readline = require('readline');
13
+ const os = require('os');
37
14
  const crypto = require('crypto');
38
15
  const { execFileSync } = require('child_process');
39
16
  const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
@@ -53,7 +30,7 @@ let committing = false;
53
30
  function die(msg) { if (committing) throw new markers.Refusal(msg); console.error(`agent-personalizer: ${msg}`); process.exit(2); }
54
31
 
55
32
  const VALUE_OPTS = ['--dir', '--ai', '--level', '--answers'];
56
- const FLAG_OPTS = ['--yes', '--defaults', '--quick', '--full', '--uninstall', '--dry', '--help', '--version', '-h', '-v'];
33
+ const FLAG_OPTS = ['--forget', '--all-projects', '--yes', '--defaults', '--quick', '--full', '--uninstall', '--dry', '--help', '--version', '-h', '-v'];
57
34
  const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).version}
58
35
 
59
36
  npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
@@ -61,17 +38,20 @@ const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).vers
61
38
  [--help | -h] [--version | -v]
62
39
  npx agent-personalizer --uninstall --dir <folder> [--dry]
63
40
 
64
- Interactive when flags are missing and stdin is a terminal; the onboarding interview runs then.
65
- The interview is SHORT by default: the seven questions that change behaviour (name, tone, length,
66
- notes tool and path, write policy, always-ask), plus any question the notes tool you pick makes
67
- apply. Other answers keep their saved values, or take defaults on the first install.
68
- --full ask every question instead of the short set. Interactive only.
69
- --quick the short interview. It is now the default; the flag is kept so older commands still work.
70
- --answers a JSON file of answers, or "-" to read the JSON from stdin. Unknown keys and values are refused.
71
- --defaults the ANSWER SOURCE: accept every default without being asked. With or without --yes.
72
- --yes NON-INTERACTIVE MODE, not an answer source. It needs --dir, --ai and --level, and with no
73
- --answers it falls back to the defaults.
74
- --uninstall remove unchanged installed files; keep and name edited files and user text.
41
+ npx agent-personalizer learn [--dir <folder>] [--all-projects] [--yes]
42
+ npx agent-personalizer learn --forget [--dir <folder>]
43
+
44
+ First interactive install: choose your AIs, then choose whether to read your recent sessions.
45
+ Saved installs ask nothing and keep their AIs, level and answers unless you give replacements.
46
+ --full accepted for older commands; the interview is gone.
47
+ --quick accepted for older commands; the interview is gone.
48
+ --answers a JSON file of answers, or "-" to read JSON from stdin. Saved legacy keys stay valid.
49
+ --defaults accept defaults on first install; a re-run keeps saved answers.
50
+ --yes scripted first install: needs --dir, --ai and --level. Never reads session history.
51
+ learn with your yes, write a local digest for up to five evidence-backed questions.
52
+ --all-projects include sessions from projects other than --dir; default reads only --dir.
53
+ --forget with learn, remove the digest; your AI apps' own history stays as it is.
54
+ --uninstall remove unchanged installed files; keep edited files and LEARNED.md with entries.
75
55
  --dry preview --uninstall without changing files.
76
56
  Levels: 1 profile, onboarding and home file(s); nothing else (the rules render from the package)
77
57
  2 + the notes folder: its README, a weekly session log, a decisions log and an inbox
@@ -84,6 +64,7 @@ function parseArgs() {
84
64
  const argv = process.argv.slice(2);
85
65
  for (let i = 0; i < argv.length; i++) {
86
66
  const a = argv[i];
67
+ if (i === 0 && a === 'learn') { out.command = a; continue; }
87
68
  if (VALUE_OPTS.includes(a)) {
88
69
  if (a in out) die(`${a} given more than once`);
89
70
  const v = argv[i + 1];
@@ -103,7 +84,7 @@ if (ARGS['--version'] || ARGS['-v']) { process.stdout.write(require(path.join(PK
103
84
 
104
85
  async function ask(q, dflt, saved = false) {
105
86
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
106
- const a = await new Promise(res => rl.question(`${q}${dflt || saved ? ` [${dflt}]` : ''}: `, res));
87
+ const a = await new Promise(res => { rl.question(`${q}${dflt || saved ? ` [${dflt}]` : ''}: `, res); rl.once('close', () => res('')); });
107
88
  rl.close();
108
89
  return saved ? a.trim() : (a || dflt || '').trim();
109
90
  }
@@ -148,8 +129,7 @@ function probe(root, rel) {
148
129
  die('unreachable');
149
130
  }
150
131
 
151
- // Read the stored config once. The interview uses it before any directories or files are created;
152
- // non-interactive answer sources retain their existing handling below.
132
+ // Read the stored config before prompting, so saved installs ask nothing and keep their answers.
153
133
  function readConfig(root, level) {
154
134
  const { full: cfgPath, exists: cfgExists } = probe(root, '.agent-personalizer.json');
155
135
  let cfg = { targets: [], level };
@@ -187,6 +167,16 @@ function resolveDestination(dir) {
187
167
  }
188
168
 
189
169
  async function main() {
170
+ if (ARGS.command === 'learn') {
171
+ for (const opt of ['--ai', '--level', '--answers', '--defaults', '--quick', '--full', '--uninstall', '--dry'])
172
+ if (opt in ARGS) die(`${opt} is not a learn option`);
173
+ if (ARGS['--forget'] && ARGS['--all-projects']) die('--all-projects cannot be used with --forget');
174
+ if (ARGS['--forget'] && ARGS['--yes']) die('--forget and --yes are exclusive');
175
+ const learning = require('./learn.cjs');
176
+ return ARGS['--forget'] ? learning.forget(arg('--dir', '.')) : learning.learn({ dir: arg('--dir', '.'), yes: !!ARGS['--yes'], allProjects: !!ARGS['--all-projects'] });
177
+ }
178
+ if (ARGS['--forget']) die('--forget needs learn');
179
+ if (ARGS['--all-projects']) die('--all-projects needs learn');
190
180
  if (ARGS['--uninstall']) {
191
181
  if (!ARGS['--dir']) die('--uninstall needs --dir <folder>');
192
182
  for (const opt of ['--ai', '--level', '--answers', '--defaults', '--quick', '--full'])
@@ -194,93 +184,72 @@ async function main() {
194
184
  return require('./uninstall.cjs').uninstall(ARGS['--dir'], { dry: !!ARGS['--dry'] });
195
185
  }
196
186
  if (ARGS['--dry']) die('--dry needs --uninstall');
197
- const interactive = process.stdin.isTTY && !!!ARGS['--yes'];
198
- let dir = arg('--dir', null);
199
- let ais = arg('--ai', null);
200
- let level = arg('--level', null);
201
-
202
- if (interactive) {
203
- console.log('\nagent-personalizer\n');
204
- dir = dir || await ask('Folder to install into', '.');
187
+ if (ARGS['--full'] || ARGS['--quick']) console.log('The interview is gone; --full and --quick are accepted for older commands.');
188
+ const interactive = !!process.stdin.isTTY && !ARGS['--yes'];
189
+ let dir = arg('--dir', '.');
190
+ let destination = resolveDestination(dir);
191
+ let stored = readConfig(destination.root, 1);
192
+ // Looking in the current folder first lets a saved install re-run with no prompts or flags.
193
+ if (interactive && !ARGS['--dir'] && !stored.cfgExists) {
194
+ dir = await ask('Folder to install into', '.');
195
+ destination = resolveDestination(dir);
196
+ stored = readConfig(destination.root, 1);
197
+ }
198
+ if (!stored.cfgExists && !interactive && (!ARGS['--dir'] || !ARGS['--ai'] || !ARGS['--level'] || !ARGS['--yes']))
199
+ die('non-interactive run needs --dir, --ai and --level (and --yes)');
200
+ let ais = arg('--ai', stored.cfgExists ? (stored.cfg.targets || []).filter(t => AIS.includes(t)).join(',') : null);
201
+ let level = arg('--level', stored.cfgExists ? stored.cfg.level || 1 : 1);
202
+ if (interactive && !stored.cfgExists) {
205
203
  console.log('\nWhich AIs do you use? Comma-separated from:');
206
204
  for (const k of AIS) console.log(` ${k.padEnd(8)} ${AI_LABEL[k]}`);
207
- ais = ais || await ask('\nAIs', 'claude,agents');
208
- console.log('\nLevels: 1 profile, onboarding and home file(s) · 2 + the notes folder · 3 + renderer, session-start hook, gate and your own rules/');
209
- level = level || await ask('Level', '1');
205
+ // Existence is the only inspection of app folders permitted before consent.
206
+ const found = [['.claude', 'claude'], ['.codex', 'agents'], ['.gemini', 'gemini']]
207
+ .filter(([folder]) => fs.existsSync(path.join(os.homedir(), folder))).map(([, ai]) => ai);
208
+ ais = await ask('\nAIs', ais || (found.length ? found.join(',') : 'claude,agents'));
210
209
  }
211
- if (!dir || !ais || !level) die('non-interactive run needs --dir, --ai and --level (and --yes)');
212
210
  if (!/^[1-4]$/.test(String(level))) die('level must be exactly 1, 2 or 3');
213
211
  level = Number(level);
214
- // Keep the former level accepted so existing scripts run. Routing has its own package.
215
212
  if (level === 4) console.log('note: --level 4 installs exactly what --level 3 installs. For model routing, see https://github.com/aunysillyme/model-orchestrator');
216
- const targets = String(ais).split(',').map(s => s.trim()).filter(Boolean);
213
+ const targets = String(ais || '').split(',').map(s => s.trim()).filter(Boolean);
217
214
  const bad = targets.filter(t => !AIS.includes(t));
218
215
  if (bad.length) die(`unknown AI: ${bad.join(', ')} (known: ${AIS.join(', ')})`);
219
216
  if (!targets.length) die('no AIs chosen');
220
217
  if (new Set(targets).size !== targets.length) die(`an AI is listed twice in --ai (${targets.join(',')}); list each once`);
221
218
 
222
- // Onboarding answers: a file, the defaults, or the interview. Validated before anything is created.
223
- let answers = null, answersSource = '';
224
219
  const answersFile = arg('--answers', null);
225
220
  if (answersFile && arg('--defaults', false)) die('--answers and --defaults are exclusive');
226
- if (arg('--quick', false) && arg('--full', false)) die('--quick and --full are exclusive; the short interview is the default');
227
- if (arg('--quick', false) && (answersFile || arg('--defaults', false) || !interactive)) die('--quick is the short interview; it needs a terminal and no --answers, --defaults or --yes');
228
- if (arg('--full', false) && (answersFile || arg('--defaults', false) || !interactive)) die('--full is the long interview; it needs a terminal and no --answers, --defaults or --yes');
229
- let destination = null, stored = null;
221
+ let answers = stored.prevAnswers || onboarding.defaults();
222
+ let answersSource = stored.prevAnswers ? 'kept from .agent-personalizer.json' : 'defaults (editable through --answers or .agent-personalizer.json)';
230
223
  if (answersFile) {
231
224
  let raw;
232
225
  const label = answersFile === '-' ? 'stdin' : answersFile;
233
- try { raw = JSON.parse(answersFile === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(answersFile), 'utf8')); } catch (e) { die(`--answers: cannot read ${label} as JSON (${e.message})`); }
226
+ try { raw = JSON.parse(answersFile === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(answersFile), 'utf8')); }
227
+ catch (e) { die(`--answers: cannot read ${label} as JSON (${e.message})`); }
234
228
  try { answers = onboarding.validate(raw); } catch (e) { die(`--answers: ${e.message}`); }
235
229
  answersSource = `from ${label}`;
236
- } else if (arg('--defaults', false) || !interactive) {
237
- answers = onboarding.defaults();
238
- if (!arg('--defaults', false) && !process.stdin.isTTY) console.error('agent-personalizer: stdin is not a terminal, so the interview cannot run; using the default answers (pass --answers <file.json>, --answers -, or --defaults to silence this)');
239
- answersSource = process.stdin.isTTY ? 'defaults (pass --answers <file.json>, or run without --yes, to answer the interview)' : 'defaults (stdin is not a terminal; pass --answers <file.json> or --answers - to script them)';
240
- } else {
241
- destination = resolveDestination(dir);
242
- const { requested, root, missing } = destination;
243
- if (!missing.length && !fs.lstatSync(root).isDirectory()) die(`--dir ${requested} is not a directory`);
244
- stored = readConfig(root, level);
245
- const saved = stored.prevAnswers;
246
- const full = !!arg('--full', false);
247
- console.log(saved
248
- ? '\nOnboarding: how should an AI work with you? Enter keeps the saved answer shown in brackets.'
249
- : '\nOnboarding: how should an AI work with you? Enter accepts the default in brackets.');
250
- console.log(full
251
- ? `Full interview: up to ${onboarding.QUESTIONS.length} questions, some of which apply only to certain notes tools.\n`
252
- : `Short interview: the ${onboarding.QUICK.length} questions that change behaviour, plus any the notes tool you pick makes apply. ${saved ? 'Every other answer keeps its saved value' : 'Every other answer takes its default'}; --full asks up to ${onboarding.QUESTIONS.length}, skipping questions that do not apply to your notes tool.\n`);
253
- const raw = saved ? onboarding.interviewAnswers(saved) : {};
254
- for (const q of onboarding.QUESTIONS) {
255
- if (!onboarding.asks(q, raw, full)) continue;
256
- if (q.options) for (const [v, l] of q.options) console.log(` ${v.padEnd(30)} ${l}`);
257
- const value = onboarding.interviewDefault(q, saved);
258
- const dflt = Array.isArray(value) ? value.join(', ') : value;
259
- raw[q.id] = onboarding.parseAnswer({ ...q, default: value }, await ask(q.ask, dflt || '', !!saved));
260
- }
261
- try { answers = onboarding.validate(raw); } catch (e) { die(`onboarding: ${e.message}`); }
262
- answersSource = full ? 'your interview answers' : `your short-interview answers (the rest are ${saved ? 'kept saved values' : 'defaults'})`;
263
230
  }
231
+ const learnRequested = interactive && !stored.cfgExists
232
+ ? await require('./learn.cjs').requestConsent() : false;
264
233
 
265
234
  // The folder you name is followed once (realpath of its deepest EXISTING ancestor); the
266
235
  // missing tail is created one level at a time, so nothing is ever created through a
267
236
  // symlink that did not exist when you ran the command. Everything beneath root is then
268
237
  // symlink-free by construction (safeDest refuses any).
269
- const { requested, root, realExisting, missing } = destination || resolveDestination(dir);
238
+ const { requested, root, realExisting, missing } = destination;
270
239
  let creating = realExisting;
271
240
  for (const part of missing) { creating = path.join(creating, part); fs.mkdirSync(creating); }
272
241
  if (!fs.lstatSync(root).isDirectory()) die(`--dir ${requested} is not a directory`);
273
242
  // Config: the one file this installer rewrites. Read and VALIDATED here, before the first write, so a malformed
274
243
  // stored config refuses the whole run and leaves the folder untouched. Existing onboarding answers are kept unless
275
- // --answers or the interview supplied new ones; targets are merged; "onboarding" is always a target.
244
+ // --answers supplied new ones; explicit targets replace the saved selection; "onboarding" is always a target.
276
245
  const storedConfig = stored || readConfig(root, level);
277
246
  const { cfgPath, cfgExists, prevAnswers } = storedConfig;
278
247
  let cfg = storedConfig.cfg;
279
248
  if (prevAnswers && !answersFile && answersSource.startsWith('defaults')) {
280
249
  answers = prevAnswers; answersSource = 'kept from .agent-personalizer.json';
281
250
  }
282
- const allTargets = [...new Set([...(Array.isArray(cfg.targets) ? cfg.targets : []), ...targets, 'onboarding'])];
283
- const installedLevel = Math.max(level, cfg.level || 0);
251
+ const allTargets = [...new Set([...targets, 'onboarding'])];
252
+ const installedLevel = level;
284
253
  const effectiveLevel = Math.min(installedLevel, 3);
285
254
  const base = onboarding.baseFor(answers); // the folder scaffolds and home-file pointers use
286
255
  const kind = onboarding.kindOf(answers);
@@ -349,6 +318,7 @@ async function main() {
349
318
  // USER.md: yours once it exists. Regenerated only when it still equals the render of the PREVIOUS
350
319
  // answers byte for byte (you never touched it) and the answers changed. Otherwise kept, and any
351
320
  // changed answer that the kept file still carries the old value of is named as a conflict.
321
+ const entries = markers.readLearned(root);
352
322
  const user = probe(root, 'USER.md');
353
323
  let userAction = 'create';
354
324
  let staleNotesInUser = false;
@@ -359,14 +329,15 @@ async function main() {
359
329
  // Two candidate renders per answer set, one saying the notes folder is there and one saying it is
360
330
  // not (#25). A match against EITHER means the file is still exactly what this installer wrote,
361
331
  // so regenerating loses nothing; anything else is yours and is kept.
362
- const untouched = (ans) => [true, false].some(ns => current === onboarding.renderUser(ans, { notesScaffolded: ns }));
332
+ const untouched = (ans) => [true, false].some(ns => current === onboarding.renderUser(ans, { notesScaffolded: ns, entries }));
363
333
  if (changedKeys.length) {
364
334
  userAction = untouched(prevAnswers) ? 'regenerate' : 'conflict';
365
- } else if (notesScaffolded && current === onboarding.renderUser(answers, { notesScaffolded: false })) {
335
+ } else if (notesScaffolded && current === onboarding.renderUser(answers, { notesScaffolded: false, entries })) {
366
336
  // Same answers, but the file says the folder is absent and it is not (this run created it, or
367
337
  // it was already there). The real paths go back, and only on a byte-for-byte match.
368
338
  userAction = 'relevel';
369
- } else userAction = 'keep';
339
+ } else if (recordedHash(cfg, 'USER.md') && sha256(Buffer.from(current)) === recordedHash(cfg, 'USER.md') && current !== onboarding.renderUser(answers, { notesScaffolded, entries })) userAction = 'refresh';
340
+ else userAction = 'keep';
370
341
  // A kept file that does not name the folder README while the folder is there is stale, however it
371
342
  // was worded: keying the notice on one sentence let an edit to that sentence silence it (finding 6).
372
343
  if (userAction === 'keep' && notesScaffolded && !current.includes(`\`${base}/README.md\``)) staleNotesInUser = true;
@@ -392,6 +363,8 @@ async function main() {
392
363
  if (migration.changed) {
393
364
  const why = effectiveLevel >= 3 && (cfg.level || 1) < 3 ? 'rule pointers now name rules/, which this level installs' : 'unchanged installer pointer lines migrated to the new answers';
394
365
  upgrades.push({ rel: name, bytes: Buffer.from(migration.text), report: `update ${name} (${why})` });
366
+ // Only an unchanged owned file can advance its whole-file ownership after migration.
367
+ if (installedHashes[name] === sha256(Buffer.from(current))) installedHashes[name] = sha256(Buffer.from(migration.text));
395
368
  }
396
369
  }
397
370
 
@@ -423,9 +396,13 @@ async function main() {
423
396
  const destination = probe(root, p.rel);
424
397
  const bytes = p.src ? fs.readFileSync(p.src) : Buffer.from(p.text);
425
398
  if (HOME_NAMES.has(p.rel)) {
426
- if (!destination.exists) writes.push({ rel: p.rel, bytes, report: `wrote ${p.rel} (${p.note})` });
399
+ if (!destination.exists) {
400
+ writes.push({ rel: p.rel, bytes, report: `wrote ${p.rel} (${p.note})` });
401
+ installedHashes[p.rel] = sha256(bytes);
402
+ }
427
403
  continue;
428
404
  }
405
+ if (destination.exists && p.firstOnly) { console.log(`kept ${p.rel} (user-owned)`); continue; }
429
406
  if (destination.exists) {
430
407
  const existing = fs.readFileSync(destination.full);
431
408
  const old = previousPlan.find(prior => prior.rel === p.rel);
@@ -453,7 +430,7 @@ async function main() {
453
430
  // stays, even when no current recipe mentions it; its hashes remain in the inventory.
454
431
  const currentPaths = new Set(plan.map(p => p.rel));
455
432
  for (const rel of Object.keys(installedHashes)) {
456
- if (!rel.startsWith('rules/') || currentPaths.has(rel)) continue;
433
+ if (effectiveLevel < 3 || !rel.startsWith('rules/') || currentPaths.has(rel)) continue;
457
434
  const destination = probe(root, rel);
458
435
  if (!destination.exists) continue;
459
436
  if (!fs.lstatSync(destination.full).isFile()) die(`${rel} is not a regular file; nothing was written`);
@@ -462,12 +439,13 @@ async function main() {
462
439
  }
463
440
  if (previousBase && previousBase !== base && previousNotesExists) console.log(`kept ${previousBase}/ (previous notes folder; current notes folder: ${base}/; kept in the uninstall inventory)`);
464
441
 
465
- if (userAction === 'create' || userAction === 'regenerate' || userAction === 'relevel') {
466
- const rendered = onboarding.renderUser(answers, { notesScaffolded });
442
+ if (['create', 'regenerate', 'relevel', 'refresh'].includes(userAction)) {
443
+ const rendered = onboarding.renderUser(answers, { notesScaffolded, entries });
467
444
  writes.push({ rel: 'USER.md', bytes: Buffer.from(rendered) });
468
445
  installedHashes['USER.md'] = sha256(Buffer.from(rendered));
469
446
  if (userAction === 'create') console.log('wrote USER.md (from your answers)');
470
447
  else if (userAction === 'regenerate') console.log(`update USER.md (regenerated: it matched your previous answers byte for byte; changed: ${changedKeys.join(', ')})`);
448
+ else if (userAction === 'refresh') console.log('update USER.md (untouched installer profile refreshed from your entries)');
471
449
  else console.log(`update USER.md (notes pointers now name ${base}/, which is there; it matched the render that said it was not, byte for byte)`);
472
450
  }
473
451
  else if (userAction === 'conflict') {
@@ -481,6 +459,7 @@ async function main() {
481
459
  // Snapshot every possible output and check every parent before the first write. The
482
460
  // renderer runs from this package, not from a potentially edited installed executable.
483
461
  const outputPaths = new Set(['.agent-personalizer.json', ...writes.map(p => p.rel), ...removals.map(p => p.rel)]);
462
+ if (learnRequested) { outputPaths.add('.agent-personalizer/digest.md'); outputPaths.add('.agent-personalizer/.gitignore'); }
484
463
  for (const target of allTargets.map(key => TARGETS[key])) {
485
464
  outputPaths.add(target.file);
486
465
  for (const rel of Object.values(target.boxFiles || {})) outputPaths.add(rel);
@@ -510,7 +489,7 @@ async function main() {
510
489
  try { fs.accessSync(ancestor, fs.constants.W_OK); } catch (_) { die(`${rel}: parent is not writable; nothing was written`); }
511
490
  }
512
491
  for (const rel of newDirectories) createdDirectories.add(rel);
513
- cfg = { ...cfg, targets: allTargets, level: installedLevel, onboarding: onboarding.sparse(answers), preservedTargets: [...preservedTargets], installed: installedHashes, createdDirectories: [...createdDirectories].sort(), toolingVersion, toolingVersions };
492
+ cfg = { ...cfg, targets: allTargets, level: installedLevel, onboarding: onboarding.sparse(answers), preservedTargets: [...preservedTargets].filter(t => allTargets.includes(t)), installed: installedHashes, createdDirectories: [...createdDirectories].sort(), toolingVersion, toolingVersions };
514
493
  writes.push({ rel: '.agent-personalizer.json', bytes: Buffer.from(JSON.stringify(cfg, null, 2) + '\n'), report: `${cfgExists ? 'update' : 'wrote '} .agent-personalizer.json (onboarding: ${answersSource})` });
515
494
  const replace = (rel, bytes, mode) => {
516
495
  const destination = safeDest(root, rel);
@@ -544,6 +523,7 @@ async function main() {
544
523
  }
545
524
  // Include renderer outputs in rollback even when it committed before reporting a failure.
546
525
  for (const rel of outputPaths) touched.add(rel);
526
+ if (learnRequested) await require('./learn.cjs').learn({ dir: root, consented: true });
547
527
  execFileSync(process.execPath, [path.join(PKG, 'render', 'render.cjs'), '--dir', root, '--targets', allTargets.join(',')], { stdio: 'inherit' });
548
528
  } catch (e) {
549
529
  const incomplete = [];
@@ -562,6 +542,10 @@ async function main() {
562
542
  throw e;
563
543
  } finally { committing = false; }
564
544
 
545
+ require('./git-exclude.cjs').protect(root);
546
+
547
+ if (interactive && !cfgExists && !learnRequested) console.log('Nothing was read. Run npx agent-personalizer learn any time.');
548
+
565
549
  const DOCS = onboarding.DOCS;
566
550
  // the rerun command a user can actually type: the npx form when this ran from npm's cache, else the local path that just worked
567
551
  const SELF = /[\\/]_npx[\\/]|[\\/]node_modules[\\/]/.test(PKG) ? 'npx agent-personalizer' : `node ${path.relative(process.cwd(), path.join(PKG, 'bin', 'agent-personalizer.js')) || 'bin/agent-personalizer.js'}`;
@@ -584,7 +568,7 @@ async function main() {
584
568
  steps.push('Read AGENT_ONBOARDING.md once: that is what every AI will be told about working with you. Re-run this installer with new answers to change it.\n USER.md is yours to edit freely; the onboarding file is regenerated from .agent-personalizer.json.');
585
569
  steps.push(level >= 3
586
570
  ? `Re-render after editing: node render/render.cjs --dir ${DIR} (drift check: add --check)`
587
- : `Re-render after editing by running this installer again (it refreshes generated outputs and untouched installer copies, and keeps and names edited files):\n ${SELF} --dir ${DIR} --ai ${targets.join(',')} --level ${level} --yes`);
571
+ : `Re-render after editing by running this installer again (it refreshes generated outputs and untouched installer copies, and keeps and names edited files):\n ${SELF} --dir ${DIR}`);
588
572
  steps.push([
589
573
  auto.length ? `Read from ${root} automatically, nothing to paste: ${auto.join(', ')}.` : null,
590
574
  paste.length ? `Still needs a paste: ${paste.join('; ')}.` : null,
@@ -596,13 +580,13 @@ async function main() {
596
580
  steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
597
581
  if (answers.notes_tool === 'obsidian') console.log(answers.obsidian_tc === 'yes'
598
582
  ? `\nCompanion: the onboarding file routes the AI through obsidian-tc; configure its folder ACLs from your off-limits answer and its human-in-the-loop list from your always-ask answer. See ${DOCS}/companions.md`
599
- : `\nCompanion: your notes are an Obsidian vault and the AI will work on the folder directly. obsidian-tc would give it governed access (folder ACLs, human-in-the-loop, audit log): \`npx obsidian-tc /path/to/vault\`, then re-run this installer and answer yes. See ${DOCS}/companions.md`);
583
+ : `\nCompanion: your notes are an Obsidian vault and the AI will work on the folder directly. obsidian-tc would give it governed access (folder ACLs, human-in-the-loop, audit log): \`npx obsidian-tc /path/to/vault\`, then set obsidian_tc to yes through --answers. See ${DOCS}/companions.md`);
600
584
  else if (answers.notes_tool === 'notion' || answers.notes_tool === 'google-docs') console.log(`\nCompanion: connect ${answers.notes_tool === 'notion' ? 'Notion' : 'Google Drive / Docs'} through your AI's own connector settings (where the app offers one); the onboarding file already names the door and the write posture, and tells the AI to make no filesystem writes for these notes. See ${DOCS}/companions.md`);
601
585
  else if (answers.notes_tool === 'apple-notes') console.log(`\nCompanion: Apple Notes needs a separately installed local Apple Notes MCP; no AI app ships one built in. Until you connect one, the onboarding file already limits the AI to reading and creating new notes. See ${DOCS}/companions.md`);
602
586
  else if (answers.notes_tool === 'other') console.log(`\nNote: "${answers.notes_tool_name || 'your notes tool'}" is unknown to this kit; the onboarding file tells the AI to ask before its first write there and to use the local fallback folder notes/ meanwhile.`);
603
587
  else if (['onenote', 'evernote'].includes(answers.notes_tool)) console.log(`\nNote: ${answers.notes_tool} has no first-class agent door today; the onboarding file treats it as read-only. See ${DOCS}/companions.md`);
604
588
  if (targets.length > 1) console.log(`\nSeveral agents? Read ${DOCS}/companions.md on the Context Layer: purpose-bound bundles and receipts for every delegation.`);
605
- console.log('\nNothing here read an environment variable or wrote a secret.');
589
+ console.log('\nThe installer made no network calls.');
606
590
  console.log('\nIf this saved you time, a star helps people find it: https://github.com/aunysillyme/agent-personalizer');
607
591
  }
608
592