agent-personalizer 0.9.1 → 0.10.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 (101) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/CONTRIBUTING.md +3 -3
  3. package/README.md +15 -13
  4. package/RELEASING.md +2 -2
  5. package/SECURITY.md +1 -1
  6. package/bin/agent-personalizer.js +128 -38
  7. package/bin/cli-util.cjs +28 -0
  8. package/bin/global.cjs +159 -33
  9. package/bin/home.cjs +69 -4
  10. package/bin/install-plan.cjs +4 -3
  11. package/bin/learn.cjs +15 -7
  12. package/bin/sessions.cjs +235 -44
  13. package/bin/uninstall.cjs +3 -3
  14. package/check/gate.cjs +46 -6
  15. package/docs/companions.md +5 -5
  16. package/docs/guarantees.md +4 -4
  17. package/docs/install.md +7 -7
  18. package/docs/learning.md +10 -10
  19. package/docs/paste-guide.md +13 -10
  20. package/docs/tiers.md +1 -1
  21. package/hooks/README.md +17 -1
  22. package/hooks/gemini-cli/session-start.sh +15 -0
  23. package/llms.txt +6 -4
  24. package/package.json +6 -3
  25. package/render/onboarding.cjs +30 -47
  26. package/render/render.cjs +24 -15
  27. package/rules/00-read-the-profile-first.md +3 -0
  28. package/rules/20-one-owner-per-rule.md +3 -0
  29. package/rules/30-folder-index-is-part-of-the-change.md +3 -0
  30. package/rules/40-sign-every-edit.md +4 -1
  31. package/skills/agent-personalizer/SKILL.md +104 -0
  32. package/templates/GEMINI.md +30 -0
  33. package/examples/freelance-illustrator/.agent-personalizer.json +0 -57
  34. package/examples/freelance-illustrator/AGENTS.md +0 -244
  35. package/examples/freelance-illustrator/AGENT_ONBOARDING.md +0 -67
  36. package/examples/freelance-illustrator/CLAUDE.md +0 -248
  37. package/examples/freelance-illustrator/LEARNED.md +0 -14
  38. package/examples/freelance-illustrator/USER.md +0 -54
  39. package/examples/freelance-illustrator/notes/README.md +0 -39
  40. package/examples/freelance-illustrator/notes/decisions.md +0 -18
  41. package/examples/freelance-illustrator/notes/inbox/2026-09-03-shot-list-for-six-prints.md +0 -14
  42. package/examples/freelance-illustrator/notes/inbox/README.md +0 -19
  43. package/examples/freelance-illustrator/notes/sessions/2026-W36.md +0 -41
  44. package/examples/freelance-illustrator/rules/00-read-the-profile-first.md +0 -24
  45. package/examples/freelance-illustrator/rules/10-evidence-before-assertion.md +0 -24
  46. package/examples/freelance-illustrator/rules/20-one-owner-per-rule.md +0 -24
  47. package/examples/freelance-illustrator/rules/30-folder-index-is-part-of-the-change.md +0 -26
  48. package/examples/freelance-illustrator/rules/40-sign-every-edit.md +0 -25
  49. package/examples/freelance-illustrator/rules/50-output-style.md +0 -21
  50. package/examples/freelance-illustrator/rules/60-act-or-ask.md +0 -30
  51. package/examples/freelance-illustrator/rules/65-ask-before-it-repeats.md +0 -18
  52. package/examples/freelance-illustrator/rules/70-their-words-point-at-the-thing.md +0 -15
  53. package/examples/freelance-illustrator/rules/80-symptoms-are-not-causes.md +0 -15
  54. package/examples/freelance-illustrator/rules/90-surface-what-they-cant-see.md +0 -15
  55. package/examples/freelance-illustrator/rules/README.md +0 -61
  56. package/examples/lab-technician/.agent-personalizer.json +0 -38
  57. package/examples/lab-technician/AGENTS.md +0 -243
  58. package/examples/lab-technician/AGENT_ONBOARDING.md +0 -64
  59. package/examples/lab-technician/CLAUDE.md +0 -247
  60. package/examples/lab-technician/LEARNED.md +0 -14
  61. package/examples/lab-technician/USER.md +0 -53
  62. package/examples/lab-technician/notes/README.md +0 -26
  63. package/examples/lab-technician/notes/decisions.md +0 -4
  64. package/examples/lab-technician/notes/inbox/2026-10-06-observation-table.md +0 -3
  65. package/examples/lab-technician/notes/inbox/README.md +0 -7
  66. package/examples/lab-technician/notes/sessions/2026-W41.md +0 -7
  67. package/examples/lab-technician/rules/00-read-the-profile-first.md +0 -24
  68. package/examples/lab-technician/rules/10-evidence-before-assertion.md +0 -24
  69. package/examples/lab-technician/rules/20-one-owner-per-rule.md +0 -24
  70. package/examples/lab-technician/rules/30-folder-index-is-part-of-the-change.md +0 -26
  71. package/examples/lab-technician/rules/40-sign-every-edit.md +0 -25
  72. package/examples/lab-technician/rules/50-output-style.md +0 -21
  73. package/examples/lab-technician/rules/60-act-or-ask.md +0 -30
  74. package/examples/lab-technician/rules/65-ask-before-it-repeats.md +0 -18
  75. package/examples/lab-technician/rules/70-their-words-point-at-the-thing.md +0 -15
  76. package/examples/lab-technician/rules/80-symptoms-are-not-causes.md +0 -15
  77. package/examples/lab-technician/rules/90-surface-what-they-cant-see.md +0 -15
  78. package/examples/lab-technician/rules/README.md +0 -61
  79. package/examples/product-designer/.agent-personalizer.json +0 -38
  80. package/examples/product-designer/AGENTS.md +0 -243
  81. package/examples/product-designer/AGENT_ONBOARDING.md +0 -63
  82. package/examples/product-designer/CLAUDE.md +0 -247
  83. package/examples/product-designer/LEARNED.md +0 -14
  84. package/examples/product-designer/USER.md +0 -53
  85. package/examples/product-designer/notes/README.md +0 -26
  86. package/examples/product-designer/notes/decisions.md +0 -4
  87. package/examples/product-designer/notes/inbox/2026-10-06-cancellation-wording.md +0 -8
  88. package/examples/product-designer/notes/inbox/README.md +0 -7
  89. package/examples/product-designer/notes/sessions/2026-W41.md +0 -7
  90. package/examples/product-designer/rules/00-read-the-profile-first.md +0 -24
  91. package/examples/product-designer/rules/10-evidence-before-assertion.md +0 -24
  92. package/examples/product-designer/rules/20-one-owner-per-rule.md +0 -24
  93. package/examples/product-designer/rules/30-folder-index-is-part-of-the-change.md +0 -26
  94. package/examples/product-designer/rules/40-sign-every-edit.md +0 -25
  95. package/examples/product-designer/rules/50-output-style.md +0 -21
  96. package/examples/product-designer/rules/60-act-or-ask.md +0 -30
  97. package/examples/product-designer/rules/65-ask-before-it-repeats.md +0 -18
  98. package/examples/product-designer/rules/70-their-words-point-at-the-thing.md +0 -15
  99. package/examples/product-designer/rules/80-symptoms-are-not-causes.md +0 -15
  100. package/examples/product-designer/rules/90-surface-what-they-cant-see.md +0 -15
  101. package/examples/product-designer/rules/README.md +0 -61
package/CHANGELOG.md CHANGED
@@ -6,6 +6,36 @@ Every entry names the adversarial audit round that produced it where one did. Au
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.10.1] - 2026-11-18
10
+
11
+ ### Fixed
12
+
13
+ - 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).
14
+ - 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).
15
+ - Document the enclosing Git `info/exclude` (and level-3 `--precommit`) exception to the project write boundary in `README.md` (#53).
16
+ - 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).
17
+
18
+ ## [0.10.0] - 2026-11-18
19
+
20
+ ### Added
21
+
22
+ - Add `templates/GEMINI.md` pointer headers, `## binding:gemini` rule sections, `.gemini/commands/personalize.toml` for `/personalize`, `hooks/gemini-cli/session-start.sh` emitting `SessionStart` `additionalContext` JSON, and Google Antigravity (`~/.gemini/config/GEMINI.md`, 24,000-byte cap) documentation (#48).
23
+ - Read Codex `memories_v2/` (`MEMORY.md`, `memory_summary.md`, `rollout_summaries/*.md`) alongside legacy `~/.codex/memories/` (#46).
24
+ - Ship `skills/agent-personalizer/SKILL.md` in the npm package (#50).
25
+
26
+ ### Changed
27
+
28
+ - Require Node.js 22 or later and run CI on Node 22, 24 and 26 (Active LTS) (#49).
29
+ - Pack `examples/answers.json` instead of full rendered example subdirectories, remove unused pre-0.8.0 interview exports from `render/onboarding.cjs`, share CLI helpers in `bin/cli-util.cjs`, and make `test/rollback.test.js` self-seeding (#50).
30
+ - Document ChatGPT's 5,000-character paid and 1,500-character Free/Go limits, update `--global` and Hermes Agent target lists across docs and issue templates, add `/docs/guides/` section anchors, and expand CLI `--help` synopses (#49).
31
+
32
+ ### Fixed
33
+
34
+ - Audit 2026-11-17: resolve Gemini CLI `v0.42+` project slugs from `projects.json` and `.project_root` (including subfolders and `~/.cache/.gemini/tmp`), and reconstruct Gemini CLI `v0.40+` append-only `.jsonl` (`MessageRecord`, string and part-array `content`, `$patch`, `$rewindTo`), `session-*.json` files and `subagent` filtering (#46).
35
+ - Audit 2026-11-17: normalize Unicode to `NFC` in `check/gate.cjs` and collapse whitespace in `bin/learn.cjs` path redaction (#47).
36
+ - Audit 2026-11-17: scope `bin/global.cjs` path qualification to installer boilerplate and rules so user `USER.md` prose and `LEARNED.md` entries are never rewritten, and isolate `HOME` in `scripts/record-demo.sh` (#47).
37
+ - Audit 2026-11-17: sync and pin `website/release-fallback.json` to `package.json`, fix the `docs/install.md` `--global` target list, and tailor the `learn --global` completion hint (#48, #49).
38
+
9
39
  ## [0.9.1] - 2026-11-10
10
40
 
11
41
  ### Security
@@ -372,7 +402,9 @@ Thirteen issues (#3 to #15) filed against `5972b32` by an independent installati
372
402
  - Installer: safe destination resolution, strict options, duplicate `--ai` refused, `--dir` created one level at a time.
373
403
  - Harness: exact exit codes, adversarial fixtures, fault injection for the rollback path.
374
404
 
375
- [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.9.1...HEAD
405
+ [Unreleased]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.1...HEAD
406
+ [0.10.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.10.0...v0.10.1
407
+ [0.10.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.9.1...v0.10.0
376
408
  [0.9.1]: https://github.com/aunysillyme/agent-personalizer/compare/v0.9.0...v0.9.1
377
409
  [0.9.0]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.7...v0.9.0
378
410
  [0.8.7]: https://github.com/aunysillyme/agent-personalizer/compare/v0.8.6...v0.8.7
package/CONTRIBUTING.md CHANGED
@@ -10,8 +10,8 @@ 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: 101 checks, exact exit codes, Linux and macOS
14
- node test/rollback.test.js "$(mktemp -d)" # after copying examples/freelance-illustrator into it
13
+ npm test # sh test/run.sh: 103 checks, exact exit codes, Linux and macOS
14
+ node test/rollback.test.js
15
15
  node check/gate.cjs --self-test
16
16
  ```
17
17
 
@@ -25,7 +25,7 @@ The privacy gate (`check/gate.cjs` against a real list) needs a local `check/for
25
25
 
26
26
  ## Adding a notes tool or an AI target
27
27
 
28
- - A notes tool is ONE entry in the `TOOL` table at the top of `render/onboarding.cjs` (`kind`, `label`, `name`, `reach`, `posture`); the interview option, the validation and the write section all derive from it. Then a row in `docs/companions.md`, and an installer hint in `bin/agent-personalizer.js` if the tool needs one. Check 60 in the harness iterates every option; add yours to the right loop. Check 74 asserts the interview options equal the table's keys.
28
+ - A notes tool is ONE entry in the `TOOL` table at the top of `render/onboarding.cjs` (`kind`, `label`, `name`, `reach`, `posture`); the saved choice options, validation and write section all derive from it. Then a row in `docs/companions.md`, and an installer hint in `bin/agent-personalizer.js` if the tool needs one. Check 60 in the harness iterates every option; add yours to the right loop. Check 74 asserts the saved options equal the table's keys.
29
29
  - An AI target needs an entry in `render/targets.json`, a row in `docs/paste-guide.md`, and updates to the hardcoded AI lists: `AIS` and `AI_LABEL` in `bin/agent-personalizer.js`, the supported targets in `bin/global.cjs`, the learning and contract target lists in `render/render.cjs`, and `SOURCE` in `bin/learn.cjs`. Set the target's supported modes and local session source where applicable. If it has a binding, add `binding:<name>` blocks to the rules that need one; unknown binding names are refused.
30
30
 
31
31
  ## Pull requests
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  npx agent-personalizer
15
15
  ```
16
16
 
17
- ![A 14-second tour: answer a few questions once, one profile and rule source becomes each AI's own file, the drift check keeps them in sync, and the closing card shows the install command.](https://raw.githubusercontent.com/aunysillyme/agent-personalizer/main/docs/trailer.gif)
17
+ ![Earlier product tour showing one profile and rule source rendered into each AI's own file, kept in sync by the drift check.](https://raw.githubusercontent.com/aunysillyme/agent-personalizer/main/docs/trailer.gif)
18
18
 
19
19
  ## What it sets up
20
20
 
@@ -25,8 +25,8 @@ npx agent-personalizer
25
25
  | Local session digest | With your yes, recent typed messages your AI uses to ask up to five evidence-backed questions. |
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
- | `AGENTS.md` | Your profile and selected rules in the project file used by Codex and Cursor. |
29
- | `GEMINI.md` | Your profile and selected rules in Gemini CLI's instruction file. |
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 Google Antigravity's instruction file. |
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. |
@@ -41,7 +41,7 @@ npx agent-personalizer
41
41
 
42
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.
43
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.
44
+ If you accepted session reading, `/personalize` in Claude Code and Gemini CLI, or the procedure in Codex's home file, 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
45
 
46
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.
47
47
 
@@ -56,8 +56,10 @@ File generation, re-runs and uninstall run in CI on Linux, macOS and Windows; yo
56
56
  | [model-orchestrator](https://github.com/aunysillyme/model-orchestrator) | Model router for AI coding agents: routes routine work to cheaper models with routing rules, 8 subagents, hooks and a CLI runner |
57
57
  | [repo-build-skill](https://github.com/aunysillyme/repo-build-skill) | Skill pack that teaches your AI to build, release and launch a GitHub repo: stack pick, README, AGENTS.md, llms.txt, repo SEO and AEO, trusted publishing. |
58
58
  | [website-build-skill](https://github.com/aunysillyme/website-build-skill) | A skill pack that turns your AI into an expert website builder: current research, design, code, accessibility, speed, SEO and security, alone or as a team. |
59
- | [lean-browser-use](https://github.com/aunysillyme/lean-browser-use) | Cut browser use cost by about 25% in Claude Code: fresh runner subagent, bulk reads, three guards and a token meter. One npx command |
59
+ | [lean-browser-use](https://github.com/aunysillyme/lean-browser-use) | Cut Claude Code browser use cost 3% to 25% (about 14% in 2 runs): fresh runner subagent, bulk reads, 3 guards and a token meter. One npx command. |
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
+ | [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
+ | [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 |
61
63
  <!-- set:end -->
62
64
 
63
65
  ## Choose your setup
@@ -82,19 +84,19 @@ For every project, install one global level-1 profile:
82
84
  npx agent-personalizer --global --ai claude,agents,gemini,hermes --yes
83
85
  ```
84
86
 
85
- The source lives in `~/.agent-personalizer/`; marked blocks go to `~/.claude/CLAUDE.md`, `~/.codex/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).
87
+ 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).
86
88
 
87
89
  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.
88
90
 
89
- 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.
91
+ 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.
90
92
 
91
- 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; global writes use the profile and selected home paths above. Edited source files are preserved and named.
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, 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.
92
94
 
93
95
  ## Privacy
94
96
 
95
97
  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.
96
98
 
97
- 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 unchanged recorded digest files; 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).
99
+ 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 unchanged recorded digest files; both leave your AI apps' history alone. agent-personalizer is not affiliated with Anthropic, OpenAI, Google, Anysphere or Nous Research, and their saved formats can change. See [learning and privacy](docs/learning.md).
98
100
 
99
101
  ## Keep it in sync
100
102
 
@@ -121,7 +123,7 @@ node render/render.cjs --dir . --check
121
123
 
122
124
  ## Put the contract in context
123
125
 
124
- At level 3, [register the Claude Code hook](hooks/README.md) to inject the onboarding restrictions and `inject: true` rules at session start. For another AI, generate a prompt to paste into its first message:
126
+ At level 3, [register the Claude Code or Gemini CLI hook](hooks/README.md) to inject the onboarding restrictions and `inject: true` rules at session start. For another AI, generate a prompt to paste into its first message:
125
127
 
126
128
  ```bash
127
129
  node render/render.cjs --dir . --contract > contract.txt
@@ -148,7 +150,7 @@ Select your notes tool through saved onboarding answers or an answers file:
148
150
  npx agent-personalizer --dir . --answers my-answers.json
149
151
  ```
150
152
 
151
- [Companion setup](docs/companions.md) explains notes connectors and how to turn onboarding answers into tool permissions and approval steps.
153
+ [Companion setup](docs/companions.md) explains notes connectors and how to apply onboarding answers to operations routed through a configured companion.
152
154
 
153
155
  | Tool | What it gives you |
154
156
  |---|---|
@@ -157,7 +159,7 @@ npx agent-personalizer --dir . --answers my-answers.json
157
159
 
158
160
  ## Common questions
159
161
 
160
- ### How do I share custom instructions across Claude Code, Codex, Cursor and ChatGPT?
162
+ ### How do I share custom instructions across Claude Code, Codex, Cursor, Gemini CLI, Hermes Agent and ChatGPT?
161
163
 
162
164
  Run `npx agent-personalizer` and select the AIs you use. One profile and rule source produce the instructions each target can carry; ChatGPT gets its profile and selected session rules as paste files.
163
165
 
@@ -213,7 +215,7 @@ Contributions are welcome: a new AI target, a notes tool, an example user, or a
213
215
 
214
216
  Pull requests are accepted under the [contributor license agreement](CLA.md); the checkbox in the pull request template records your agreement.
215
217
 
216
- The harness (`test/run.sh: 101 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.
218
+ 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.
217
219
 
218
220
  ## License
219
221
 
package/RELEASING.md CHANGED
@@ -4,8 +4,8 @@ Maintainer notes. Follow the steps below for version sites, rendering, checks an
4
4
 
5
5
  1. Every change in the release has a `CHANGELOG.md` line under `[Unreleased]`, naming the audit round or issue that produced it where one did.
6
6
  2. Move `[Unreleased]` to `[X.Y.Z] - YYYY-MM-DD`, add the compare link at the bottom, and point the `[Unreleased]` link at `vX.Y.Z...HEAD`.
7
- 3. Set the version in the three places the harness pins together: `package.json`, `const VERSION` in `render/onboarding.cjs` (it builds the docs URL every installed file links to), and the tiers link in `hooks/README.md`.
8
- 4. Re-render the example, because its files carry that version-keyed docs URL: `node render/render.cjs --dir examples/freelance-illustrator`, then the same command with `--check` must print nothing. Skipping this step is the one thing that has turned a release commit red, twice.
7
+ 3. Set the version in the four places the harness pins together: `package.json`, `const VERSION` in `render/onboarding.cjs` (it builds the docs URL every installed file links to), the tiers link in `hooks/README.md`, and `website/release-fallback.json` (plus its `publishedAt` date).
8
+ 4. Re-render all three example directories (`examples/freelance-illustrator`, `examples/lab-technician`, `examples/product-designer`), because their files carry that version-keyed docs URL: `node render/render.cjs --dir examples/freelance-illustrator`, then the same command with `--check` must print nothing. Skipping this step is the one thing that has turned a release commit red, twice.
9
9
  5. Before a public flip, and after any history rewrite, run `node check/gate.cjs --history` with the maintainer private list and review each reported location. On this repo's existing public history it reports known fixture and hash strings, so here it is a review step and its exit code does not gate a release.
10
10
  6. `sh test/run.sh` green locally (the count guard included). Push `main`; CI green on that commit.
11
11
  7. `git tag -a vX.Y.Z -m "X.Y.Z: <one line>"` and `git push origin main vX.Y.Z`.
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 101-check harness with exact exit codes, on Linux and macOS in CI. The deferred residuals are stated in the code headers: TOCTOU between check and write, unicode look-alikes in the gate, the named `--dir` being followed once via realpath, and a hard process kill between two renames. On Windows, `O_NOFOLLOW` is unavailable to the flag the uninstaller opens tracked files with; nothing depends on it there, because the delete loop re-probes every path with `lstat` immediately before each unlink, so no destructive path exists without it.
21
+ Every release passes an adversarial read-only audit (see `CHANGELOG.md`, each entry names its round) and a 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.
@@ -10,14 +10,14 @@
10
10
  const fs = require('fs');
11
11
  const path = require('path');
12
12
  const readline = require('readline');
13
- const { resolveHome } = require('./home.cjs');
13
+ const { resolveHome, resolveCodexHome, walkRealChain, hasNonEmptyOverride } = require('./home.cjs');
14
+ const { sha256, parseCliArgs } = require('./cli-util.cjs');
14
15
  const crypto = require('crypto');
15
16
  const { execFileSync } = require('child_process');
16
- const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
17
- // CLAUDE.md and AGENTS.md are written here as a pointer template only; render.cjs (run at the
17
+ // CLAUDE.md, AGENTS.md and GEMINI.md are written here as a pointer template only; render.cjs (run at the
18
18
  // end of main()) splices in the rendered block and records the final bytes it wrote, so their
19
19
  // hash is recorded there, once, against the complete file.
20
- const HOME_NAMES = new Set(['CLAUDE.md', 'AGENTS.md']);
20
+ const HOME_NAMES = new Set(['CLAUDE.md', 'AGENTS.md', 'GEMINI.md']);
21
21
 
22
22
  const PKG = path.resolve(__dirname, '..');
23
23
  const onboarding = require(path.join(PKG, 'render', 'onboarding.cjs'));
@@ -34,14 +34,14 @@ const FLAG_OPTS = ['--global', '--forget', '--all-projects', '--yes', '--default
34
34
  const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).version}
35
35
 
36
36
  npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
37
- [--answers <file.json> | --answers - | --defaults] [--full] [--yes]
38
- [--help | -h] [--version | -v]
39
- npx agent-personalizer --global [--ai claude,agents,gemini,hermes] [--yes]
37
+ [--answers <file.json> | --answers - | --defaults] [--compact]
38
+ [--precommit] [--full] [--yes] [--help | -h] [--version | -v]
39
+ npx agent-personalizer --global [--ai claude,agents,gemini,hermes] [--compact] [--yes]
40
40
  npx agent-personalizer --global --uninstall [--dry]
41
41
  npx agent-personalizer --uninstall --dir <folder> [--dry]
42
42
 
43
43
  npx agent-personalizer learn [--dir <folder>] [--all-projects] [--yes]
44
- npx agent-personalizer learn --global [--yes]
44
+ npx agent-personalizer learn --global [--yes | --forget]
45
45
  npx agent-personalizer learn --forget [--dir <folder>]
46
46
 
47
47
  First interactive install: choose your AIs, then choose whether to read your recent sessions.
@@ -65,25 +65,7 @@ const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).vers
65
65
  exit codes: 0 ok · 1 unexpected error · 2 refused or invalid input
66
66
  `;
67
67
  /* Parse argv once, strictly: value options at most once each, flags at most once, nothing unknown. */
68
- function parseArgs() {
69
- const out = {};
70
- const argv = process.argv.slice(2);
71
- for (let i = 0; i < argv.length; i++) {
72
- const a = argv[i];
73
- if (i === 0 && a === 'learn') { out.command = a; continue; }
74
- if (VALUE_OPTS.includes(a)) {
75
- if (a in out) die(`${a} given more than once`);
76
- const v = argv[i + 1];
77
- if (v === undefined || v === '' || v.startsWith('--')) die(`${a} needs a non-empty value`);
78
- out[a] = v; i++;
79
- } else if (FLAG_OPTS.includes(a)) {
80
- if (a in out) die(`${a} given more than once`);
81
- out[a] = true;
82
- } else die(`unknown option "${a}" (known: ${[...VALUE_OPTS, ...FLAG_OPTS].join(', ')})`);
83
- }
84
- return out;
85
- }
86
- const ARGS = parseArgs();
68
+ const ARGS = parseCliArgs(process.argv.slice(2), { valueOpts: VALUE_OPTS, flagOpts: FLAG_OPTS, commands: ['learn'], onError: die });
87
69
  function arg(name, dflt) { return name in ARGS ? ARGS[name] : dflt; }
88
70
  if (ARGS['--help'] || ARGS['-h']) { process.stdout.write(USAGE); process.exit(0); }
89
71
  if (ARGS['--version'] || ARGS['-v']) { process.stdout.write(require(path.join(PKG, 'package.json')).version + '\n'); process.exit(0); }
@@ -175,7 +157,7 @@ function resolveDestination(dir) {
175
157
 
176
158
 
177
159
  // One transaction for project and global plans: snapshot before writes, replace atomically, restore on failure.
178
- async function commitPlan(root, { writes, removals = [], outputPaths, prepare, finalize }) {
160
+ async function commitPlan(root, { writes, removals = [], external = [], outputPaths, prepare, finalize }) {
179
161
  for (const rel of outputPaths) {
180
162
  let parent = path.posix.dirname(rel);
181
163
  while (parent !== '.') {
@@ -200,7 +182,38 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
200
182
  while (!fs.existsSync(ancestor)) ancestor = path.dirname(ancestor);
201
183
  try { fs.accessSync(ancestor, fs.constants.W_OK); } catch (_) { die(`${rel}: parent is not writable; nothing was written`); }
202
184
  }
203
- if (prepare) prepare(newDirectories);
185
+ const savedExternal = new Map(), externalNewDirs = [];
186
+ const checkExternalBase = base => {
187
+ try {
188
+ const chain = walkRealChain(base, { allowDarwinRootLink: false, action: 'nothing was written' });
189
+ if (chain.missingDirs.length) die(`${base} does not exist; nothing was written`);
190
+ } catch (e) { if (e instanceof markers.Refusal) die(e.message); throw e; }
191
+ };
192
+ for (const ext of external) {
193
+ checkExternalBase(ext.base);
194
+ const full = path.join(ext.base, ...(ext.missingDirs || []), ext.file);
195
+ ext.full = full;
196
+ if (savedExternal.has(full)) die(`${full}: duplicate external target; nothing was written`);
197
+ let st = null;
198
+ try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
199
+ if (st) {
200
+ if (st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
201
+ if (!st.isFile()) die(`${full} is not a regular file; nothing was written`);
202
+ savedExternal.set(full, { bytes: fs.readFileSync(full), mode: st.mode & 0o777, dev: st.dev, ino: st.ino });
203
+ } else savedExternal.set(full, null);
204
+ try { fs.accessSync(ext.base, fs.constants.W_OK); } catch (_) { die(`${full}: parent is not writable; nothing was written`); }
205
+ let cur = ext.base;
206
+ for (const part of ext.missingDirs || []) {
207
+ cur = path.join(cur, part);
208
+ let dirSt = null;
209
+ try { dirSt = fs.lstatSync(cur); } catch (e) { if (e.code !== 'ENOENT') throw e; }
210
+ if (dirSt) {
211
+ if (dirSt.isSymbolicLink()) die(`${cur} is a symlink; refusing to write through it`);
212
+ if (!dirSt.isDirectory()) die(`${cur} exists and is not a directory`);
213
+ } else if (!externalNewDirs.includes(cur)) externalNewDirs.push(cur);
214
+ }
215
+ }
216
+ if (prepare) prepare(newDirectories, externalNewDirs);
204
217
  const replace = (rel, bytes, mode) => {
205
218
  const destination = safeDest(root, rel);
206
219
  const tmp = path.join(path.dirname(destination.full), `.${path.basename(rel)}.${crypto.randomBytes(8).toString('hex')}.agent-personalizer.tmp`);
@@ -211,6 +224,18 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
211
224
  fs.renameSync(tmp, destination.full);
212
225
  } finally { if (fs.existsSync(tmp)) fs.unlinkSync(tmp); }
213
226
  };
227
+ const replaceExternal = (full, bytes, mode) => {
228
+ checkExternalBase(path.dirname(full));
229
+ const tmp = path.join(path.dirname(full), `.${path.basename(full)}.${crypto.randomBytes(8).toString('hex')}.agent-personalizer.tmp`);
230
+ try {
231
+ fs.writeFileSync(tmp, bytes, { flag: 'wx', ...(mode === undefined ? {} : { mode }) });
232
+ if (mode !== undefined) fs.chmodSync(tmp, mode);
233
+ let st = null;
234
+ try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
235
+ if (st && st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
236
+ fs.renameSync(tmp, full);
237
+ } finally { if (fs.existsSync(tmp)) fs.unlinkSync(tmp); }
238
+ };
214
239
  const assertSaved = rel => {
215
240
  const destination = probe(root, rel), before = saved.get(rel);
216
241
  if (!!before !== destination.exists) die(`${rel} changed during preflight; nothing was written`);
@@ -219,15 +244,45 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
219
244
  if (info.dev !== before.dev || info.ino !== before.ino || !fs.readFileSync(destination.full).equals(before.bytes)) die(`${rel} changed during preflight; nothing was written`);
220
245
  }
221
246
  };
247
+ const assertSavedExternal = full => {
248
+ let dirExists = true;
249
+ try {
250
+ const chain = walkRealChain(path.dirname(full), { allowDarwinRootLink: false, action: 'nothing was written' });
251
+ dirExists = chain.missingDirs.length === 0;
252
+ } catch (e) { if (e instanceof markers.Refusal) die(e.message); throw e; }
253
+ let st = null;
254
+ if (dirExists) {
255
+ try { st = fs.lstatSync(full); } catch (e) { if (e.code !== 'ENOENT') throw e; }
256
+ }
257
+ if (st && st.isSymbolicLink()) die(`${full} is a symlink; refusing to write through it`);
258
+ const before = savedExternal.get(full);
259
+ if (!!before !== !!st) die(`${full} changed during preflight; nothing was written`);
260
+ if (before && (st.dev !== before.dev || st.ino !== before.ino || !fs.readFileSync(full).equals(before.bytes))) die(`${full} changed during preflight; nothing was written`);
261
+ };
222
262
  committing = true;
223
- const touched = new Set();
263
+ const touched = new Set(), touchedExternal = [], touchedExternalDirs = [];
224
264
  try {
225
265
  for (const rel of outputPaths) assertSaved(rel);
266
+ for (const full of savedExternal.keys()) assertSavedExternal(full);
267
+ for (const dir of externalNewDirs) {
268
+ let st = null;
269
+ try { st = fs.lstatSync(dir); } catch (e) { if (e.code !== 'ENOENT') throw e; }
270
+ if (st) die(`${dir} changed during preflight; nothing was written`);
271
+ fs.mkdirSync(dir);
272
+ touchedExternalDirs.push(dir);
273
+ }
226
274
  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); }
275
+ for (const ext of external) {
276
+ assertSavedExternal(ext.full);
277
+ touchedExternal.push(ext.full);
278
+ if (ext.remove) fs.unlinkSync(ext.full);
279
+ else replaceExternal(ext.full, ext.bytes, savedExternal.get(ext.full)?.mode);
280
+ if (ext.report) console.log(ext.report);
281
+ }
227
282
  for (const p of writes) {
228
283
  assertSaved(p.rel);
229
284
  touched.add(p.rel);
230
- const mode = p.rel === 'hooks/claude-code/session-start.sh' ? 0o755 : saved.get(p.rel)?.mode;
285
+ const mode = (p.rel === 'hooks/claude-code/session-start.sh' || p.rel === 'hooks/gemini-cli/session-start.sh') ? 0o755 : saved.get(p.rel)?.mode;
231
286
  replace(p.rel, p.bytes, mode);
232
287
  if (p.report) console.log(p.report);
233
288
  }
@@ -236,6 +291,17 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
236
291
  if (finalize) await finalize();
237
292
  } catch (e) {
238
293
  const incomplete = [];
294
+ for (const full of [...touchedExternal].reverse()) {
295
+ try {
296
+ checkExternalBase(path.dirname(full));
297
+ const before = savedExternal.get(full);
298
+ let st = null;
299
+ try { st = fs.lstatSync(full); } catch (_) { st = null; }
300
+ if (st && st.isSymbolicLink()) throw new Error('refusing symlink during restore');
301
+ if (before) replaceExternal(full, before.bytes, before.mode);
302
+ else if (st) fs.unlinkSync(full);
303
+ } catch (failure) { incomplete.push(`${full}: ${failure.message}`); }
304
+ }
239
305
  for (const rel of [...touched].reverse()) {
240
306
  try {
241
307
  const before = saved.get(rel), destination = probe(root, rel);
@@ -243,6 +309,12 @@ async function commitPlan(root, { writes, removals = [], outputPaths, prepare, f
243
309
  else if (destination.exists) fs.unlinkSync(destination.full);
244
310
  } catch (failure) { incomplete.push(`${rel}: ${failure.message}`); }
245
311
  }
312
+ for (const dir of [...touchedExternalDirs].reverse()) {
313
+ try {
314
+ const chain = walkRealChain(dir, { allowDarwinRootLink: false, action: 'nothing was written' });
315
+ if (!chain.missingDirs.length && fs.readdirSync(dir).length === 0) fs.rmdirSync(dir);
316
+ } catch (failure) { incomplete.push(`${dir}/: ${failure.message}`); }
317
+ }
246
318
  for (const rel of [...newDirectories].sort((a, b) => b.split('/').length - a.split('/').length)) {
247
319
  try { const destination = probe(root, rel); if (destination.exists && fs.readdirSync(destination.full).length === 0) fs.rmdirSync(destination.full); }
248
320
  catch (failure) { incomplete.push(`${rel}/: ${failure.message}`); }
@@ -296,8 +368,16 @@ async function main() {
296
368
  let home;
297
369
  try { home = resolveHome(); }
298
370
  catch (e) { if (!(e instanceof markers.Refusal)) throw e; }
299
- const found = home ? [['.claude', 'claude'], ['.codex', 'agents'], ['.gemini', 'gemini']]
300
- .filter(([folder]) => fs.existsSync(path.join(home, folder))).map(([, ai]) => ai) : [];
371
+ let codexDir = null;
372
+ if (home) {
373
+ try { codexDir = resolveCodexHome(home); }
374
+ catch (e) { if (!(e instanceof markers.Refusal)) throw e; }
375
+ }
376
+ const found = home ? [
377
+ [path.join(home, '.claude'), 'claude'],
378
+ ...(codexDir ? [[codexDir, 'agents']] : []),
379
+ [path.join(home, '.gemini'), 'gemini'],
380
+ ].filter(([folder]) => fs.existsSync(folder)).map(([, ai]) => ai) : [];
301
381
  ais = await ask('\nAIs', ais || (found.length ? found.join(',') : 'claude,agents'));
302
382
  }
303
383
  if (!/^[1-4]$/.test(String(level))) die('level must be 1, 2 or 3 (4 is accepted as 3)');
@@ -477,15 +557,22 @@ async function main() {
477
557
  const ms = markers.markerState(text, name);
478
558
  return ms.kind === 'one' ? text.slice(0, ms.bStart) + text.slice(ms.eEnd) : text;
479
559
  };
480
- for (const name of ['CLAUDE.md', 'AGENTS.md']) {
481
- if (keptRuleTargets.has(name === 'CLAUDE.md' ? 'claude' : 'agents') || adoptedRuleTargets.has(name === 'CLAUDE.md' ? 'claude' : 'agents')) continue;
560
+ for (const [name, targetKey] of [['CLAUDE.md', 'claude'], ['AGENTS.md', 'agents'], ['GEMINI.md', 'gemini']]) {
561
+ if (keptRuleTargets.has(targetKey) || adoptedRuleTargets.has(targetKey)) continue;
482
562
  const prior = previousPlan.find(p => p.rel === name);
483
563
  const next = plan.find(p => p.rel === name);
484
564
  if (!prior || !next) continue;
485
565
  const { full, exists } = probe(root, name);
486
566
  if (!exists || !fs.lstatSync(full).isFile()) continue;
487
567
  const current = fs.readFileSync(full, 'utf8');
488
- if (outside(current, name) !== outside(prior.text, name)) preservedTargets.add(name === 'CLAUDE.md' ? 'claude' : 'agents');
568
+ // Pre-0.10.0 GEMINI.md had no pointer header; adopt the new pointer template cleanly if untouched.
569
+ if (name === 'GEMINI.md' && markers.markerState(current, name).kind === 'one' && outside(current, name).trim() === '' && installedHashes[name] === sha256(fs.readFileSync(full))) {
570
+ const upgraded = markers.splice(next.text, markers.between(current, name), name);
571
+ upgrades.push({ rel: name, bytes: Buffer.from(upgraded), report: `update ${name} (added pointer header)` });
572
+ installedHashes[name] = sha256(Buffer.from(upgraded));
573
+ continue;
574
+ }
575
+ if (outside(current, name) !== outside(prior.text, name)) preservedTargets.add(targetKey);
489
576
  const migration = migrateHome(current, prior.text, next.text, text => markers.markerState(text, name));
490
577
  for (const line of migration.edited) console.log(`kept ${name} (edited pointer; manual review): ${line}`);
491
578
  if (migration.changed) {
@@ -607,6 +694,9 @@ async function main() {
607
694
  });
608
695
 
609
696
  require('./git-exclude.cjs').protect(root);
697
+ if (targets.includes('agents') && hasNonEmptyOverride(root)) {
698
+ 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.`);
699
+ }
610
700
 
611
701
  if (interactive && !cfgExists && !learnRequested) console.log('Nothing was read. Run npx agent-personalizer learn any time.');
612
702
 
@@ -620,7 +710,7 @@ async function main() {
620
710
  // Which of the files just written an AI picks up on its own, and which a human still has to paste.
621
711
  // Claude Code reads CLAUDE.md from the folder; claude.ai reads no files at all, and the success
622
712
  // text used to say nothing about that.
623
- const AUTO = { claude: 'CLAUDE.md (Claude Code)', agents: 'AGENTS.md (Codex, Cursor, anything that reads AGENTS.md)', gemini: 'GEMINI.md (Gemini CLI)' };
713
+ const AUTO = { claude: 'CLAUDE.md (Claude Code)', agents: 'AGENTS.md (Codex, Cursor, Hermes Agent, anything that reads AGENTS.md)', gemini: 'GEMINI.md (Gemini CLI, Google Antigravity)' };
624
714
  const PASTE = {
625
715
  claude: 'claude.ai and the Claude apps read no files: paste the body of USER.md, then AGENT_ONBOARDING.md, into the project or profile instructions',
626
716
  chatgpt: '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',
@@ -639,7 +729,7 @@ async function main() {
639
729
  `Which file each AI reads, and what to re-paste after you change an answer: ${DOCS}/paste-guide.md`,
640
730
  ].filter(Boolean).join('\n '));
641
731
  if (level >= 2 && kind !== 'cloud') steps.push(`Read ${base}/README.md before letting an AI write into ${base}/.`);
642
- if (level >= 3) steps.push('Register hooks/claude-code/session-start.sh (see hooks/README.md) and copy check/forbidden.example.txt to check/forbidden.local.txt.');
732
+ 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.');
643
733
  console.log('\nNext:');
644
734
  steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
645
735
  if (answers.notes_tool === 'obsidian') console.log(answers.obsidian_tc === 'yes'
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ const crypto = require('node:crypto');
4
+
5
+ const sha256 = bytes => crypto.createHash('sha256').update(bytes).digest('hex');
6
+
7
+ function parseCliArgs(argv, { valueOpts = [], flagOpts = [], commands = [], onError }) {
8
+ const out = {};
9
+ for (let i = 0; i < argv.length; i++) {
10
+ const a = argv[i];
11
+ if (i === 0 && commands.includes(a)) { out.command = a; continue; }
12
+ if (valueOpts.includes(a)) {
13
+ if (a in out) onError(`${a} given more than once`);
14
+ const v = argv[i + 1];
15
+ if (v === undefined || v === '' || v.startsWith('--')) onError(`${a} needs a non-empty value`);
16
+ out[a] = v;
17
+ i++;
18
+ } else if (flagOpts.includes(a)) {
19
+ if (a in out) onError(`${a} given more than once`);
20
+ out[a] = true;
21
+ } else {
22
+ onError(`unknown option "${a}" (known: ${[...valueOpts, ...flagOpts].join(', ')})`);
23
+ }
24
+ }
25
+ return out;
26
+ }
27
+
28
+ module.exports = { sha256, parseCliArgs };