agent-personalizer 0.10.0 → 0.10.2
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 +26 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +19 -18
- package/SECURITY.md +1 -1
- package/bin/agent-personalizer.js +130 -26
- package/bin/global.cjs +155 -29
- package/bin/home.cjs +69 -4
- package/bin/install-plan.cjs +10 -6
- package/bin/learn.cjs +5 -4
- package/bin/sessions.cjs +57 -14
- package/check/gate.cjs +76 -30
- package/docs/companions.md +11 -11
- package/docs/guarantees.md +4 -4
- package/docs/install.md +1 -1
- package/docs/learning.md +5 -5
- package/docs/paste-guide.md +13 -11
- package/examples/answers.json +1 -1
- package/hooks/README.md +1 -1
- package/hooks/gemini-cli/session-start.sh +19 -7
- package/llms.txt +2 -1
- package/package.json +22 -9
- package/render/onboarding.cjs +8 -8
- package/render/render.cjs +1 -1
- package/skills/agent-personalizer/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ Every entry names the adversarial audit round that produced it where one did. Au
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.10.2] - 2026-11-29
|
|
10
|
+
|
|
11
|
+
### Security
|
|
12
|
+
|
|
13
|
+
- Bump `ossf/scorecard-action` to 2.6.0 (#56) and `github/codeql-action/upload-sarif` to 4.39.5 (#57) in `.github/workflows/scorecard.yml`.
|
|
14
|
+
- Replace sequential HTML attribute entity decoding in `website/check.mjs` with single-pass entity lookup so `&` sequences are never double-unescaped, add `--offline` to the `publish.yml` tarball smoke install, enforce HTTPS TLS 1.2+ in `notify-dev-site.yml`, and run `website/` security and live-build checks in `harness.yml`.
|
|
15
|
+
- Tighten `P_TOKEN` in `check/gate.cjs` so Base62 `npm_` and `gh[pousr]_` token patterns still flag credentials while snake_case `npm_config_*` environment variables in `scripts/record-demo.sh` do not trigger false positives during `--history` scans.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Rename the Obsidian vault MCP companion from `obsidian-tc` to `reliquary-tc` across docs and companion guidance (#55), and add `.github/workflows/notify-dev-site.yml` to refresh product-site metadata on release.
|
|
20
|
+
- Speed up `check/gate.cjs` (`git cat-file --batch` history scanning, pre-folded NFC terms and whole-file fast-path filtering), defer heavy module loading after `--help` and `--version` in `bin/agent-personalizer.js`, run `hooks/gemini-cli/session-start.sh` in-process with an explicit missing-`node` check, cache `known-hashes.json` lookups in `bin/install-plan.cjs`, and precompile private terms in `bin/sessions.cjs`.
|
|
21
|
+
- Align `package.json` `description` (151 characters) with `set.json`, point `package.json` `homepage` at `https://agent-personalizer.aunysillyme.dev`, expand npm discovery `keywords`, add `REPO_SETTINGS.md`, add explicit AI search crawler allow directives in `website/build.mjs`, and update `README.md`, `docs/paste-guide.md`, `llms.txt` and `skills/agent-personalizer/SKILL.md` for Gemini (via Antigravity CLI), Claude Code `@AGENTS.md` imports and standalone common-question answers.
|
|
22
|
+
|
|
23
|
+
## [0.10.1] - 2026-11-18
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Respect `CODEX_HOME` for `--global --ai agents` (install, re-run, atomic rollback, `learn` and `--uninstall`), pre-selection and session discovery, and warn without modifying `AGENTS.override.md` when a non-empty override shadows `AGENTS.md` (#51).
|
|
28
|
+
- Replace blanket ChatGPT file-access copy with surface-specific wording, and describe Codex memory notes as local to the machine or connected host (`~/.codex` or `$CODEX_HOME`) rather than global to an account (#52).
|
|
29
|
+
- Document the enclosing Git `info/exclude` (and level-3 `--precommit`) exception to the project write boundary in `README.md` (#53).
|
|
30
|
+
- Align `docs/learning.md` and `docs/paste-guide.md` with full declined-entry ChatGPT exports and `OVER BUDGET` / `--strict` behavior, and scope `docs/companions.md` enforcement claims to operations routed through the configured companion (#54).
|
|
31
|
+
|
|
9
32
|
## [0.10.0] - 2026-11-18
|
|
10
33
|
|
|
11
34
|
### Added
|
|
@@ -393,7 +416,9 @@ Thirteen issues (#3 to #15) filed against `5972b32` by an independent installati
|
|
|
393
416
|
- Installer: safe destination resolution, strict options, duplicate `--ai` refused, `--dir` created one level at a time.
|
|
394
417
|
- Harness: exact exit codes, adversarial fixtures, fault injection for the rollback path.
|
|
395
418
|
|
|
396
|
-
[Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.
|
|
419
|
+
[Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.2...HEAD
|
|
420
|
+
[0.10.2]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.1...v0.10.2
|
|
421
|
+
[0.10.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.0...v0.10.1
|
|
397
422
|
[0.10.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.9.1...v0.10.0
|
|
398
423
|
[0.9.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.9.0...v0.9.1
|
|
399
424
|
[0.9.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.7...v0.9.0
|
package/CONTRIBUTING.md
CHANGED
|
@@ -10,7 +10,7 @@ Contributions are welcome: a **new AI target**, a **notes tool**, an **example u
|
|
|
10
10
|
## Running the checks
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm test # sh test/run.sh:
|
|
13
|
+
npm test # sh test/run.sh: 103 checks, exact exit codes, Linux and macOS
|
|
14
14
|
node test/rollback.test.js
|
|
15
15
|
node check/gate.cjs --self-test
|
|
16
16
|
```
|
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) [](https://scorecard.dev/viewer/?uri=github.com/aunysillyme/agent-personalizer)
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**AI custom instructions kept in sync across every AI you use:** Claude Code, Codex, Cursor, Gemini CLI, Gemini (via Antigravity CLI), Hermes Agent and ChatGPT, rendered from one source.
|
|
6
6
|
|
|
7
7
|
**The problem:** Custom instructions live in each app separately, drift apart and fade over a long chat.
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@ npx agent-personalizer
|
|
|
26
26
|
| `AGENT_ONBOARDING.md` | Your AI's reading order, writing policy, off-limits topics and approval steps. |
|
|
27
27
|
| `CLAUDE.md` | Your profile and selected rules in Claude Code's project instruction file. |
|
|
28
28
|
| `AGENTS.md` | Your profile and selected rules in the project file used by Codex, Cursor and Hermes Agent. |
|
|
29
|
-
| `GEMINI.md` | Your profile and selected rules in Gemini CLI and
|
|
29
|
+
| `GEMINI.md` | Your profile and selected rules in the instruction file read by Gemini CLI and Gemini (via Antigravity CLI). |
|
|
30
30
|
| ChatGPT paste files | `chatgpt-box1.txt` for your profile and `chatgpt-box2.txt` for response instructions, plus a preview with counts. |
|
|
31
31
|
| `system-prompt.md` | Shareable universal rules for another chat app, bot or API. |
|
|
32
32
|
| Notes folder, level 2 | A folder index, weekly session template, decisions log and inbox for local or fallback notes tools. |
|
|
@@ -60,6 +60,7 @@ File generation, re-runs and uninstall run in CI on Linux, macOS and Windows; yo
|
|
|
60
60
|
| [lean-computer-use](https://github.com/aunysillyme/lean-computer-use) | Background Mac computer control for AI agents: desk tools, a fresh runner subagent, retry guards and a transcript token meter, installed with one command |
|
|
61
61
|
| [decompose](https://github.com/aunysillyme-dev/aunx-decompose) | Task planner and wave checker for AI coding agents: splits prompts into checkable units and parallel waves, rejecting cycles and overlapping writes |
|
|
62
62
|
| [aunx-skills](https://github.com/aunysillyme-dev/aunx-skills) | Ten standalone agent skills for Claude Code, Codex, Cursor and Gemini CLI: full output keeper, number guard, docs fetch ladder, rename sweep and more |
|
|
63
|
+
| [stack](https://github.com/aunysillyme-dev/stack) | AI tools list for everything you build with AI: curated stacks of tools, models and workflows as open JSON. Video and design live, more coming. |
|
|
63
64
|
<!-- set:end -->
|
|
64
65
|
|
|
65
66
|
## Choose your setup
|
|
@@ -84,13 +85,13 @@ For every project, install one global level-1 profile:
|
|
|
84
85
|
npx agent-personalizer --global --ai claude,agents,gemini,hermes --yes
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
The source lives in `~/.agent-personalizer/`; marked blocks go to `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md
|
|
88
|
+
The source lives in `~/.agent-personalizer/`; marked blocks go to `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md` (or `$CODEX_HOME/AGENTS.md`), `~/.gemini/GEMINI.md` and `~/.hermes/SOUL.md` for the selected targets. User text outside the blocks stays byte for byte. For Hermes in a project, use `--ai agents` for `AGENTS.md`. `--global` supports these four targets and level 1; it excludes `--dir`. Re-run with `--global`, learn across all projects with `learn --global`, and remove owned global content with `--global --uninstall`. See [global installation](docs/install.md#every-project-with-one-profile).
|
|
88
89
|
|
|
89
90
|
Levels 1 and 2 carry the Core 5: read the profile first, evidence before assertion, output style, act or ask, and ask before it repeats. Level 3 retains all eleven, with each target's existing surface and signature selection.
|
|
90
91
|
|
|
91
92
|
Node 24 or 26 (active LTS) is recommended; 22 or later runs. Published on npm with provenance. [Installation](docs/install.md) covers scripted answers, every flag, notes tools and manual copying.
|
|
92
93
|
|
|
93
|
-
The tool runs locally after `npx` fetches the package. The installer and renderer make no network calls and send no telemetry. Project writes stay inside the folder you name;
|
|
94
|
+
The tool runs locally after `npx` fetches the package. The installer and renderer make no network calls and send no telemetry. Project writes stay inside the folder you name, except inside a Git work tree where install updates the enclosing repository's Git `info/exclude` (and `hooks/pre-commit` only when you pass `--precommit` at level 3; see [preflight and writes](docs/guarantees.md#preflight-and-writes)). Global writes (`--global`) use only `~/.agent-personalizer/` and the selected AI home paths above. Edited source files are preserved and named.
|
|
94
95
|
|
|
95
96
|
## Privacy
|
|
96
97
|
|
|
@@ -150,38 +151,38 @@ Select your notes tool through saved onboarding answers or an answers file:
|
|
|
150
151
|
npx agent-personalizer --dir . --answers my-answers.json
|
|
151
152
|
```
|
|
152
153
|
|
|
153
|
-
[Companion setup](docs/companions.md) explains notes connectors and how to
|
|
154
|
+
[Companion setup](docs/companions.md) explains notes connectors and how to apply onboarding answers to operations routed through a configured companion.
|
|
154
155
|
|
|
155
156
|
| Tool | What it gives you |
|
|
156
157
|
|---|---|
|
|
157
|
-
| [
|
|
158
|
+
| [reliquary-tc](https://github.com/The-40-Thieves/reliquary-tc) | Governed Obsidian access: configure folder permissions from your off-limits answer and human approval from your always-ask answer. |
|
|
158
159
|
| [The Context Layer](https://sierracatalina.com/context-layer) | Purpose-bound context with receipts; its decide and vault stages apply your write policy and off-limits boundaries. |
|
|
159
160
|
|
|
160
161
|
## Common questions
|
|
161
162
|
|
|
162
163
|
### How do I share custom instructions across Claude Code, Codex, Cursor, Gemini CLI, Hermes Agent and ChatGPT?
|
|
163
164
|
|
|
164
|
-
Run `npx agent-personalizer`
|
|
165
|
+
Run `npx agent-personalizer` to generate native instruction files for every selected AI from one `USER.md` profile, `LEARNED.md` log and rule source. Coding agents load their generated files automatically, while ChatGPT gets plain-text exports (`chatgpt-box1.txt` and `chatgpt-box2.txt`) ready to paste.
|
|
165
166
|
|
|
166
|
-
###
|
|
167
|
+
### What is the difference between CLAUDE.md, AGENTS.md, GEMINI.md and SOUL.md?
|
|
167
168
|
|
|
168
|
-
|
|
169
|
+
`agent-personalizer` writes each AI's native instruction file from the same source: `CLAUDE.md` for Claude Code, `AGENTS.md` for Codex, Cursor and project-level Hermes Agent, `GEMINI.md` for Gemini CLI and Gemini (via Antigravity CLI), and `~/.hermes/SOUL.md` for global Hermes Agent installs. See [What it sets up](#what-it-sets-up) and the [paste guide](docs/paste-guide.md) for loading details.
|
|
169
170
|
|
|
170
|
-
### How do I
|
|
171
|
+
### How do I set one global AI profile across all of my repositories?
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
Run `npx agent-personalizer --global --ai claude,agents,gemini,hermes --yes` to store one shared profile in `~/.agent-personalizer/` and sync marked blocks into `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md` (or `$CODEX_HOME/AGENTS.md`), `~/.gemini/GEMINI.md` and `~/.hermes/SOUL.md` while preserving existing text outside the markers.
|
|
173
174
|
|
|
174
|
-
### How do I
|
|
175
|
+
### How do I update my AI profile or change an onboarding answer?
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
Run `npx agent-personalizer --dir . --answers my-answers.json` to apply new onboarding preferences, or edit `USER.md`, `LEARNED.md` and `rules/` directly in a level-3 `agent-personalizer` install and run `node render/render.cjs --dir .` before re-pasting changed chat exports.
|
|
177
178
|
|
|
178
|
-
### How do I
|
|
179
|
+
### How do I check generated AI instruction files for drift in CI?
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
Run `node render/render.cjs --dir . --check` in a level-3 `agent-personalizer` setup to verify every generated block and ChatGPT paste file against `USER.md`, `LEARNED.md` and `rules/`. Exit 0 confirms the files match their sources, exit 1 names drifted files and exit 2 refuses invalid input.
|
|
181
182
|
|
|
182
|
-
### How do I uninstall agent-personalizer
|
|
183
|
+
### How do I uninstall agent-personalizer without losing my notes or edits?
|
|
183
184
|
|
|
184
|
-
Preview with `npx agent-personalizer --uninstall --dir . --dry`, then run `npx agent-personalizer --uninstall --dir .`.
|
|
185
|
+
Preview removal with `npx agent-personalizer --uninstall --dir . --dry`, then run `npx agent-personalizer --uninstall --dir .`. `agent-personalizer` compares recorded SHA-256 hashes, removes unchanged generated files and digests, restores untouched host files byte for byte, and keeps edited files, user-written notes and any `LEARNED.md` with entries.
|
|
185
186
|
|
|
186
187
|
## Uninstall
|
|
187
188
|
|
|
@@ -215,7 +216,7 @@ Contributions are welcome: a new AI target, a notes tool, an example user, or a
|
|
|
215
216
|
|
|
216
217
|
Pull requests are accepted under the [contributor license agreement](CLA.md); the checkbox in the pull request template records your agreement.
|
|
217
218
|
|
|
218
|
-
The harness (`test/run.sh:
|
|
219
|
+
The harness (`test/run.sh: 103 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.
|
|
219
220
|
|
|
220
221
|
## License
|
|
221
222
|
|
package/SECURITY.md
CHANGED
|
@@ -18,4 +18,4 @@ In scope: `bin/`, including session reading, learning and removal, `render/`, `c
|
|
|
18
18
|
|
|
19
19
|
## What is already done
|
|
20
20
|
|
|
21
|
-
Every release passes an adversarial read-only audit (see `CHANGELOG.md`, each entry names its round) and a
|
|
21
|
+
Every release passes an adversarial read-only audit (see `CHANGELOG.md`, each entry names its round) and a 103-check harness with exact exit codes, on Linux and macOS in CI. The deferred residuals are stated in the code headers: TOCTOU between check and write, unicode look-alikes in the gate, the named `--dir` being followed once via realpath, and a hard process kill between two renames. On Windows, `O_NOFOLLOW` is unavailable to the flag the uninstaller opens tracked files with; nothing depends on it there, because the delete loop re-probes every path with `lstat` immediately before each unlink, so no destructive path exists without it.
|
|
@@ -9,29 +9,18 @@
|
|
|
9
9
|
*/
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const readline = require('readline');
|
|
13
|
-
const { resolveHome } = require('./home.cjs');
|
|
14
12
|
const { sha256, parseCliArgs } = require('./cli-util.cjs');
|
|
15
|
-
const crypto = require('crypto');
|
|
16
|
-
const { execFileSync } = require('child_process');
|
|
17
|
-
// CLAUDE.md, AGENTS.md and GEMINI.md are written here as a pointer template only; render.cjs (run at the
|
|
18
|
-
// end of main()) splices in the rendered block and records the final bytes it wrote, so their
|
|
19
|
-
// hash is recorded there, once, against the complete file.
|
|
20
|
-
const HOME_NAMES = new Set(['CLAUDE.md', 'AGENTS.md', 'GEMINI.md']);
|
|
21
13
|
|
|
22
14
|
const PKG = path.resolve(__dirname, '..');
|
|
23
|
-
const
|
|
24
|
-
const markers = require(path.join(PKG, 'render', 'render.cjs')); // markerState, for the preflight; render.cjs runs nothing on require
|
|
25
|
-
const { installPlan, validateInventory, knownVersions, ownership, migrateHome, recordedHash } = require('./install-plan.cjs');
|
|
26
|
-
const AIS = ['claude', 'agents', 'gemini', 'chatgpt', 'prompt'];
|
|
27
|
-
const AI_LABEL = { claude: 'Claude (Claude Code, Claude apps)', agents: 'Codex / Cursor / Hermes / anything that reads AGENTS.md', gemini: 'Gemini', chatgpt: 'ChatGPT custom instructions', prompt: 'a plain system prompt (shareable, no profile)' };
|
|
15
|
+
const PKG_VERSION = require(path.join(PKG, 'package.json')).version;
|
|
28
16
|
|
|
29
17
|
let committing = false;
|
|
30
|
-
|
|
18
|
+
let markers = null;
|
|
19
|
+
function die(msg) { if (committing && markers) throw new markers.Refusal(msg); console.error(`agent-personalizer: ${msg}`); process.exit(2); }
|
|
31
20
|
|
|
32
21
|
const VALUE_OPTS = ['--dir', '--ai', '--level', '--answers'];
|
|
33
22
|
const FLAG_OPTS = ['--global', '--forget', '--all-projects', '--yes', '--defaults', '--quick', '--full', '--compact', '--precommit', '--uninstall', '--dry', '--help', '--version', '-h', '-v'];
|
|
34
|
-
const USAGE = `agent-personalizer ${
|
|
23
|
+
const USAGE = `agent-personalizer ${PKG_VERSION}
|
|
35
24
|
|
|
36
25
|
npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
|
|
37
26
|
[--answers <file.json> | --answers - | --defaults] [--compact]
|
|
@@ -68,7 +57,21 @@ const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).vers
|
|
|
68
57
|
const ARGS = parseCliArgs(process.argv.slice(2), { valueOpts: VALUE_OPTS, flagOpts: FLAG_OPTS, commands: ['learn'], onError: die });
|
|
69
58
|
function arg(name, dflt) { return name in ARGS ? ARGS[name] : dflt; }
|
|
70
59
|
if (ARGS['--help'] || ARGS['-h']) { process.stdout.write(USAGE); process.exit(0); }
|
|
71
|
-
if (ARGS['--version'] || ARGS['-v']) { process.stdout.write(
|
|
60
|
+
if (ARGS['--version'] || ARGS['-v']) { process.stdout.write(PKG_VERSION + '\n'); process.exit(0); }
|
|
61
|
+
|
|
62
|
+
const readline = require('readline');
|
|
63
|
+
const crypto = require('crypto');
|
|
64
|
+
const { execFileSync } = require('child_process');
|
|
65
|
+
const { resolveHome, resolveCodexHome, walkRealChain, hasNonEmptyOverride } = require('./home.cjs');
|
|
66
|
+
// CLAUDE.md, AGENTS.md and GEMINI.md are written here as a pointer template only; render.cjs (run at the
|
|
67
|
+
// end of main()) splices in the rendered block and records the final bytes it wrote, so their
|
|
68
|
+
// hash is recorded there, once, against the complete file.
|
|
69
|
+
const HOME_NAMES = new Set(['CLAUDE.md', 'AGENTS.md', 'GEMINI.md']);
|
|
70
|
+
const onboarding = require(path.join(PKG, 'render', 'onboarding.cjs'));
|
|
71
|
+
markers = require(path.join(PKG, 'render', 'render.cjs')); // markerState, for the preflight; render.cjs runs nothing on require
|
|
72
|
+
const { installPlan, validateInventory, knownVersions, ownership, migrateHome, recordedHash } = require('./install-plan.cjs');
|
|
73
|
+
const AIS = ['claude', 'agents', 'gemini', 'chatgpt', 'prompt'];
|
|
74
|
+
const AI_LABEL = { claude: 'Claude (Claude Code, Claude apps)', agents: 'Codex / Cursor / Hermes / anything that reads AGENTS.md', gemini: 'Gemini', chatgpt: 'ChatGPT custom instructions', prompt: 'a plain system prompt (shareable, no profile)' };
|
|
72
75
|
|
|
73
76
|
async function ask(q, dflt, saved = false) {
|
|
74
77
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -157,7 +160,7 @@ function resolveDestination(dir) {
|
|
|
157
160
|
|
|
158
161
|
|
|
159
162
|
// One transaction for project and global plans: snapshot before writes, replace atomically, restore on failure.
|
|
160
|
-
async function commitPlan(root, { writes, removals = [], outputPaths, prepare, finalize }) {
|
|
163
|
+
async function commitPlan(root, { writes, removals = [], external = [], outputPaths, prepare, finalize }) {
|
|
161
164
|
for (const rel of outputPaths) {
|
|
162
165
|
let parent = path.posix.dirname(rel);
|
|
163
166
|
while (parent !== '.') {
|
|
@@ -182,7 +185,38 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
|
|
|
182
185
|
while (!fs.existsSync(ancestor)) ancestor = path.dirname(ancestor);
|
|
183
186
|
try { fs.accessSync(ancestor, fs.constants.W_OK); } catch (_) { die(`${rel}: parent is not writable; nothing was written`); }
|
|
184
187
|
}
|
|
185
|
-
|
|
188
|
+
const savedExternal = new Map(), externalNewDirs = [];
|
|
189
|
+
const checkExternalBase = base => {
|
|
190
|
+
try {
|
|
191
|
+
const chain = walkRealChain(base, { allowDarwinRootLink: false, action: 'nothing was written' });
|
|
192
|
+
if (chain.missingDirs.length) die(`${base} does not exist; nothing was written`);
|
|
193
|
+
} catch (e) { if (e instanceof markers.Refusal) die(e.message); throw e; }
|
|
194
|
+
};
|
|
195
|
+
for (const ext of external) {
|
|
196
|
+
checkExternalBase(ext.base);
|
|
197
|
+
const full = path.join(ext.base, ...(ext.missingDirs || []), ext.file);
|
|
198
|
+
ext.full = full;
|
|
199
|
+
if (savedExternal.has(full)) die(`${full}: duplicate external target; nothing was written`);
|
|
200
|
+
let st = null;
|
|
201
|
+
try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
202
|
+
if (st) {
|
|
203
|
+
if (st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
|
|
204
|
+
if (!st.isFile()) die(`${full} is not a regular file; nothing was written`);
|
|
205
|
+
savedExternal.set(full, { bytes: fs.readFileSync(full), mode: st.mode & 0o777, dev: st.dev, ino: st.ino });
|
|
206
|
+
} else savedExternal.set(full, null);
|
|
207
|
+
try { fs.accessSync(ext.base, fs.constants.W_OK); } catch (_) { die(`${full}: parent is not writable; nothing was written`); }
|
|
208
|
+
let cur = ext.base;
|
|
209
|
+
for (const part of ext.missingDirs || []) {
|
|
210
|
+
cur = path.join(cur, part);
|
|
211
|
+
let dirSt = null;
|
|
212
|
+
try { dirSt = fs.lstatSync(cur); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
213
|
+
if (dirSt) {
|
|
214
|
+
if (dirSt.isSymbolicLink()) die(`${cur} is a symlink; refusing to write through it`);
|
|
215
|
+
if (!dirSt.isDirectory()) die(`${cur} exists and is not a directory`);
|
|
216
|
+
} else if (!externalNewDirs.includes(cur)) externalNewDirs.push(cur);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (prepare) prepare(newDirectories, externalNewDirs);
|
|
186
220
|
const replace = (rel, bytes, mode) => {
|
|
187
221
|
const destination = safeDest(root, rel);
|
|
188
222
|
const tmp = path.join(path.dirname(destination.full), `.${path.basename(rel)}.${crypto.randomBytes(8).toString('hex')}.agent-personalizer.tmp`);
|
|
@@ -193,6 +227,18 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
|
|
|
193
227
|
fs.renameSync(tmp, destination.full);
|
|
194
228
|
} finally { if (fs.existsSync(tmp)) fs.unlinkSync(tmp); }
|
|
195
229
|
};
|
|
230
|
+
const replaceExternal = (full, bytes, mode) => {
|
|
231
|
+
checkExternalBase(path.dirname(full));
|
|
232
|
+
const tmp = path.join(path.dirname(full), `.${path.basename(full)}.${crypto.randomBytes(8).toString('hex')}.agent-personalizer.tmp`);
|
|
233
|
+
try {
|
|
234
|
+
fs.writeFileSync(tmp, bytes, { flag: 'wx', ...(mode === undefined ? {} : { mode }) });
|
|
235
|
+
if (mode !== undefined) fs.chmodSync(tmp, mode);
|
|
236
|
+
let st = null;
|
|
237
|
+
try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
238
|
+
if (st && st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
|
|
239
|
+
fs.renameSync(tmp, full);
|
|
240
|
+
} finally { if (fs.existsSync(tmp)) fs.unlinkSync(tmp); }
|
|
241
|
+
};
|
|
196
242
|
const assertSaved = rel => {
|
|
197
243
|
const destination = probe(root, rel), before = saved.get(rel);
|
|
198
244
|
if (!!before !== destination.exists) die(`${rel} changed during preflight; nothing was written`);
|
|
@@ -201,11 +247,41 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
|
|
|
201
247
|
if (info.dev !== before.dev || info.ino !== before.ino || !fs.readFileSync(destination.full).equals(before.bytes)) die(`${rel} changed during preflight; nothing was written`);
|
|
202
248
|
}
|
|
203
249
|
};
|
|
250
|
+
const assertSavedExternal = full => {
|
|
251
|
+
let dirExists = true;
|
|
252
|
+
try {
|
|
253
|
+
const chain = walkRealChain(path.dirname(full), { allowDarwinRootLink: false, action: 'nothing was written' });
|
|
254
|
+
dirExists = chain.missingDirs.length === 0;
|
|
255
|
+
} catch (e) { if (e instanceof markers.Refusal) die(e.message); throw e; }
|
|
256
|
+
let st = null;
|
|
257
|
+
if (dirExists) {
|
|
258
|
+
try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
259
|
+
}
|
|
260
|
+
if (st && st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
|
|
261
|
+
const before = savedExternal.get(full);
|
|
262
|
+
if (!!before !== !!st) die(`${full} changed during preflight; nothing was written`);
|
|
263
|
+
if (before && (st.dev !== before.dev || st.ino !== before.ino || !fs.readFileSync(full).equals(before.bytes))) die(`${full} changed during preflight; nothing was written`);
|
|
264
|
+
};
|
|
204
265
|
committing = true;
|
|
205
|
-
const touched = new Set();
|
|
266
|
+
const touched = new Set(), touchedExternal = [], touchedExternalDirs = [];
|
|
206
267
|
try {
|
|
207
268
|
for (const rel of outputPaths) assertSaved(rel);
|
|
269
|
+
for (const full of savedExternal.keys()) assertSavedExternal(full);
|
|
270
|
+
for (const dir of externalNewDirs) {
|
|
271
|
+
let st = null;
|
|
272
|
+
try { st = fs.lstatSync(dir); } catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
273
|
+
if (st) die(`${dir} changed during preflight; nothing was written`);
|
|
274
|
+
fs.mkdirSync(dir);
|
|
275
|
+
touchedExternalDirs.push(dir);
|
|
276
|
+
}
|
|
208
277
|
for (const p of removals) { assertSaved(p.rel); fs.unlinkSync(probe(root, p.rel).full); touched.add(p.rel); if (p.report) console.log(p.report); }
|
|
278
|
+
for (const ext of external) {
|
|
279
|
+
assertSavedExternal(ext.full);
|
|
280
|
+
touchedExternal.push(ext.full);
|
|
281
|
+
if (ext.remove) fs.unlinkSync(ext.full);
|
|
282
|
+
else replaceExternal(ext.full, ext.bytes, savedExternal.get(ext.full)?.mode);
|
|
283
|
+
if (ext.report) console.log(ext.report);
|
|
284
|
+
}
|
|
209
285
|
for (const p of writes) {
|
|
210
286
|
assertSaved(p.rel);
|
|
211
287
|
touched.add(p.rel);
|
|
@@ -218,6 +294,17 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
|
|
|
218
294
|
if (finalize) await finalize();
|
|
219
295
|
} catch (e) {
|
|
220
296
|
const incomplete = [];
|
|
297
|
+
for (const full of [...touchedExternal].reverse()) {
|
|
298
|
+
try {
|
|
299
|
+
checkExternalBase(path.dirname(full));
|
|
300
|
+
const before = savedExternal.get(full);
|
|
301
|
+
let st = null;
|
|
302
|
+
try { st = fs.lstatSync(full); } catch (_) { st = null; }
|
|
303
|
+
if (st && st.isSymbolicLink()) throw new Error('refusing symlink during restore');
|
|
304
|
+
if (before) replaceExternal(full, before.bytes, before.mode);
|
|
305
|
+
else if (st) fs.unlinkSync(full);
|
|
306
|
+
} catch (failure) { incomplete.push(`${full}: ${failure.message}`); }
|
|
307
|
+
}
|
|
221
308
|
for (const rel of [...touched].reverse()) {
|
|
222
309
|
try {
|
|
223
310
|
const before = saved.get(rel), destination = probe(root, rel);
|
|
@@ -225,6 +312,12 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
|
|
|
225
312
|
else if (destination.exists) fs.unlinkSync(destination.full);
|
|
226
313
|
} catch (failure) { incomplete.push(`${rel}: ${failure.message}`); }
|
|
227
314
|
}
|
|
315
|
+
for (const dir of [...touchedExternalDirs].reverse()) {
|
|
316
|
+
try {
|
|
317
|
+
const chain = walkRealChain(dir, { allowDarwinRootLink: false, action: 'nothing was written' });
|
|
318
|
+
if (!chain.missingDirs.length && fs.readdirSync(dir).length === 0) fs.rmdirSync(dir);
|
|
319
|
+
} catch (failure) { incomplete.push(`${dir}/: ${failure.message}`); }
|
|
320
|
+
}
|
|
228
321
|
for (const rel of [...newDirectories].sort((a, b) => b.split('/').length - a.split('/').length)) {
|
|
229
322
|
try { const destination = probe(root, rel); if (destination.exists && fs.readdirSync(destination.full).length === 0) fs.rmdirSync(destination.full); }
|
|
230
323
|
catch (failure) { incomplete.push(`${rel}/: ${failure.message}`); }
|
|
@@ -278,8 +371,16 @@ async function main() {
|
|
|
278
371
|
let home;
|
|
279
372
|
try { home = resolveHome(); }
|
|
280
373
|
catch (e) { if (!(e instanceof markers.Refusal)) throw e; }
|
|
281
|
-
|
|
282
|
-
|
|
374
|
+
let codexDir = null;
|
|
375
|
+
if (home) {
|
|
376
|
+
try { codexDir = resolveCodexHome(home); }
|
|
377
|
+
catch (e) { if (!(e instanceof markers.Refusal)) throw e; }
|
|
378
|
+
}
|
|
379
|
+
const found = home ? [
|
|
380
|
+
[path.join(home, '.claude'), 'claude'],
|
|
381
|
+
...(codexDir ? [[codexDir, 'agents']] : []),
|
|
382
|
+
[path.join(home, '.gemini'), 'gemini'],
|
|
383
|
+
].filter(([folder]) => fs.existsSync(folder)).map(([, ai]) => ai) : [];
|
|
283
384
|
ais = await ask('\nAIs', ais || (found.length ? found.join(',') : 'claude,agents'));
|
|
284
385
|
}
|
|
285
386
|
if (!/^[1-4]$/.test(String(level))) die('level must be 1, 2 or 3 (4 is accepted as 3)');
|
|
@@ -342,7 +443,7 @@ async function main() {
|
|
|
342
443
|
const installedHashes = { ...(cfg.installed && typeof cfg.installed === 'object' ? cfg.installed : {}) };
|
|
343
444
|
const createdDirectories = new Set(cfg.createdDirectories || []);
|
|
344
445
|
const toolingVersions = { ...(cfg.toolingVersions || {}) };
|
|
345
|
-
const toolingVersion =
|
|
446
|
+
const toolingVersion = PKG_VERSION;
|
|
346
447
|
const legacy = cfgExists && !!prevAnswers && !Object.hasOwn(cfg, 'installed');
|
|
347
448
|
|
|
348
449
|
console.log(`\nInstalling level ${level} for ${targets.join(', ')} into ${root}\nOnboarding answers: ${answersSource}\n`);
|
|
@@ -533,7 +634,7 @@ async function main() {
|
|
|
533
634
|
continue;
|
|
534
635
|
}
|
|
535
636
|
if (existing.equals(bytes)) {
|
|
536
|
-
installedHashes[p.rel] =
|
|
637
|
+
installedHashes[p.rel] = owner.hash;
|
|
537
638
|
if (p.src || p.rel.startsWith('rules/')) toolingVersions[p.rel] = toolingVersion;
|
|
538
639
|
console.log(`kept ${p.rel} (unchanged)`);
|
|
539
640
|
continue;
|
|
@@ -596,6 +697,9 @@ async function main() {
|
|
|
596
697
|
});
|
|
597
698
|
|
|
598
699
|
require('./git-exclude.cjs').protect(root);
|
|
700
|
+
if (targets.includes('agents') && hasNonEmptyOverride(root)) {
|
|
701
|
+
console.warn(`Warning: ${path.join(root, 'AGENTS.override.md')} is non-empty and overrides ${path.join(root, 'AGENTS.md')} in Codex; Codex ignores AGENTS.md in that directory while AGENTS.override.md has content.`);
|
|
702
|
+
}
|
|
599
703
|
|
|
600
704
|
if (interactive && !cfgExists && !learnRequested) console.log('Nothing was read. Run npx agent-personalizer learn any time.');
|
|
601
705
|
|
|
@@ -631,9 +735,9 @@ async function main() {
|
|
|
631
735
|
if (level >= 3) steps.push('Register hooks/claude-code/session-start.sh or hooks/gemini-cli/session-start.sh (see hooks/README.md) and copy check/forbidden.example.txt to check/forbidden.local.txt.');
|
|
632
736
|
console.log('\nNext:');
|
|
633
737
|
steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
|
|
634
|
-
if (answers.notes_tool === 'obsidian') console.log(answers.
|
|
635
|
-
? `\nCompanion: the onboarding file routes the AI through
|
|
636
|
-
: `\nCompanion: your notes are an Obsidian vault and the AI will work on the folder directly.
|
|
738
|
+
if (answers.notes_tool === 'obsidian') console.log(answers.reliquary_tc === 'yes'
|
|
739
|
+
? `\nCompanion: the onboarding file routes the AI through reliquary-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`
|
|
740
|
+
: `\nCompanion: your notes are an Obsidian vault and the AI will work on the folder directly. reliquary-tc would give it governed access (folder ACLs, human-in-the-loop, audit log): \`npx reliquary-tc /path/to/vault\`, then set reliquary_tc to yes through --answers. See ${DOCS}/companions.md`);
|
|
637
741
|
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`);
|
|
638
742
|
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`);
|
|
639
743
|
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.`);
|