agent-personalizer 0.4.3 → 0.5.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/README.md +32 -15
- package/bin/agent-personalizer.js +107 -53
- package/docs/companions.md +1 -1
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +2 -2
- package/hooks/README.md +1 -1
- package/package.json +1 -1
- package/render/onboarding.cjs +24 -9
- package/render/render.cjs +15 -4
- package/templates/FOLDER_README.md +2 -2
- package/templates/INBOX_README.md +1 -1
- package/templates/decisions-log.md +2 -2
- package/templates/session-log.md +3 -3
package/README.md
CHANGED
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
Most people set up custom instructions once, in one app, and still get generic output. The instructions decay over a long chat, the AI forgets where things are, every app has its own copy that drifts, and the AI treats its own guesses about you as your rulings.
|
|
8
8
|
|
|
9
|
-
This repo is the fix, in
|
|
9
|
+
This repo is the fix, in three install levels. Stop at the level you need. A level is the only thing the installer asks you to pick.
|
|
10
10
|
|
|
11
|
-
| Level | You have |
|
|
11
|
+
| Level | You have | It writes |
|
|
12
12
|
|---|---|---|
|
|
13
|
-
| **1.
|
|
14
|
-
| **2. Dynamic docs** | a notes folder the AI may edit |
|
|
15
|
-
| **3. Mechanisms** | a coding agent (Claude Code, Codex, Cursor) | the automation: your own copy of `rules/` to edit, one rule source rendered per AI, a session-start contract that puts your rules in context at decision time, a drift check that fails loudly, a forbidden-string gate. |
|
|
16
|
-
|
|
13
|
+
| **1. Profile and home file** | one AI, one app | four files and no folders: a profile of you (`USER.md`), an agent onboarding file written from your answers (`AGENT_ONBOARDING.md`), a home file the AI reads first (`CLAUDE.md` or `AGENTS.md`) with the rules rendered into it, and the installer's own `.agent-personalizer.json`. Nothing else, and the home file names nothing that is not there. |
|
|
14
|
+
| **2. Dynamic docs** | a notes folder the AI may edit | everything in level 1, plus the notes folder itself: a folder index, a weekly session log, a decisions log and an inbox, each with the rules the AI follows when it writes there. Instructions, not automation: the AI does the keeping. |
|
|
15
|
+
| **3. Mechanisms** | a coding agent (Claude Code, Codex, Cursor) | everything above, plus the automation: your own copy of `rules/` to edit, one rule source rendered per AI, a session-start contract that puts your rules in context at decision time, a drift check that fails loudly, a forbidden-string gate. |
|
|
16
|
+
|
|
17
|
+
Level 3 is the top. There is a fourth tier of this system, the hand-off layer, but it ships no files yet and the installer does not offer it: [read what it is](#the-hand-off-layer-not-an-install-level) rather than installing it.
|
|
17
18
|
|
|
18
19
|
Everything here is the generalized shape of a system that runs in production every day. The examples are invented. The failures the rules prevent are real.
|
|
19
20
|
|
|
@@ -29,7 +30,19 @@ Everything here is the generalized shape of a system that runs in production eve
|
|
|
29
30
|
npx agent-personalizer
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
Published on npm with provenance from this repository's own workflow (`npx github:aunysillyme/agent-personalizer` still works and runs the same code straight from the tag). The installer asks which AIs you use and which level you want, then writes only the matching files into the folder you point it at. It never writes secrets. `--help` lists every flag
|
|
33
|
+
Published on npm with provenance from this repository's own workflow (`npx github:aunysillyme/agent-personalizer` still works and runs the same code straight from the tag). The installer asks which AIs you use and which level you want, then writes only the matching files into the folder you point it at. It never writes secrets. `--help` lists every flag.
|
|
34
|
+
|
|
35
|
+
**The interview is short by default.** A bare `npx agent-personalizer` asks the seven questions that change behaviour (name, tone, length, notes tool and path, write policy, always-ask) plus any question the notes tool you pick makes apply, and defaults the rest. `--full` asks all 23.
|
|
36
|
+
|
|
37
|
+
**`--yes` and `--defaults` are not the same flag.**
|
|
38
|
+
|
|
39
|
+
- `--defaults` is the ANSWER SOURCE: accept every default without being asked. Use it with or without `--yes`.
|
|
40
|
+
- `--yes` is NON-INTERACTIVE MODE. It needs `--dir`, `--ai` and `--level`; without those it exits 2. With no `--answers` it falls back to the defaults.
|
|
41
|
+
- `--answers file.json` (or `--answers -` from stdin) is the other answer source, and scripts the whole interview.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx agent-personalizer --dir . --ai claude,agents --level 1 --yes --defaults
|
|
45
|
+
```
|
|
33
46
|
|
|
34
47
|
No Node? Copy `templates/USER.md` and `templates/CLAUDE.md` (or `templates/AGENTS.md`) into your project by hand. That is level 1.
|
|
35
48
|
|
|
@@ -41,9 +54,9 @@ npm_config_cache=./.npm-cache npx agent-personalizer
|
|
|
41
54
|
|
|
42
55
|
---
|
|
43
56
|
|
|
44
|
-
##
|
|
57
|
+
## Why this works: the five places instructions live
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
**These are not the install levels, and there is nothing to pick here.** The levels above are what the installer writes. The five tiers below are where instructions live once they are written, and why each placement exists. Read [docs/tiers.md](docs/tiers.md) before writing a rule of your own.
|
|
47
60
|
|
|
48
61
|
| Tier | What | Prevents |
|
|
49
62
|
|---|---|---|
|
|
@@ -63,20 +76,22 @@ Your instructions live in five places, each with one job and one failure it prev
|
|
|
63
76
|
|
|
64
77
|
The installer asks you how an AI should work with you, then writes the answers to `AGENT_ONBOARDING.md`: how to talk to you, how to shape output, what to read first and in what order, where it may write, how to save a file, and what it must always ask before doing. It is generated from your answers in `.agent-personalizer.json`, so every AI you point at the folder gets the same manual, and re-running the installer changes it everywhere at once.
|
|
65
78
|
|
|
66
|
-
- **Interactive**: run the installer without `--yes` and answer the questions. Enter accepts the default.
|
|
67
|
-
- **Scripted**: `--answers my-answers.json` (see [`test/fixtures/answers.json`](test/fixtures/answers.json) for the shape). Unknown keys, wrong types or unknown choices are refused before anything is written.
|
|
68
|
-
- **Defaults**: `--defaults`
|
|
79
|
+
- **Interactive**: run the installer without `--yes` and answer the questions. Enter accepts the default. The short interview is the default: seven questions, plus any the notes tool you pick makes apply. `--full` asks all 23. A question that applies to one notes tool is never asked about another, so nobody answers the Obsidian question about Notion.
|
|
80
|
+
- **Scripted**: `--answers my-answers.json` (see [`test/fixtures/answers.json`](test/fixtures/answers.json) for the shape), or `--answers -` to read the JSON from stdin. Unknown keys, wrong types or unknown choices are refused before anything is written.
|
|
81
|
+
- **Defaults**: `--defaults`. That is the answer source, and it is not `--yes`, which is non-interactive mode and needs `--dir`, `--ai` and `--level`. A non-interactive run with no answer source falls back to the defaults and says so. The defaults are one working setup: direct, short, one-line corrections, settle facts yourself and ask only when the answer changes what gets built, verdict first, bullets, evidence inline, sign every edit, always ask before delete / publish / send / spend / settings / standing rules. Every one is a question you can answer differently.
|
|
69
82
|
|
|
70
83
|
`USER.md` is generated from the same answers the first time and is then yours to edit. Re-running with changed answers regenerates `AGENT_ONBOARDING.md` and every rendered block; `USER.md` is regenerated only if you never edited it (it still equals the render of the previous answers), otherwise it is kept and the installer names the answers that changed so you can carry them over by hand. Two rules depend on answers: the signature rule renders only when you answered yes, and the output-style rule defers to your stated shape instead of imposing one. The session-start contract carries a short version of the onboarding block, restrictions first, so it is present at the moment of decision, not only in a file.
|
|
71
84
|
|
|
72
85
|
ChatGPT has two custom-instruction boxes with a character budget, so its render is the compact profile plus the onboarding block and only the `inject: true` rules, each box measured against the budget, and written twice: inside `chatgpt-custom-instructions.md` with the counts, and as two plain paste files, `chatgpt-box1.txt` and `chatgpt-box2.txt`. `render.cjs --strict` exits 1 instead of writing when a box is over budget, for people who wire the render into CI. Nothing is cut silently: an over-budget box is written in full and flagged, ordered so the last lines are the cheapest to trim. For the rest of the rules, use a ChatGPT Project and upload `AGENT_ONBOARDING.md` and `rules/` as files.
|
|
73
86
|
|
|
74
|
-
## Level 1: one file
|
|
87
|
+
## Level 1: the profile and one home file
|
|
75
88
|
|
|
76
89
|
1. Fill in [`templates/USER.md`](templates/USER.md), or let the installer generate it from your onboarding answers. Who you are, how to talk to you, how firmly you mean things, how you want output shaped.
|
|
77
90
|
2. Copy [`templates/CLAUDE.md`](templates/CLAUDE.md) for Claude, or [`templates/AGENTS.md`](templates/AGENTS.md) for Codex, Cursor and most other coding agents. Both are pointers: they tell the AI to read `USER.md` first and where everything else lives.
|
|
78
91
|
3. Paste the `USER.md` body into the "custom instructions" box of any chat app that has one.
|
|
79
92
|
|
|
93
|
+
Level 1 creates no notes folder, so the home file it writes names none: it points at `AGENT_ONBOARDING.md` for where the AI may write. Level 2 creates the folder and repoints the home file at it in the same run.
|
|
94
|
+
|
|
80
95
|
**The one idea in level 1:** the home file carries pointers, not hand-maintained copies. Text you retype drifts. A pointer does not, and neither does a block the renderer regenerates and `--check` compares (level 3): that block is a generated snapshot, with one owner and a drift check, which is the other acceptable shape.
|
|
81
96
|
|
|
82
97
|
## Level 2: dynamic docs
|
|
@@ -107,10 +122,12 @@ Two companions turn the onboarding answers from advice into enforcement. Neither
|
|
|
107
122
|
- **[obsidian-tc](https://github.com/The-40-Thieves/obsidian-tc)** for Obsidian vaults: governed MCP access. Your **off-limits** answer becomes a folder ACL, your **always-ask** answer becomes its human-in-the-loop list, and destructive tools fail closed until you confirm. `npx obsidian-tc /path/to/vault`.
|
|
108
123
|
- **[The Context Layer](https://sierracatalina.com/context-layer)** by Sierra Catalina: purpose-bound context with receipts. Capture → normalize → vault → decide → bundle → act; memory writes remain proposals. Your **write policy** and **off-limits** answers are its decide and vault stages in miniature. Read the essay first, then run the starter.
|
|
109
124
|
|
|
110
|
-
##
|
|
125
|
+
## The hand-off layer (not an install level)
|
|
111
126
|
|
|
112
127
|
Once you run several AIs, personalization is not the problem any more; routing is. That is a separate layer: which model handles which task, task bundles for every delegation, and CLI runs that only count as success when a deliverable exists. It is being built as its own repo and will link from here when it ships. This repo stays the beginner tier of that stack.
|
|
113
128
|
|
|
129
|
+
Nothing here installs it, so the installer stops at level 3. `--level 4` is still accepted, because it once was offered, and it writes exactly what `--level 3` writes.
|
|
130
|
+
|
|
114
131
|
---
|
|
115
132
|
|
|
116
133
|
## Every rule carries its story
|
|
@@ -133,7 +150,7 @@ examples/ one invented user, end to end
|
|
|
133
150
|
docs/ tiers.md, companions.md, paste-guide.md
|
|
134
151
|
CHANGELOG.md keyed on audit rounds
|
|
135
152
|
.github/ harness.yml: the checks on every push and PR, Ubuntu and macOS x Node 18/20/22, plus a Windows smoke job; publish.yml: npm publish with provenance, dispatched per tag
|
|
136
|
-
test/ run.sh:
|
|
153
|
+
test/ run.sh: 88 checks, exact exit codes, adversarial fixtures (symlinks, traversal, malformed markers, CRLF, partial renders)
|
|
137
154
|
```
|
|
138
155
|
|
|
139
156
|
## Changelog
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/*
|
|
4
4
|
agent-personalizer installer.
|
|
5
5
|
|
|
6
|
-
npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3
|
|
7
|
-
[--answers <file.json>] [--defaults] [--yes]
|
|
6
|
+
npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
|
|
7
|
+
[--answers <file.json>] [--defaults] [--full] [--yes]
|
|
8
8
|
|
|
9
9
|
Interactive when flags are missing and stdin is a terminal. Non-interactive with flags.
|
|
10
10
|
The ONBOARDING INTERVIEW (how to talk to you, output shape, what to read first, where the AI
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"onboarding" in .agent-personalizer.json and rendered to AGENT_ONBOARDING.md; USER.md is
|
|
14
14
|
generated from the same answers when it does not exist yet.
|
|
15
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
|
|
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
|
|
17
18
|
then on) with the renderer, hook and gate. .agent-personalizer.json stores only the answers that
|
|
18
19
|
differ from the defaults.
|
|
19
20
|
Writes only the files for the chosen AIs and level. Never overwrites a file that exists
|
|
@@ -44,21 +45,26 @@ const AI_LABEL = { claude: 'Claude (Claude Code, Claude apps)', agents: 'Codex /
|
|
|
44
45
|
function die(msg) { console.error(`agent-personalizer: ${msg}`); process.exit(2); }
|
|
45
46
|
|
|
46
47
|
const VALUE_OPTS = ['--dir', '--ai', '--level', '--answers'];
|
|
47
|
-
const FLAG_OPTS = ['--yes', '--defaults', '--quick', '--help', '--version', '-h', '-v'];
|
|
48
|
+
const FLAG_OPTS = ['--yes', '--defaults', '--quick', '--full', '--help', '--version', '-h', '-v'];
|
|
48
49
|
const USAGE = `agent-personalizer ${require(path.join(PKG, 'package.json')).version}
|
|
49
50
|
|
|
50
|
-
npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3
|
|
51
|
-
[--answers <file.json> | --answers - | --defaults] [--
|
|
51
|
+
npx agent-personalizer [--dir <folder>] [--ai claude,agents,gemini,chatgpt,prompt] [--level 1|2|3]
|
|
52
|
+
[--answers <file.json> | --answers - | --defaults] [--full] [--yes]
|
|
52
53
|
[--help | -h] [--version | -v]
|
|
53
54
|
|
|
54
55
|
Interactive when flags are missing and stdin is a terminal; the onboarding interview runs then.
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
The interview is SHORT by default: the seven questions that change behaviour (name, tone, length,
|
|
57
|
+
notes tool and path, write policy, always-ask), plus any question the notes tool you pick makes
|
|
58
|
+
apply. Every other answer takes its default.
|
|
59
|
+
--full ask every question instead of the short set. Interactive only.
|
|
60
|
+
--quick the short interview. It is now the default; the flag is kept so older commands still work.
|
|
57
61
|
--answers a JSON file of answers, or "-" to read the JSON from stdin. Unknown keys and values are refused.
|
|
58
|
-
--defaults accept every default without
|
|
59
|
-
--yes
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
--defaults the ANSWER SOURCE: accept every default without being asked. With or without --yes.
|
|
63
|
+
--yes NON-INTERACTIVE MODE, not an answer source. It needs --dir, --ai and --level, and with no
|
|
64
|
+
--answers it falls back to the defaults.
|
|
65
|
+
Levels: 1 profile, onboarding and home file(s); nothing else (the rules render from the package)
|
|
66
|
+
2 + the notes folder: its README, a weekly session log, a decisions log and an inbox
|
|
67
|
+
3 + the renderer, the session-start hook, the gate and a copy of rules/ to edit
|
|
62
68
|
exit codes: 0 ok · 1 unexpected error · 2 refused or invalid input
|
|
63
69
|
`;
|
|
64
70
|
/* Parse argv once, strictly: value options at most once each, flags at most once, nothing unknown. */
|
|
@@ -151,12 +157,15 @@ async function main() {
|
|
|
151
157
|
console.log('\nWhich AIs do you use? Comma-separated from:');
|
|
152
158
|
for (const k of AIS) console.log(` ${k.padEnd(8)} ${AI_LABEL[k]}`);
|
|
153
159
|
ais = ais || await ask('\nAIs', 'claude,agents');
|
|
154
|
-
console.log('\nLevels: 1
|
|
160
|
+
console.log('\nLevels: 1 profile, onboarding and home file(s) · 2 + the notes folder · 3 + renderer, session-start hook, gate and your own rules/');
|
|
155
161
|
level = level || await ask('Level', '1');
|
|
156
162
|
}
|
|
157
163
|
if (!dir || !ais || !level) die('non-interactive run needs --dir, --ai and --level (and --yes)');
|
|
158
|
-
if (!/^[1-4]$/.test(String(level))) die('level must be exactly 1, 2
|
|
164
|
+
if (!/^[1-4]$/.test(String(level))) die('level must be exactly 1, 2 or 3');
|
|
159
165
|
level = Number(level);
|
|
166
|
+
// 4 was once offered as a peer of 1-3 and installed exactly what 3 installs: the hand-off layer is
|
|
167
|
+
// reading material, not files. It is no longer offered, and still accepted so older scripts run.
|
|
168
|
+
if (level === 4) console.log('note: --level 4 installs exactly what --level 3 installs. The hand-off layer (routing, task bundles, verified CLI runs) is reading material until it ships, so 3 is the top install level.');
|
|
160
169
|
const targets = String(ais).split(',').map(s => s.trim()).filter(Boolean);
|
|
161
170
|
const bad = targets.filter(t => !AIS.includes(t));
|
|
162
171
|
if (bad.length) die(`unknown AI: ${bad.join(', ')} (known: ${AIS.join(', ')})`);
|
|
@@ -167,7 +176,9 @@ async function main() {
|
|
|
167
176
|
let answers = null, answersSource = '';
|
|
168
177
|
const answersFile = arg('--answers', null);
|
|
169
178
|
if (answersFile && arg('--defaults', false)) die('--answers and --defaults are exclusive');
|
|
179
|
+
if (arg('--quick', false) && arg('--full', false)) die('--quick and --full are exclusive; the short interview is the default');
|
|
170
180
|
if (arg('--quick', false) && (answersFile || arg('--defaults', false) || !interactive)) die('--quick is the short interview; it needs a terminal and no --answers, --defaults or --yes');
|
|
181
|
+
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');
|
|
171
182
|
if (answersFile) {
|
|
172
183
|
let raw;
|
|
173
184
|
const label = answersFile === '-' ? 'stdin' : answersFile;
|
|
@@ -179,17 +190,20 @@ async function main() {
|
|
|
179
190
|
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)');
|
|
180
191
|
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)';
|
|
181
192
|
} else {
|
|
182
|
-
const
|
|
183
|
-
console.log(
|
|
193
|
+
const full = !!arg('--full', false);
|
|
194
|
+
console.log('\nOnboarding: how should an AI work with you? Enter accepts the default in brackets.');
|
|
195
|
+
console.log(full
|
|
196
|
+
? `Full interview: up to ${onboarding.QUESTIONS.length} questions, some of which apply only to certain notes tools.\n`
|
|
197
|
+
: `Short interview: the ${onboarding.QUICK.length} questions that change behaviour, plus any the notes tool you pick makes apply. Every other answer takes its default; --full asks all ${onboarding.QUESTIONS.length}.\n`);
|
|
184
198
|
const raw = {};
|
|
185
199
|
for (const q of onboarding.QUESTIONS) {
|
|
186
|
-
if (
|
|
200
|
+
if (!onboarding.asks(q, raw, full)) continue;
|
|
187
201
|
if (q.options) for (const [v, l] of q.options) console.log(` ${v.padEnd(30)} ${l}`);
|
|
188
202
|
const dflt = Array.isArray(q.default) ? q.default.join(', ') : q.default;
|
|
189
203
|
raw[q.id] = onboarding.parseAnswer(q, await ask(q.ask, dflt || ''));
|
|
190
204
|
}
|
|
191
205
|
try { answers = onboarding.validate(raw); } catch (e) { die(`onboarding: ${e.message}`); }
|
|
192
|
-
answersSource =
|
|
206
|
+
answersSource = full ? 'your interview answers' : 'your short-interview answers (the rest are defaults)';
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
// The folder you name is followed once (realpath of its deepest EXISTING ancestor); the
|
|
@@ -235,13 +249,23 @@ async function main() {
|
|
|
235
249
|
// signature=no: the signature rule file is not installed (a `requires:` rule that is absent cannot drift back in),
|
|
236
250
|
// and every copied markdown loses its `Last edited by:` template line and its pointer to the rule.
|
|
237
251
|
const noSig = answers.signature === 'no';
|
|
238
|
-
const stripSig = (t) => noSig ? t.split('\n').filter(l => !l.includes('40-sign-every-edit.md') &&
|
|
252
|
+
const stripSig = (t) => noSig ? t.split('\n').filter(l => !l.includes('40-sign-every-edit.md') && !/^`?Last edited by:/.test(l)).join('\n') : t;
|
|
239
253
|
const mdCopy = (rel, src) => plan.push({ rel, text: stripSig(fs.readFileSync(src, 'utf8')) });
|
|
240
254
|
// rules/ is copied at level 3, where it becomes yours to edit; levels 1 and 2 render from the package's rules
|
|
241
255
|
if (level >= 3) for (const f of fs.readdirSync(path.join(PKG, 'rules')).sort()) {
|
|
242
256
|
if (noSig && f === '40-sign-every-edit.md') continue;
|
|
243
257
|
mdCopy(`rules/${f}`, path.join(PKG, 'rules', f));
|
|
244
258
|
}
|
|
259
|
+
// The home templates carry four `notes/...` pointer lines. They collapse to ONE line whenever the
|
|
260
|
+
// folder they name will not be there to read: a cloud notes tool has no local folder at all, and no
|
|
261
|
+
// level below 2 creates one, so a level-1 install used to hand the first session four broken
|
|
262
|
+
// pointers. NOTES_ONE_LINE is also what the level-2 upgrade looks for, byte for byte.
|
|
263
|
+
const NOTES_ONE_LINE = (why) => `- Notes: see \`AGENT_ONBOARDING.md\` § Where you may write (${why})`;
|
|
264
|
+
const NOTES_LATER = `no local notes folder at level 1; level 2 creates \`${base}/\``;
|
|
265
|
+
const notesWhy = kind === 'cloud' ? 'reached through its connector, no local files'
|
|
266
|
+
: level < 2 ? NOTES_LATER
|
|
267
|
+
: kind !== 'disk' ? 'local fallback folder `notes/`'
|
|
268
|
+
: null; // disk, level 2+: the four paths, retargeted at notes_path
|
|
245
269
|
const home = (name) => {
|
|
246
270
|
let t = fs.readFileSync(path.join(PKG, 'templates', name), 'utf8');
|
|
247
271
|
if (level < 3) {
|
|
@@ -249,18 +273,16 @@ async function main() {
|
|
|
249
273
|
t = t.split('\n').filter(l => !/Rules, one file each, the owning copy/.test(l)).join('\n');
|
|
250
274
|
t = t.replace(/`\[owner: rules\/[^\]]+\]`/g, '`[owner: the rendered block below]`');
|
|
251
275
|
}
|
|
252
|
-
if (
|
|
253
|
-
else {
|
|
254
|
-
// cloud, read-only and unknown tools: one line pointing at the onboarding file instead of four local paths
|
|
255
|
-
const tool = onboarding.kindOf(answers) === 'cloud' ? 'reached through its connector, no local files' : 'local fallback folder `notes/`';
|
|
276
|
+
if (notesWhy) {
|
|
256
277
|
let done = false;
|
|
257
278
|
t = t.split('\n').filter(l => { if (!/`notes\//.test(l)) return true; if (done) return false; done = true; return true; })
|
|
258
|
-
.map(l => /`notes\//.test(l) ?
|
|
259
|
-
}
|
|
279
|
+
.map(l => /`notes\//.test(l) ? NOTES_ONE_LINE(notesWhy) : l).join('\n');
|
|
280
|
+
} else if (base !== 'notes') t = t.replace(/\bnotes\//g, `${base}/`);
|
|
260
281
|
return stripSig(t);
|
|
261
282
|
};
|
|
262
|
-
|
|
263
|
-
if (targets.includes('
|
|
283
|
+
const POINTER = 'pointer file; the renderer fills its block below';
|
|
284
|
+
if (targets.includes('claude')) plan.push({ rel: 'CLAUDE.md', text: home('CLAUDE.md'), note: POINTER });
|
|
285
|
+
if (targets.includes('agents')) plan.push({ rel: 'AGENTS.md', text: home('AGENTS.md'), note: POINTER });
|
|
264
286
|
if (level >= 2 && kind !== 'cloud') { // a cloud tool's notes are not local files; no folder named after a workspace
|
|
265
287
|
mdCopy(`${base}/README.md`, path.join(PKG, 'templates', 'FOLDER_README.md'));
|
|
266
288
|
mdCopy(`${base}/sessions/TEMPLATE-week.md`, path.join(PKG, 'templates', 'session-log.md'));
|
|
@@ -310,31 +332,43 @@ async function main() {
|
|
|
310
332
|
} else userAction = 'keep';
|
|
311
333
|
}
|
|
312
334
|
|
|
313
|
-
// Upgrade from
|
|
314
|
-
//
|
|
315
|
-
//
|
|
335
|
+
// Upgrade from a lower level. Two repairs, each matched byte for byte against a line THIS installer
|
|
336
|
+
// wrote, so anything the user edited is left alone:
|
|
337
|
+
// level 3: the pointer lines said "the rendered block below"; now that rules/ arrives they name it.
|
|
338
|
+
// level 2: the one-line notes placeholder a level-1 install wrote becomes the real pointers, now
|
|
339
|
+
// that the folder behind them exists.
|
|
316
340
|
const upgrades = [];
|
|
317
|
-
if (level >=
|
|
341
|
+
if (level >= 2) for (const name of ['CLAUDE.md', 'AGENTS.md']) {
|
|
318
342
|
if (!(name === 'CLAUDE.md' ? targets.includes('claude') : targets.includes('agents'))) continue;
|
|
319
343
|
const { full, exists } = probe(root, name);
|
|
320
344
|
if (!exists || !fs.lstatSync(full).isFile()) continue;
|
|
321
345
|
const tmpl = stripSig(fs.readFileSync(path.join(PKG, 'templates', name), 'utf8')).split('\n');
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
346
|
+
const lines = fs.readFileSync(full, 'utf8').split('\n');
|
|
347
|
+
const why = [];
|
|
348
|
+
if (level >= 3) {
|
|
349
|
+
let repointed = false;
|
|
350
|
+
for (const t of tmpl) {
|
|
351
|
+
if (!/`\[owner: rules\/[^\]]+\]`/.test(t)) continue;
|
|
352
|
+
const placeholder = t.replace(/`\[owner: rules\/[^\]]+\]`/g, '`[owner: the rendered block below]`');
|
|
353
|
+
for (let i = 0; i < lines.length; i++) if (lines[i] === placeholder) { lines[i] = t; repointed = true; }
|
|
354
|
+
}
|
|
355
|
+
const rulesLine = tmpl.find(l => /Rules, one file each, the owning copy/.test(l));
|
|
356
|
+
const anchorIdx = lines.findIndex(l => /AGENT_ONBOARDING\.md`$/.test(l) && /^- /.test(l));
|
|
357
|
+
if (rulesLine && !lines.includes(rulesLine) && anchorIdx !== -1 && repointed) lines.splice(anchorIdx + 1, 0, rulesLine);
|
|
358
|
+
if (repointed) why.push('rule pointers now name rules/, which this level installs');
|
|
329
359
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
360
|
+
if (!notesWhy) { // this run creates the folder the four lines name
|
|
361
|
+
const idx = lines.indexOf(NOTES_ONE_LINE(NOTES_LATER));
|
|
362
|
+
if (idx !== -1) {
|
|
363
|
+
lines.splice(idx, 1, ...tmpl.filter(l => /`notes\//.test(l)).map(l => base === 'notes' ? l : l.replace(/\bnotes\//g, `${base}/`)));
|
|
364
|
+
why.push(`notes pointers now name ${base}/, which this level installs`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (why.length) { try { fs.accessSync(full, fs.constants.W_OK); } catch (_) { die(`${name} is not writable; nothing was written`); } upgrades.push({ name, full, text: lines.join('\n'), why }); }
|
|
334
368
|
}
|
|
335
369
|
|
|
336
370
|
// ---- WRITE ----
|
|
337
|
-
for (const u of upgrades) { fs.writeFileSync(u.full, u.text); console.log(`update ${u.name} (
|
|
371
|
+
for (const u of upgrades) { fs.writeFileSync(u.full, u.text); console.log(`update ${u.name} (${u.why.join('; ')})`); }
|
|
338
372
|
if (userAction === 'create') { fs.writeFileSync(user.full, onboarding.renderUser(answers), { flag: 'wx' }); console.log('wrote USER.md (from your answers)'); }
|
|
339
373
|
else if (userAction === 'regenerate') { fs.writeFileSync(user.full, onboarding.renderUser(answers)); console.log(`update USER.md (regenerated: it matched your previous answers byte for byte; changed: ${changedKeys.join(', ')})`); }
|
|
340
374
|
else if (userAction === 'conflict') {
|
|
@@ -347,7 +381,7 @@ async function main() {
|
|
|
347
381
|
else {
|
|
348
382
|
const { full, exists } = safeDest(root, p.rel);
|
|
349
383
|
if (exists) console.log(`kept ${p.rel} (exists)`);
|
|
350
|
-
else { fs.writeFileSync(full, p.text, { flag: 'wx' }); console.log(`wrote ${p.rel}`); }
|
|
384
|
+
else { fs.writeFileSync(full, p.text, { flag: 'wx' }); console.log(`wrote ${p.rel}${p.note ? ` (${p.note})` : ''}`); }
|
|
351
385
|
}
|
|
352
386
|
}
|
|
353
387
|
if (level >= 3) {
|
|
@@ -366,15 +400,35 @@ async function main() {
|
|
|
366
400
|
const DOCS = onboarding.DOCS;
|
|
367
401
|
// 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
|
|
368
402
|
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'}`;
|
|
403
|
+
// The rerun command names the folder that was just installed, in full. "--dir ." was a command that
|
|
404
|
+
// wrote into whatever directory it was pasted from, which is not where the install went.
|
|
405
|
+
const shq = (x) => /^[A-Za-z0-9._\/@:+,=-]+$/.test(x) ? x : `'${String(x).replace(/'/g, "'\\''")}'`;
|
|
406
|
+
const DIR = shq(root);
|
|
407
|
+
// Which of the files just written an AI picks up on its own, and which a human still has to paste.
|
|
408
|
+
// Claude Code reads CLAUDE.md from the folder; claude.ai reads no files at all, and the success
|
|
409
|
+
// text used to say nothing about that.
|
|
410
|
+
const AUTO = { claude: 'CLAUDE.md (Claude Code)', agents: 'AGENTS.md (Codex, Cursor, anything that reads AGENTS.md)', gemini: 'GEMINI.md (Gemini CLI)' };
|
|
411
|
+
const PASTE = {
|
|
412
|
+
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',
|
|
413
|
+
chatgpt: 'ChatGPT: paste chatgpt-box1.txt and chatgpt-box2.txt into its two custom-instruction boxes',
|
|
414
|
+
prompt: 'system-prompt.md: paste it wherever you set a system prompt',
|
|
415
|
+
};
|
|
416
|
+
const auto = targets.filter(t => AUTO[t]).map(t => AUTO[t]);
|
|
417
|
+
const paste = targets.filter(t => PASTE[t]).map(t => PASTE[t]);
|
|
418
|
+
const steps = [];
|
|
419
|
+
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.');
|
|
420
|
+
steps.push(level >= 3
|
|
421
|
+
? `Re-render after editing: node render/render.cjs --dir ${DIR} (drift check: add --check)`
|
|
422
|
+
: `Re-render after editing by running this installer again (it keeps your files and only refreshes the rendered blocks):\n ${SELF} --dir ${DIR} --ai ${targets.join(',')} --level ${level} --yes`);
|
|
423
|
+
steps.push([
|
|
424
|
+
auto.length ? `Read from ${root} automatically, nothing to paste: ${auto.join(', ')}.` : null,
|
|
425
|
+
paste.length ? `Still needs a paste: ${paste.join('; ')}.` : null,
|
|
426
|
+
`Which file each AI reads, and what to re-paste after you change an answer: ${DOCS}/paste-guide.md`,
|
|
427
|
+
].filter(Boolean).join('\n '));
|
|
428
|
+
if (level >= 2 && kind !== 'cloud') steps.push(`Read ${base}/README.md before letting an AI write into ${base}/.`);
|
|
429
|
+
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.');
|
|
369
430
|
console.log('\nNext:');
|
|
370
|
-
console.log(
|
|
371
|
-
console.log(' USER.md is yours to edit freely; the onboarding file is regenerated from .agent-personalizer.json.');
|
|
372
|
-
console.log(level >= 3
|
|
373
|
-
? ' 2. Re-render after editing: node render/render.cjs --dir . (drift check: add --check)'
|
|
374
|
-
: ` 2. Re-render after editing by running this installer again (it keeps your files and only refreshes the rendered blocks):\n ${SELF} --dir . --ai ${targets.join(',')} --level ${level} --yes`);
|
|
375
|
-
if (level >= 2 && kind !== 'cloud') console.log(` 3. Read ${base}/README.md before letting an AI write into ${base}/.`);
|
|
376
|
-
if (level >= 3) console.log(' 4. Register hooks/claude-code/session-start.sh (see hooks/README.md) and copy check/forbidden.example.txt to check/forbidden.local.txt.');
|
|
377
|
-
if (level >= 4) console.log(' 5. Level 4 is pointers only for now: routing, task bundles and verified CLI runs live in the multi-agent layer, linked from the README when it ships.');
|
|
431
|
+
steps.forEach((step, i) => console.log(` ${i + 1}. ${step}`));
|
|
378
432
|
if (answers.notes_tool === 'obsidian') console.log(answers.obsidian_tc === 'yes'
|
|
379
433
|
? `\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`
|
|
380
434
|
: `\nCompanion: your notes are an Obsidian vault and the AI will work on the folder directly. obsidian-tc would give it governed access (folder ACLs, human-in-the-loop, audit log): \`npx obsidian-tc /path/to/vault\`, then re-run this installer and answer yes. See ${DOCS}/companions.md`);
|
|
@@ -382,7 +436,7 @@ async function main() {
|
|
|
382
436
|
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`);
|
|
383
437
|
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.`);
|
|
384
438
|
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`);
|
|
385
|
-
console.log(
|
|
439
|
+
if (targets.length > 1) console.log(`\nSeveral agents? Read ${DOCS}/companions.md on the Context Layer: purpose-bound bundles and receipts for every delegation.`);
|
|
386
440
|
console.log('\nNothing here read an environment variable or wrote a secret.');
|
|
387
441
|
console.log('\nIf this saved you time, a star helps people find it: https://github.com/aunysillyme/agent-personalizer');
|
|
388
442
|
}
|
package/docs/companions.md
CHANGED
|
@@ -43,7 +43,7 @@ Lexical search and every note tool work immediately; semantic and graph retrieva
|
|
|
43
43
|
- **Write policy** "logs and inbox only" or "ask before every write" is the Layer's rule that memory writes remain proposals until approved.
|
|
44
44
|
- **Off limits** is the Layer's vault stage: originals that never enter a bundle.
|
|
45
45
|
- **Always ask before** is the Layer's decide stage: allow, reduce, approve or deny by action and recipient.
|
|
46
|
-
|
|
46
|
+
Running several agents is where it earns its keep (the hand-off layer, which this repo does not install): each delegation carries a purpose-bound bundle and returns a receipt, so you can answer "who saw what, and why" after the fact. The repo's `AGENT_ONBOARDING.md` is the human-readable policy; the Context Layer is how you make a machine enforce and record it.
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
@@ -15,7 +15,7 @@ _Generated by agent-personalizer from Mara's own answers (stored in `.agent-pers
|
|
|
15
15
|
- **Directness:** direct answers, no hedging, say what you think.
|
|
16
16
|
- **Length:** short by default, detail on request.
|
|
17
17
|
- **When you are wrong:** state the correction in one line and move on.
|
|
18
|
-
- **When you are unsure:** settle facts
|
|
18
|
+
- **When you are unsure:** settle facts yourself; ask only when the answer changes what gets built.
|
|
19
19
|
- **Never:** em dashes; start a reply with Great question; client names outside their folder.
|
|
20
20
|
|
|
21
21
|
### Output shape
|
|
@@ -37,7 +37,7 @@ _Generated by agent-personalizer from Mara's own answers (stored in `.agent-pers
|
|
|
37
37
|
|
|
38
38
|
### Where you may write
|
|
39
39
|
|
|
40
|
-
- **Notes live in Obsidian:** reach them as the vault at `notes/`, through **obsidian-tc** (governed MCP: folder ACLs, human-in-the-loop confirmation for destructive tools, audit log) rather than raw filesystem access; see https://github.com/aunysillyme/agent-personalizer/blob/v0.
|
|
40
|
+
- **Notes live in Obsidian:** reach them as the vault at `notes/`, through **obsidian-tc** (governed MCP: folder ACLs, human-in-the-loop confirmation for destructive tools, audit log) rather than raw filesystem access; see https://github.com/aunysillyme/agent-personalizer/blob/v0.5.0/docs/companions.md.
|
|
41
41
|
- You may create and edit files anywhere under `notes/`, under that folder's rules. Nowhere else without being asked.
|
|
42
42
|
- **Every folder you write into has a README.** Any write, edit or delete means that README is corrected in the same pass: the file's one-line description, the folder's status, settled decisions, next steps. A stale index is worse than none, because the next agent believes it.
|
|
43
43
|
- **Session log:** append a dated section to this week's note in `notes/sessions/`. **Decisions:** one line each in `notes/decisions.md`. **Inbox:** one file per item in `notes/inbox/`; finished items are deleted, not marked done.
|
package/hooks/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# hooks/
|
|
2
2
|
|
|
3
|
-
Tier 3 from the tiers doc (https://github.com/aunysillyme/agent-personalizer/blob/v0.
|
|
3
|
+
Tier 3 from the tiers doc (https://github.com/aunysillyme/agent-personalizer/blob/v0.5.0/docs/tiers.md): the few rules that must be in context at the moment of decision, injected in full at the start of every session. Injection puts the text in front of the model; whether the model follows it is up to the model and the host. This is the strongest placement available, not a guarantee.
|
|
4
4
|
|
|
5
5
|
Which rules? The ones with `inject: true` in their frontmatter. Keep that set small. Every injected rule costs tokens every session.
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-personalizer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Personalize any AI with dynamic instructions. One profile, one rule source, rendered for Claude, Codex, Cursor, Gemini and ChatGPT.",
|
|
5
5
|
"author": "aunysillyme (https://github.com/aunysillyme)",
|
|
6
6
|
"license": "MIT",
|
package/render/onboarding.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
DOCS points at the matching tag on GitHub so an installed copy never links to a file the
|
|
18
18
|
destination does not have.
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = '0.
|
|
20
|
+
const VERSION = '0.5.0';
|
|
21
21
|
const DOCS = `https://github.com/aunysillyme/agent-personalizer/blob/v${VERSION}/docs`;
|
|
22
22
|
|
|
23
23
|
/* THE single source for notes tools. Add a tool here and nowhere else: the interview option, the
|
|
@@ -60,7 +60,7 @@ const QUESTIONS = [
|
|
|
60
60
|
{ id: 'mistakes', ask: 'When the AI is wrong, how should it handle it?', type: 'choice', default: 'one-line',
|
|
61
61
|
options: [['one-line', 'state the correction in one line and move on'], ['brief', 'correction plus one line on the cause'], ['full', 'correction plus the full cause']] },
|
|
62
62
|
{ id: 'unsure', ask: 'When the AI is unsure, what should it do?', type: 'choice', default: 'ask-when-it-changes-the-build',
|
|
63
|
-
options: [['ask-when-it-changes-the-build', 'settle facts itself; ask only when the answer changes what gets built'], ['ask-first', 'ask before doing anything uncertain'], ['assume-and-say', 'proceed on a stated assumption, never ask']] },
|
|
63
|
+
options: [['ask-when-it-changes-the-build', 'settle facts itself; ask only when the answer changes what gets built', 'settle facts yourself; ask only when the answer changes what gets built'], ['ask-first', 'ask before doing anything uncertain'], ['assume-and-say', 'proceed on a stated assumption, never ask']] },
|
|
64
64
|
{ id: 'lead_with', ask: 'What should a reply open with?', type: 'choice', default: 'verdict',
|
|
65
65
|
options: [['verdict', 'the answer or the verdict'], ['summary', 'a one-paragraph summary'], ['context', 'the context, then the answer']] },
|
|
66
66
|
{ id: 'structure', ask: 'How should replies be shaped?', type: 'choice', default: 'bullets',
|
|
@@ -71,9 +71,9 @@ const QUESTIONS = [
|
|
|
71
71
|
{ id: 'read_first', ask: 'Files the AI reads first, in order (comma-separated)', type: 'list', default: ['USER.md', 'AGENT_ONBOARDING.md'] },
|
|
72
72
|
{ id: 'notes_tool', ask: 'Where do your notes live?', type: 'choice', default: 'folder',
|
|
73
73
|
options: Object.entries(TOOL).map(([k, t]) => [k, t.label]) },
|
|
74
|
-
{ id: 'obsidian_tc', ask: '
|
|
74
|
+
{ id: 'obsidian_tc', ask: 'Do you use obsidian-tc, the governed MCP?', type: 'choice', default: 'no', when: (a) => a.notes_tool === 'obsidian',
|
|
75
75
|
options: [['no', 'not installed; the AI works on the vault folder directly'], ['yes', 'installed and connected; the AI reaches the vault through it']] },
|
|
76
|
-
{ id: 'notes_tool_name', ask: '
|
|
76
|
+
{ id: 'notes_tool_name', ask: 'The name of that tool', type: 'text', default: '', when: (a) => a.notes_tool === 'other' },
|
|
77
77
|
{ id: 'notes_path', ask: 'Where inside it: the folder path (Obsidian, Logseq, plain folder), or the workspace / notebook / folder name (Notion, Google Docs, Apple Notes, others)', type: 'text', default: 'notes' },
|
|
78
78
|
{ id: 'tracker', ask: 'Your task tracker, if the AI should read it ("none" to skip)', type: 'text', default: 'none' },
|
|
79
79
|
{ id: 'write_policy', ask: 'How freely may the AI write into your notes?', type: 'choice', default: 'notes-freely',
|
|
@@ -89,8 +89,18 @@ const QUESTIONS = [
|
|
|
89
89
|
];
|
|
90
90
|
|
|
91
91
|
const IDS = new Set(QUESTIONS.map(q => q.id));
|
|
92
|
-
/* the
|
|
92
|
+
/* the short interview, which is what a bare `npx agent-personalizer` runs; every other answer takes
|
|
93
|
+
its default. --full asks the rest as well. */
|
|
93
94
|
const QUICK = ['name', 'tone', 'length', 'notes_tool', 'notes_path', 'write_policy', 'always_ask'];
|
|
95
|
+
/* Does this interview ask question q, given the answers so far? A question with a `when` is
|
|
96
|
+
CONDITIONAL: it is asked exactly when its condition holds, short interview or long, so nobody
|
|
97
|
+
answers the Obsidian question about Notion and nobody picks "other" without being asked to name
|
|
98
|
+
it. Every other question is asked in the long interview and only in the short set otherwise.
|
|
99
|
+
The installer's interview loop calls this, so a test of it is a test of the installer. */
|
|
100
|
+
function asks(q, answersSoFar, full) {
|
|
101
|
+
if (q.when) return !!q.when(answersSoFar || {});
|
|
102
|
+
return !!full || QUICK.includes(q.id);
|
|
103
|
+
}
|
|
94
104
|
/* only the answers that differ from the defaults: what the installer stores, so the config reads as
|
|
95
105
|
"what this person chose" and a future default applies to everyone who never chose otherwise */
|
|
96
106
|
/* PINNED answers are always stored, default or not: they govern what the AI may touch, so a future
|
|
@@ -151,6 +161,11 @@ function parseAnswer(q, raw) {
|
|
|
151
161
|
}
|
|
152
162
|
|
|
153
163
|
const label = (q, v) => { const o = q.options && q.options.find(x => x[0] === v); return o ? o[1] : v; };
|
|
164
|
+
/* The interview asks the HUMAN about the AI, so an option's label is third person ("settle facts
|
|
165
|
+
itself"). USER.md, AGENT_ONBOARDING.md and the session-start contract all address the AI
|
|
166
|
+
directly, so they take the option's third element, its second-person phrasing, where a choice
|
|
167
|
+
carries one. Without it the AI reads "when you are unsure: settle facts itself". */
|
|
168
|
+
const youLabel = (q, v) => { const o = q.options && q.options.find(x => x[0] === v); return o ? (o[2] || o[1]) : v; };
|
|
154
169
|
const Q = Object.fromEntries(QUESTIONS.map(q => [q.id, q]));
|
|
155
170
|
const bullets = (arr, empty) => arr.length ? arr.map(x => `- ${x}`).join('\n') : `- ${empty}`;
|
|
156
171
|
/* md(): for values placed INSIDE an inline-code span; a code span cannot carry structure, so only
|
|
@@ -180,7 +195,7 @@ function renderUser(a) {
|
|
|
180
195
|
- **Directness:** ${label(Q.tone, a.tone)}
|
|
181
196
|
- **Length:** ${label(Q.length, a.length)}
|
|
182
197
|
- **When you are wrong:** ${label(Q.mistakes, a.mistakes)}
|
|
183
|
-
- **When you are unsure:** ${
|
|
198
|
+
- **When you are unsure:** ${youLabel(Q.unsure, a.unsure)}
|
|
184
199
|
- **Never:** ${a.never.length ? a.never.map(md).join('; ') : 'nothing declared yet'}
|
|
185
200
|
|
|
186
201
|
## How firmly I mean things
|
|
@@ -274,7 +289,7 @@ ${a.work ? `- **What they do:** ${md(a.work)}\n` : ''}${a.focus ? `- **Current f
|
|
|
274
289
|
- **Directness:** ${label(Q.tone, a.tone)}.
|
|
275
290
|
- **Length:** ${label(Q.length, a.length)}.
|
|
276
291
|
- **When you are wrong:** ${label(Q.mistakes, a.mistakes)}.
|
|
277
|
-
- **When you are unsure:** ${
|
|
292
|
+
- **When you are unsure:** ${youLabel(Q.unsure, a.unsure)}.
|
|
278
293
|
- **Never:** ${a.never.length ? a.never.map(md).join('; ') : 'nothing declared'}.
|
|
279
294
|
|
|
280
295
|
### Output shape
|
|
@@ -339,7 +354,7 @@ function contractBlock(a, opts) {
|
|
|
339
354
|
a.off_limits.length ? `Off limits in any output: ${a.off_limits.map(md).join(', ')}.` : null,
|
|
340
355
|
writesLine(a),
|
|
341
356
|
files ? `Read first: ${a.read_first.map(md).join(' → ')}.` : null,
|
|
342
|
-
`Directness: ${label(Q.tone, a.tone)}. Length: ${label(Q.length, a.length)}. When wrong: ${label(Q.mistakes, a.mistakes)}. When unsure: ${
|
|
357
|
+
`Directness: ${label(Q.tone, a.tone)}. Length: ${label(Q.length, a.length)}. When wrong: ${label(Q.mistakes, a.mistakes)}. When unsure: ${youLabel(Q.unsure, a.unsure)}.`,
|
|
343
358
|
`Open with ${label(Q.lead_with, a.lead_with)}; ${label(Q.structure, a.structure)}; evidence ${label(Q.evidence, a.evidence)}.${a.signature === 'yes' ? ' Sign every edit to a note (one `Last edited by:` line, overwritten).' : ''}`,
|
|
344
359
|
a.never.length ? `Never: ${a.never.map(md).join('; ')}.` : null,
|
|
345
360
|
].filter(x => x !== null).join('\n');
|
|
@@ -357,4 +372,4 @@ function compactProfile(a) {
|
|
|
357
372
|
].filter(Boolean).join('\n');
|
|
358
373
|
}
|
|
359
374
|
|
|
360
|
-
module.exports = { QUESTIONS, QUICK, PINNED, TOOL, VERSION, DOCS, FALLBACK, defaults, sparse, validate, parseAnswer, renderUser, renderOnboarding, contractBlock, compactProfile, kindOf, baseFor };
|
|
375
|
+
module.exports = { QUESTIONS, QUICK, PINNED, TOOL, VERSION, DOCS, FALLBACK, asks, defaults, sparse, validate, parseAnswer, renderUser, renderOnboarding, contractBlock, compactProfile, kindOf, baseFor };
|
package/render/render.cjs
CHANGED
|
@@ -383,6 +383,17 @@ function between(existing, file) {
|
|
|
383
383
|
return existing.slice(st.bEnd, st.eStart).replace(/\r\n/g, '\n').replace(/^\n/, '').replace(/\n$/, '');
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
/* One line per file, one verb per line, and the verb is the one that is true of THAT file. The
|
|
387
|
+
installer writes a home file from its template and then calls this renderer to fill the block, so
|
|
388
|
+
a run that printed "wrote" for both steps said the same file was created twice, and a re-run that
|
|
389
|
+
kept the file printed "kept" and then "wrote" it. */
|
|
390
|
+
function report(label, existing, current, block, raw) {
|
|
391
|
+
if (existing == null) return `wrote ${label}`;
|
|
392
|
+
if (current === block) return `ok ${label} (${raw ? 'already current' : 'rendered block already current'})`;
|
|
393
|
+
if (!raw && current === null) return `update ${label} (rendered block added)`;
|
|
394
|
+
return `update ${label} (${raw ? 'rewritten' : 'rendered block'})`;
|
|
395
|
+
}
|
|
396
|
+
|
|
386
397
|
function main() {
|
|
387
398
|
ARGS = parseArgs();
|
|
388
399
|
if (arg('--version', false) || arg('-v', false)) { process.stdout.write(onboarding.VERSION + '\n'); return; }
|
|
@@ -447,7 +458,7 @@ function main() {
|
|
|
447
458
|
// the generated file must itself re-parse to exactly one block, or the next render would refuse it
|
|
448
459
|
if (output != null) { const st = markerState(output, `${target.file} (generated)`); if (st.kind !== 'one' || between(output, `${target.file} (generated)`) !== block) die(`${target.file}: generated content would not re-parse cleanly; a fence in USER.md or a rule is unbalanced. Nothing was written`); }
|
|
449
460
|
const mode = existing == null ? 0o644 : (fs.statSync(file).mode & 0o777);
|
|
450
|
-
const entry = { key, target, file, block, current, output, mode };
|
|
461
|
+
const entry = { key, target, file, block, current, output, mode, report: report(target.file, existing, current, block, false) };
|
|
451
462
|
if (!target.boxes) return entry;
|
|
452
463
|
// the two plain paste files: whole-file outputs, no markers, compared whole in --check
|
|
453
464
|
const raws = Object.entries(target.boxFiles || {}).map(([which, rel]) => {
|
|
@@ -457,7 +468,7 @@ function main() {
|
|
|
457
468
|
if (fs.existsSync(rfile)) rexisting = decodeUtf8(fs.readFileSync(rfile), rel);
|
|
458
469
|
if (!check) { try { fs.accessSync(rexisting == null ? path.dirname(rfile) : rfile, fs.constants.W_OK); } catch (_) { die(`${rel}: not writable. Nothing was written`); } }
|
|
459
470
|
const rmode = rexisting == null ? 0o644 : (fs.statSync(rfile).mode & 0o777);
|
|
460
|
-
return { key: `${key}:${which}`, target: { file: rel }, file: rfile, block: text, current: rexisting, output: check ? null : text, mode: rmode, raw: true };
|
|
471
|
+
return { key: `${key}:${which}`, target: { file: rel }, file: rfile, block: text, current: rexisting, output: check ? null : text, mode: rmode, raw: true, report: report(rel, rexisting, rexisting, text, true) };
|
|
461
472
|
});
|
|
462
473
|
return [entry, ...raws];
|
|
463
474
|
}).flat();
|
|
@@ -516,7 +527,7 @@ function main() {
|
|
|
516
527
|
try {
|
|
517
528
|
for (const p of plan) {
|
|
518
529
|
const tmp = path.join(path.dirname(p.file), `.${path.basename(p.file)}.${run}.agent-personalizer.tmp`);
|
|
519
|
-
staged.push({ tmp, file: p.file, label: p.target.file, mode: p.mode }); // recorded BEFORE the file can exist; cleanup tolerates ENOENT
|
|
530
|
+
staged.push({ tmp, file: p.file, label: p.target.file, mode: p.mode, report: p.report }); // recorded BEFORE the file can exist; cleanup tolerates ENOENT
|
|
520
531
|
fs.writeFileSync(tmp, p.output, { flag: 'wx', mode: p.mode });
|
|
521
532
|
fs.chmodSync(tmp, p.mode);
|
|
522
533
|
}
|
|
@@ -538,7 +549,7 @@ function main() {
|
|
|
538
549
|
} catch (e) { undo(`could not commit output (${e.message})`); }
|
|
539
550
|
const leftovers = [];
|
|
540
551
|
for (const c of committed) if (c.bak) tryUnlink(c.bak, leftovers, 'backup not removed');
|
|
541
|
-
for (const s of staged) console.log(
|
|
552
|
+
for (const s of staged) console.log(s.report);
|
|
542
553
|
for (const o of (renderTarget.overBudget || [])) console.log(`OVER BUDGET ${o} (written in full; trim by hand, bottom up)`);
|
|
543
554
|
if (leftovers.length) {
|
|
544
555
|
console.error('render: every target was written, but CLEANUP INCOMPLETE. Remove these by hand (they hold copies of the previous targets):');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `<Folder name>`
|
|
2
2
|
|
|
3
3
|
*One line: what this folder is for and what does NOT belong here.*
|
|
4
4
|
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
Relevant means a decision, a status flip, a reversal, a new section, a changed scope. Not a typo fix. If nothing became untrue, leave it and say so.
|
|
33
33
|
|
|
34
34
|
---
|
|
35
|
-
Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words on what changed
|
|
35
|
+
`Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words on what changed>`
|
|
@@ -8,9 +8,9 @@ A decision that reverses an earlier one names the earlier line and says "superse
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
-
|
|
11
|
+
- `<YYYY-MM-DD> · <decision> · why: <reason> · where: <session slug>`
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
<!-- synthesis watermark: read through <YYYY-MM-DD> (a sweep that promotes decisions to memory updates this line) -->
|
|
15
15
|
|
|
16
|
-
Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words
|
|
16
|
+
`Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words>`
|
package/templates/session-log.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Session log ·
|
|
1
|
+
# Session log · `<YYYY>-W<ww>`
|
|
2
2
|
|
|
3
3
|
*One note per ISO week. Each session appends a dated section below. Records are grouped by type so a later sweep can promote the durable ones to memory. Nothing here is a rule until it is promoted.*
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Record types: `decision` · `correction` (the AI was wrong, how, what it should
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## `<YYYY-MM-DD>` - `<three-to-six-word slug>`
|
|
10
10
|
|
|
11
11
|
**What happened:** one or two lines.
|
|
12
12
|
|
|
@@ -19,4 +19,4 @@ Record types: `decision` · `correction` (the AI was wrong, how, what it should
|
|
|
19
19
|
|
|
20
20
|
<!-- next session appends above this line, newest at the top of the week -->
|
|
21
21
|
|
|
22
|
-
Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words
|
|
22
|
+
`Last edited by: <ai> <model> <YYYY-MM-DD> · <ten words>`
|