agent-personalizer 0.7.1 → 0.8.0
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 +28 -1
- package/CLA.md +1 -1
- package/README.md +25 -14
- package/SECURITY.md +3 -1
- package/bin/agent-personalizer.js +79 -105
- package/bin/install-plan.cjs +3 -0
- package/bin/known-hashes.json +54 -0
- package/bin/learn.cjs +185 -0
- package/bin/sessions.cjs +392 -0
- package/bin/uninstall.cjs +30 -4
- package/check/gate.cjs +4 -3
- package/docs/README.md +2 -1
- package/docs/companions.md +2 -2
- package/docs/guarantees.md +13 -3
- package/docs/install.md +28 -18
- package/docs/learning.md +99 -0
- package/docs/paste-guide.md +4 -4
- package/docs/tiers.md +4 -4
- package/examples/freelance-illustrator/.agent-personalizer.json +3 -3
- package/examples/freelance-illustrator/AGENTS.md +67 -3
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +4 -7
- package/examples/freelance-illustrator/CLAUDE.md +67 -3
- package/examples/freelance-illustrator/LEARNED.md +14 -0
- package/examples/freelance-illustrator/USER.md +6 -1
- package/examples/freelance-illustrator/rules/00-read-the-profile-first.md +1 -1
- package/examples/freelance-illustrator/rules/65-ask-before-it-repeats.md +18 -0
- package/examples/freelance-illustrator/rules/70-their-words-point-at-the-thing.md +15 -0
- package/examples/freelance-illustrator/rules/80-symptoms-are-not-causes.md +15 -0
- package/examples/freelance-illustrator/rules/90-surface-what-they-cant-see.md +15 -0
- package/examples/freelance-illustrator/rules/README.md +59 -0
- package/examples/lab-technician/.agent-personalizer.json +38 -0
- package/examples/lab-technician/AGENTS.md +243 -0
- package/examples/lab-technician/AGENT_ONBOARDING.md +64 -0
- package/examples/lab-technician/CLAUDE.md +247 -0
- package/examples/lab-technician/LEARNED.md +14 -0
- package/examples/lab-technician/USER.md +53 -0
- package/examples/lab-technician/notes/README.md +26 -0
- package/examples/lab-technician/notes/decisions.md +4 -0
- package/examples/lab-technician/notes/inbox/2026-10-06-observation-table.md +3 -0
- package/examples/lab-technician/notes/inbox/README.md +7 -0
- package/examples/lab-technician/notes/sessions/2026-W41.md +7 -0
- package/examples/lab-technician/rules/00-read-the-profile-first.md +24 -0
- package/examples/lab-technician/rules/10-evidence-before-assertion.md +24 -0
- package/examples/lab-technician/rules/20-one-owner-per-rule.md +24 -0
- package/examples/lab-technician/rules/30-folder-index-is-part-of-the-change.md +26 -0
- package/examples/lab-technician/rules/40-sign-every-edit.md +25 -0
- package/examples/lab-technician/rules/50-output-style.md +21 -0
- package/examples/lab-technician/rules/60-act-or-ask.md +30 -0
- package/examples/lab-technician/rules/65-ask-before-it-repeats.md +18 -0
- package/examples/lab-technician/rules/70-their-words-point-at-the-thing.md +15 -0
- package/examples/lab-technician/rules/80-symptoms-are-not-causes.md +15 -0
- package/examples/lab-technician/rules/90-surface-what-they-cant-see.md +15 -0
- package/examples/lab-technician/rules/README.md +59 -0
- package/examples/product-designer/.agent-personalizer.json +38 -0
- package/examples/product-designer/AGENTS.md +243 -0
- package/examples/product-designer/AGENT_ONBOARDING.md +63 -0
- package/examples/product-designer/CLAUDE.md +247 -0
- package/examples/product-designer/LEARNED.md +14 -0
- package/examples/product-designer/USER.md +53 -0
- package/examples/product-designer/notes/README.md +26 -0
- package/examples/product-designer/notes/decisions.md +4 -0
- package/examples/product-designer/notes/inbox/2026-10-06-cancellation-wording.md +8 -0
- package/examples/product-designer/notes/inbox/README.md +7 -0
- package/examples/product-designer/notes/sessions/2026-W41.md +7 -0
- package/examples/product-designer/rules/00-read-the-profile-first.md +24 -0
- package/examples/product-designer/rules/10-evidence-before-assertion.md +24 -0
- package/examples/product-designer/rules/20-one-owner-per-rule.md +24 -0
- package/examples/product-designer/rules/30-folder-index-is-part-of-the-change.md +26 -0
- package/examples/product-designer/rules/40-sign-every-edit.md +25 -0
- package/examples/product-designer/rules/50-output-style.md +21 -0
- package/examples/product-designer/rules/60-act-or-ask.md +30 -0
- package/examples/product-designer/rules/65-ask-before-it-repeats.md +18 -0
- package/examples/product-designer/rules/70-their-words-point-at-the-thing.md +15 -0
- package/examples/product-designer/rules/80-symptoms-are-not-causes.md +15 -0
- package/examples/product-designer/rules/90-surface-what-they-cant-see.md +15 -0
- package/examples/product-designer/rules/README.md +59 -0
- package/hooks/README.md +1 -1
- package/llms.txt +6 -2
- package/package.json +2 -2
- package/render/onboarding.cjs +111 -45
- package/render/render.cjs +60 -12
- package/rules/00-read-the-profile-first.md +1 -1
- package/rules/65-ask-before-it-repeats.md +18 -0
- package/rules/70-their-words-point-at-the-thing.md +15 -0
- package/rules/80-symptoms-are-not-causes.md +15 -0
- package/rules/90-surface-what-they-cant-see.md +15 -0
- package/rules/README.md +4 -0
- package/templates/LEARNED.md +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ Every entry names the adversarial audit round that produced it where one did. Au
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.8.0] - 2026-10-06
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
- `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.
|
|
15
|
+
- `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.
|
|
16
|
+
- 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.
|
|
17
|
+
- 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.
|
|
18
|
+
- Learning and privacy documentation, synthetic session fixtures, and two more invented example users with different entries.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- 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.
|
|
23
|
+
- 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.
|
|
24
|
+
- Uninstall always keeps `LEARNED.md` and removes the digest. Non-interactive installs never read sessions; scripted consent uses `learn --yes`.
|
|
25
|
+
- Privacy guidance explains local session access, AI provider visibility, other people's details, work accounts, private-list filtering and undo.
|
|
26
|
+
|
|
27
|
+
## [0.7.2] - 2026-10-06
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- The Contributor License Agreement defines a Contribution as work submitted through a pull request, matching the pull request checkbox that records agreement.
|
|
32
|
+
- The README Contributing section links the Contributor License Agreement and explains how agreement is recorded.
|
|
33
|
+
|
|
9
34
|
## [0.7.1] - 2026-10-06
|
|
10
35
|
|
|
11
36
|
### Changed
|
|
@@ -258,7 +283,9 @@ Thirteen issues (#3 to #15) filed against `5972b32` by an independent installati
|
|
|
258
283
|
- Installer: safe destination resolution, strict options, duplicate `--ai` refused, `--dir` created one level at a time.
|
|
259
284
|
- Harness: exact exit codes, adversarial fixtures, fault injection for the rollback path.
|
|
260
285
|
|
|
261
|
-
[Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.
|
|
286
|
+
[Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.0...HEAD
|
|
287
|
+
[0.8.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.2...v0.8.0
|
|
288
|
+
[0.7.2]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.1...v0.7.2
|
|
262
289
|
[0.7.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.7.0...v0.7.1
|
|
263
290
|
[0.7.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.6.5...v0.7.0
|
|
264
291
|
[0.6.5]: https://github.com/aunysillyme/agent-personalizer/compare/v0.6.4...v0.6.5
|
package/CLA.md
CHANGED
|
@@ -7,7 +7,7 @@ To agree, tick the Contributor License Agreement box in your pull request descri
|
|
|
7
7
|
## 1. Definitions
|
|
8
8
|
|
|
9
9
|
- **"You"** means the person or legal entity submitting a Contribution.
|
|
10
|
-
- **"Contribution"** means any original work of authorship, including any changes or additions to existing work, that You intentionally submit to Auny LLC for inclusion in this project
|
|
10
|
+
- **"Contribution"** means any original work of authorship, including any changes or additions to existing work, that You intentionally submit to Auny LLC for inclusion in this project through a pull request.
|
|
11
11
|
- **"Auny LLC"** means Auny LLC, a New York limited liability company, the owner and maintainer of this project.
|
|
12
12
|
|
|
13
13
|
## 2. Copyright license
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/agent-personalizer) [](https://github.com/aunysillyme/agent-personalizer/actions/workflows/harness.yml) [](https://github.com/aunysillyme/agent-personalizer/blob/main/CHANGELOG.md) [](LICENSE)
|
|
4
4
|
|
|
5
|
-
**
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
132
|
+
Select your notes tool through saved onboarding answers or an answers file:
|
|
125
133
|
|
|
126
134
|
```bash
|
|
127
|
-
npx agent-personalizer --
|
|
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 . --
|
|
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
|
|
169
|
+
Preview with `npx agent-personalizer --uninstall --dir . --dry`, then run `npx agent-personalizer --uninstall --dir .`. Edited files, user-written notes and `LEARNED.md` stay; the local digest is removed.
|
|
162
170
|
|
|
163
171
|
## Uninstall
|
|
164
172
|
|
|
165
|
-
Preview with --uninstall --dry. Removal compares recorded install hashes, keeps edited files and
|
|
173
|
+
Preview with --uninstall --dry. Removal compares recorded install hashes, keeps edited files, notes and `LEARNED.md`, 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.
|
|
@@ -189,6 +198,8 @@ Start at the [documentation index](docs/README.md):
|
|
|
189
198
|
|
|
190
199
|
Contributions are welcome: a new AI target, a notes tool, an example user, or a failure you hit with steps to reproduce it. [CONTRIBUTING.md](CONTRIBUTING.md) covers the rule format and checks; [MAINTAINERS.md](MAINTAINERS.md) names the owner and release responsibilities.
|
|
191
200
|
|
|
201
|
+
Pull requests are accepted under the [contributor license agreement](CLA.md); the checkbox in the pull request template records your agreement.
|
|
202
|
+
|
|
192
203
|
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.
|
|
193
204
|
|
|
194
205
|
## License
|
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
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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', '--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,19 @@ 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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
--
|
|
70
|
-
--
|
|
71
|
-
--
|
|
72
|
-
--
|
|
73
|
-
|
|
74
|
-
|
|
41
|
+
npx agent-personalizer learn [--dir <folder>] [--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
|
+
--forget with learn, remove the digest; your AI apps' own history stays as it is.
|
|
53
|
+
--uninstall remove unchanged installed files; keep LEARNED.md and edited files.
|
|
75
54
|
--dry preview --uninstall without changing files.
|
|
76
55
|
Levels: 1 profile, onboarding and home file(s); nothing else (the rules render from the package)
|
|
77
56
|
2 + the notes folder: its README, a weekly session log, a decisions log and an inbox
|
|
@@ -84,6 +63,7 @@ function parseArgs() {
|
|
|
84
63
|
const argv = process.argv.slice(2);
|
|
85
64
|
for (let i = 0; i < argv.length; i++) {
|
|
86
65
|
const a = argv[i];
|
|
66
|
+
if (i === 0 && a === 'learn') { out.command = a; continue; }
|
|
87
67
|
if (VALUE_OPTS.includes(a)) {
|
|
88
68
|
if (a in out) die(`${a} given more than once`);
|
|
89
69
|
const v = argv[i + 1];
|
|
@@ -103,7 +83,7 @@ if (ARGS['--version'] || ARGS['-v']) { process.stdout.write(require(path.join(PK
|
|
|
103
83
|
|
|
104
84
|
async function ask(q, dflt, saved = false) {
|
|
105
85
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
106
|
-
const a = await new Promise(res => rl.question(`${q}${dflt || saved ? ` [${dflt}]` : ''}: `, res));
|
|
86
|
+
const a = await new Promise(res => { rl.question(`${q}${dflt || saved ? ` [${dflt}]` : ''}: `, res); rl.once('close', () => res('')); });
|
|
107
87
|
rl.close();
|
|
108
88
|
return saved ? a.trim() : (a || dflt || '').trim();
|
|
109
89
|
}
|
|
@@ -148,8 +128,7 @@ function probe(root, rel) {
|
|
|
148
128
|
die('unreachable');
|
|
149
129
|
}
|
|
150
130
|
|
|
151
|
-
// Read the stored config
|
|
152
|
-
// non-interactive answer sources retain their existing handling below.
|
|
131
|
+
// Read the stored config before prompting, so saved installs ask nothing and keep their answers.
|
|
153
132
|
function readConfig(root, level) {
|
|
154
133
|
const { full: cfgPath, exists: cfgExists } = probe(root, '.agent-personalizer.json');
|
|
155
134
|
let cfg = { targets: [], level };
|
|
@@ -187,6 +166,14 @@ function resolveDestination(dir) {
|
|
|
187
166
|
}
|
|
188
167
|
|
|
189
168
|
async function main() {
|
|
169
|
+
if (ARGS.command === 'learn') {
|
|
170
|
+
for (const opt of ['--ai', '--level', '--answers', '--defaults', '--quick', '--full', '--uninstall', '--dry'])
|
|
171
|
+
if (opt in ARGS) die(`${opt} is not a learn option`);
|
|
172
|
+
if (ARGS['--forget'] && ARGS['--yes']) die('--forget and --yes are exclusive');
|
|
173
|
+
const learning = require('./learn.cjs');
|
|
174
|
+
return ARGS['--forget'] ? learning.forget(arg('--dir', '.')) : learning.learn({ dir: arg('--dir', '.'), yes: !!ARGS['--yes'] });
|
|
175
|
+
}
|
|
176
|
+
if (ARGS['--forget']) die('--forget needs learn');
|
|
190
177
|
if (ARGS['--uninstall']) {
|
|
191
178
|
if (!ARGS['--dir']) die('--uninstall needs --dir <folder>');
|
|
192
179
|
for (const opt of ['--ai', '--level', '--answers', '--defaults', '--quick', '--full'])
|
|
@@ -194,93 +181,72 @@ async function main() {
|
|
|
194
181
|
return require('./uninstall.cjs').uninstall(ARGS['--dir'], { dry: !!ARGS['--dry'] });
|
|
195
182
|
}
|
|
196
183
|
if (ARGS['--dry']) die('--dry needs --uninstall');
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
dir =
|
|
184
|
+
if (ARGS['--full'] || ARGS['--quick']) console.log('The interview is gone; --full and --quick are accepted for older commands.');
|
|
185
|
+
const interactive = !!process.stdin.isTTY && !ARGS['--yes'];
|
|
186
|
+
let dir = arg('--dir', '.');
|
|
187
|
+
let destination = resolveDestination(dir);
|
|
188
|
+
let stored = readConfig(destination.root, 1);
|
|
189
|
+
// Looking in the current folder first lets a saved install re-run with no prompts or flags.
|
|
190
|
+
if (interactive && !ARGS['--dir'] && !stored.cfgExists) {
|
|
191
|
+
dir = await ask('Folder to install into', '.');
|
|
192
|
+
destination = resolveDestination(dir);
|
|
193
|
+
stored = readConfig(destination.root, 1);
|
|
194
|
+
}
|
|
195
|
+
if (!stored.cfgExists && !interactive && (!ARGS['--dir'] || !ARGS['--ai'] || !ARGS['--level'] || !ARGS['--yes']))
|
|
196
|
+
die('non-interactive run needs --dir, --ai and --level (and --yes)');
|
|
197
|
+
let ais = arg('--ai', stored.cfgExists ? (stored.cfg.targets || []).filter(t => AIS.includes(t)).join(',') : null);
|
|
198
|
+
let level = arg('--level', stored.cfgExists ? stored.cfg.level || 1 : 1);
|
|
199
|
+
if (interactive && !stored.cfgExists) {
|
|
205
200
|
console.log('\nWhich AIs do you use? Comma-separated from:');
|
|
206
201
|
for (const k of AIS) console.log(` ${k.padEnd(8)} ${AI_LABEL[k]}`);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
202
|
+
// Existence is the only inspection of app folders permitted before consent.
|
|
203
|
+
const found = [['.claude', 'claude'], ['.codex', 'agents'], ['.gemini', 'gemini']]
|
|
204
|
+
.filter(([folder]) => fs.existsSync(path.join(os.homedir(), folder))).map(([, ai]) => ai);
|
|
205
|
+
ais = await ask('\nAIs', ais || (found.length ? found.join(',') : 'claude,agents'));
|
|
210
206
|
}
|
|
211
|
-
if (!dir || !ais || !level) die('non-interactive run needs --dir, --ai and --level (and --yes)');
|
|
212
207
|
if (!/^[1-4]$/.test(String(level))) die('level must be exactly 1, 2 or 3');
|
|
213
208
|
level = Number(level);
|
|
214
|
-
// Keep the former level accepted so existing scripts run. Routing has its own package.
|
|
215
209
|
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);
|
|
210
|
+
const targets = String(ais || '').split(',').map(s => s.trim()).filter(Boolean);
|
|
217
211
|
const bad = targets.filter(t => !AIS.includes(t));
|
|
218
212
|
if (bad.length) die(`unknown AI: ${bad.join(', ')} (known: ${AIS.join(', ')})`);
|
|
219
213
|
if (!targets.length) die('no AIs chosen');
|
|
220
214
|
if (new Set(targets).size !== targets.length) die(`an AI is listed twice in --ai (${targets.join(',')}); list each once`);
|
|
221
215
|
|
|
222
|
-
// Onboarding answers: a file, the defaults, or the interview. Validated before anything is created.
|
|
223
|
-
let answers = null, answersSource = '';
|
|
224
216
|
const answersFile = arg('--answers', null);
|
|
225
217
|
if (answersFile && arg('--defaults', false)) die('--answers and --defaults are exclusive');
|
|
226
|
-
|
|
227
|
-
|
|
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;
|
|
218
|
+
let answers = stored.prevAnswers || onboarding.defaults();
|
|
219
|
+
let answersSource = stored.prevAnswers ? 'kept from .agent-personalizer.json' : 'defaults (editable through --answers or .agent-personalizer.json)';
|
|
230
220
|
if (answersFile) {
|
|
231
221
|
let raw;
|
|
232
222
|
const label = answersFile === '-' ? 'stdin' : answersFile;
|
|
233
|
-
try { raw = JSON.parse(answersFile === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(answersFile), 'utf8')); }
|
|
223
|
+
try { raw = JSON.parse(answersFile === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(answersFile), 'utf8')); }
|
|
224
|
+
catch (e) { die(`--answers: cannot read ${label} as JSON (${e.message})`); }
|
|
234
225
|
try { answers = onboarding.validate(raw); } catch (e) { die(`--answers: ${e.message}`); }
|
|
235
226
|
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
227
|
}
|
|
228
|
+
const learnRequested = interactive && !stored.cfgExists
|
|
229
|
+
? await require('./learn.cjs').requestConsent() : false;
|
|
264
230
|
|
|
265
231
|
// The folder you name is followed once (realpath of its deepest EXISTING ancestor); the
|
|
266
232
|
// missing tail is created one level at a time, so nothing is ever created through a
|
|
267
233
|
// symlink that did not exist when you ran the command. Everything beneath root is then
|
|
268
234
|
// symlink-free by construction (safeDest refuses any).
|
|
269
|
-
const { requested, root, realExisting, missing } = destination
|
|
235
|
+
const { requested, root, realExisting, missing } = destination;
|
|
270
236
|
let creating = realExisting;
|
|
271
237
|
for (const part of missing) { creating = path.join(creating, part); fs.mkdirSync(creating); }
|
|
272
238
|
if (!fs.lstatSync(root).isDirectory()) die(`--dir ${requested} is not a directory`);
|
|
273
239
|
// Config: the one file this installer rewrites. Read and VALIDATED here, before the first write, so a malformed
|
|
274
240
|
// stored config refuses the whole run and leaves the folder untouched. Existing onboarding answers are kept unless
|
|
275
|
-
// --answers
|
|
241
|
+
// --answers supplied new ones; explicit targets replace the saved selection; "onboarding" is always a target.
|
|
276
242
|
const storedConfig = stored || readConfig(root, level);
|
|
277
243
|
const { cfgPath, cfgExists, prevAnswers } = storedConfig;
|
|
278
244
|
let cfg = storedConfig.cfg;
|
|
279
245
|
if (prevAnswers && !answersFile && answersSource.startsWith('defaults')) {
|
|
280
246
|
answers = prevAnswers; answersSource = 'kept from .agent-personalizer.json';
|
|
281
247
|
}
|
|
282
|
-
const allTargets = [...new Set([...
|
|
283
|
-
const installedLevel =
|
|
248
|
+
const allTargets = [...new Set([...targets, 'onboarding'])];
|
|
249
|
+
const installedLevel = level;
|
|
284
250
|
const effectiveLevel = Math.min(installedLevel, 3);
|
|
285
251
|
const base = onboarding.baseFor(answers); // the folder scaffolds and home-file pointers use
|
|
286
252
|
const kind = onboarding.kindOf(answers);
|
|
@@ -349,6 +315,7 @@ async function main() {
|
|
|
349
315
|
// USER.md: yours once it exists. Regenerated only when it still equals the render of the PREVIOUS
|
|
350
316
|
// answers byte for byte (you never touched it) and the answers changed. Otherwise kept, and any
|
|
351
317
|
// changed answer that the kept file still carries the old value of is named as a conflict.
|
|
318
|
+
const entries = markers.readLearned(root);
|
|
352
319
|
const user = probe(root, 'USER.md');
|
|
353
320
|
let userAction = 'create';
|
|
354
321
|
let staleNotesInUser = false;
|
|
@@ -359,14 +326,15 @@ async function main() {
|
|
|
359
326
|
// Two candidate renders per answer set, one saying the notes folder is there and one saying it is
|
|
360
327
|
// not (#25). A match against EITHER means the file is still exactly what this installer wrote,
|
|
361
328
|
// 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 }));
|
|
329
|
+
const untouched = (ans) => [true, false].some(ns => current === onboarding.renderUser(ans, { notesScaffolded: ns, entries }));
|
|
363
330
|
if (changedKeys.length) {
|
|
364
331
|
userAction = untouched(prevAnswers) ? 'regenerate' : 'conflict';
|
|
365
|
-
} else if (notesScaffolded && current === onboarding.renderUser(answers, { notesScaffolded: false })) {
|
|
332
|
+
} else if (notesScaffolded && current === onboarding.renderUser(answers, { notesScaffolded: false, entries })) {
|
|
366
333
|
// Same answers, but the file says the folder is absent and it is not (this run created it, or
|
|
367
334
|
// it was already there). The real paths go back, and only on a byte-for-byte match.
|
|
368
335
|
userAction = 'relevel';
|
|
369
|
-
} else userAction = '
|
|
336
|
+
} else if (recordedHash(cfg, 'USER.md') && sha256(Buffer.from(current)) === recordedHash(cfg, 'USER.md') && current !== onboarding.renderUser(answers, { notesScaffolded, entries })) userAction = 'refresh';
|
|
337
|
+
else userAction = 'keep';
|
|
370
338
|
// A kept file that does not name the folder README while the folder is there is stale, however it
|
|
371
339
|
// was worded: keying the notice on one sentence let an edit to that sentence silence it (finding 6).
|
|
372
340
|
if (userAction === 'keep' && notesScaffolded && !current.includes(`\`${base}/README.md\``)) staleNotesInUser = true;
|
|
@@ -426,6 +394,7 @@ async function main() {
|
|
|
426
394
|
if (!destination.exists) writes.push({ rel: p.rel, bytes, report: `wrote ${p.rel} (${p.note})` });
|
|
427
395
|
continue;
|
|
428
396
|
}
|
|
397
|
+
if (destination.exists && p.firstOnly) { console.log(`kept ${p.rel} (user-owned)`); continue; }
|
|
429
398
|
if (destination.exists) {
|
|
430
399
|
const existing = fs.readFileSync(destination.full);
|
|
431
400
|
const old = previousPlan.find(prior => prior.rel === p.rel);
|
|
@@ -453,7 +422,7 @@ async function main() {
|
|
|
453
422
|
// stays, even when no current recipe mentions it; its hashes remain in the inventory.
|
|
454
423
|
const currentPaths = new Set(plan.map(p => p.rel));
|
|
455
424
|
for (const rel of Object.keys(installedHashes)) {
|
|
456
|
-
if (!rel.startsWith('rules/') || currentPaths.has(rel)) continue;
|
|
425
|
+
if (effectiveLevel < 3 || !rel.startsWith('rules/') || currentPaths.has(rel)) continue;
|
|
457
426
|
const destination = probe(root, rel);
|
|
458
427
|
if (!destination.exists) continue;
|
|
459
428
|
if (!fs.lstatSync(destination.full).isFile()) die(`${rel} is not a regular file; nothing was written`);
|
|
@@ -462,12 +431,13 @@ async function main() {
|
|
|
462
431
|
}
|
|
463
432
|
if (previousBase && previousBase !== base && previousNotesExists) console.log(`kept ${previousBase}/ (previous notes folder; current notes folder: ${base}/; kept in the uninstall inventory)`);
|
|
464
433
|
|
|
465
|
-
if (
|
|
466
|
-
const rendered = onboarding.renderUser(answers, { notesScaffolded });
|
|
434
|
+
if (['create', 'regenerate', 'relevel', 'refresh'].includes(userAction)) {
|
|
435
|
+
const rendered = onboarding.renderUser(answers, { notesScaffolded, entries });
|
|
467
436
|
writes.push({ rel: 'USER.md', bytes: Buffer.from(rendered) });
|
|
468
437
|
installedHashes['USER.md'] = sha256(Buffer.from(rendered));
|
|
469
438
|
if (userAction === 'create') console.log('wrote USER.md (from your answers)');
|
|
470
439
|
else if (userAction === 'regenerate') console.log(`update USER.md (regenerated: it matched your previous answers byte for byte; changed: ${changedKeys.join(', ')})`);
|
|
440
|
+
else if (userAction === 'refresh') console.log('update USER.md (untouched installer profile refreshed from your entries)');
|
|
471
441
|
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
442
|
}
|
|
473
443
|
else if (userAction === 'conflict') {
|
|
@@ -481,6 +451,7 @@ async function main() {
|
|
|
481
451
|
// Snapshot every possible output and check every parent before the first write. The
|
|
482
452
|
// renderer runs from this package, not from a potentially edited installed executable.
|
|
483
453
|
const outputPaths = new Set(['.agent-personalizer.json', ...writes.map(p => p.rel), ...removals.map(p => p.rel)]);
|
|
454
|
+
if (learnRequested) { outputPaths.add('.agent-personalizer/digest.md'); outputPaths.add('.agent-personalizer/.gitignore'); }
|
|
484
455
|
for (const target of allTargets.map(key => TARGETS[key])) {
|
|
485
456
|
outputPaths.add(target.file);
|
|
486
457
|
for (const rel of Object.values(target.boxFiles || {})) outputPaths.add(rel);
|
|
@@ -510,7 +481,7 @@ async function main() {
|
|
|
510
481
|
try { fs.accessSync(ancestor, fs.constants.W_OK); } catch (_) { die(`${rel}: parent is not writable; nothing was written`); }
|
|
511
482
|
}
|
|
512
483
|
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 };
|
|
484
|
+
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
485
|
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
486
|
const replace = (rel, bytes, mode) => {
|
|
516
487
|
const destination = safeDest(root, rel);
|
|
@@ -544,6 +515,7 @@ async function main() {
|
|
|
544
515
|
}
|
|
545
516
|
// Include renderer outputs in rollback even when it committed before reporting a failure.
|
|
546
517
|
for (const rel of outputPaths) touched.add(rel);
|
|
518
|
+
if (learnRequested) await require('./learn.cjs').learn({ dir: root, consented: true });
|
|
547
519
|
execFileSync(process.execPath, [path.join(PKG, 'render', 'render.cjs'), '--dir', root, '--targets', allTargets.join(',')], { stdio: 'inherit' });
|
|
548
520
|
} catch (e) {
|
|
549
521
|
const incomplete = [];
|
|
@@ -562,6 +534,8 @@ async function main() {
|
|
|
562
534
|
throw e;
|
|
563
535
|
} finally { committing = false; }
|
|
564
536
|
|
|
537
|
+
if (interactive && !cfgExists && !learnRequested) console.log('Nothing was read. Run npx agent-personalizer learn any time.');
|
|
538
|
+
|
|
565
539
|
const DOCS = onboarding.DOCS;
|
|
566
540
|
// 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
541
|
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 +558,7 @@ async function main() {
|
|
|
584
558
|
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
559
|
steps.push(level >= 3
|
|
586
560
|
? `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}
|
|
561
|
+
: `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
562
|
steps.push([
|
|
589
563
|
auto.length ? `Read from ${root} automatically, nothing to paste: ${auto.join(', ')}.` : null,
|
|
590
564
|
paste.length ? `Still needs a paste: ${paste.join('; ')}.` : null,
|
|
@@ -596,13 +570,13 @@ async function main() {
|
|
|
596
570
|
steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
|
|
597
571
|
if (answers.notes_tool === 'obsidian') console.log(answers.obsidian_tc === 'yes'
|
|
598
572
|
? `\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
|
|
573
|
+
: `\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
574
|
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
575
|
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
576
|
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
577
|
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
578
|
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('\
|
|
579
|
+
console.log('\nThe installer made no network calls.');
|
|
606
580
|
console.log('\nIf this saved you time, a star helps people find it: https://github.com/aunysillyme/agent-personalizer');
|
|
607
581
|
}
|
|
608
582
|
|
package/bin/install-plan.cjs
CHANGED
|
@@ -99,6 +99,9 @@ function installPlan({ answers, level, targets, notesScaffolded }) {
|
|
|
99
99
|
const noSig = answers.signature === 'no';
|
|
100
100
|
const stripSig = (t) => noSig ? stripSignature(t) : t;
|
|
101
101
|
const mdCopy = (rel, src) => plan.push({ rel, text: stripSig(fs.readFileSync(src, 'utf8')) });
|
|
102
|
+
// Entries belong to the user as soon as the template is written, even untouched.
|
|
103
|
+
plan.push({ rel: 'LEARNED.md', text: fs.readFileSync(path.join(PKG, 'templates', 'LEARNED.md'), 'utf8'), firstOnly: true });
|
|
104
|
+
if (targets.includes('claude')) plan.push({ rel: '.claude/commands/personalize.md', text: onboarding.learningProcedure() + '\n' });
|
|
102
105
|
// rules/ is copied at level 3, where it becomes yours to edit; levels 1 and 2 render from the package's rules
|
|
103
106
|
if (level >= 3) for (const f of fs.readdirSync(path.join(PKG, 'rules')).sort()) {
|
|
104
107
|
if (noSig && f === '40-sign-every-edit.md') continue;
|