agent-personalizer 0.5.0 → 0.5.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.
package/README.md CHANGED
@@ -90,7 +90,7 @@ ChatGPT has two custom-instruction boxes with a character budget, so its render
90
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.
91
91
  3. Paste the `USER.md` body into the "custom instructions" box of any chat app that has one.
92
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.
93
+ Level 1 creates no notes folder, so none of the files it writes names one. The home file points at `AGENT_ONBOARDING.md` for where the AI may write; `AGENT_ONBOARDING.md` and `USER.md` say outright that the folder is not on disk yet and that the AI is to propose writes rather than create it. Level 2 creates the folder and repoints all three at it in the same run.
94
94
 
95
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.
96
96
 
@@ -150,7 +150,7 @@ examples/ one invented user, end to end
150
150
  docs/ tiers.md, companions.md, paste-guide.md
151
151
  CHANGELOG.md keyed on audit rounds
152
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
153
- test/ run.sh: 88 checks, exact exit codes, adversarial fixtures (symlinks, traversal, malformed markers, CRLF, partial renders)
153
+ test/ run.sh: 89 checks, exact exit codes, adversarial fixtures (symlinks, traversal, malformed markers, CRLF, partial renders)
154
154
  ```
155
155
 
156
156
  ## Changelog
@@ -262,10 +262,19 @@ async function main() {
262
262
  // pointers. NOTES_ONE_LINE is also what the level-2 upgrade looks for, byte for byte.
263
263
  const NOTES_ONE_LINE = (why) => `- Notes: see \`AGENT_ONBOARDING.md\` § Where you may write (${why})`;
264
264
  const NOTES_LATER = `no local notes folder at level 1; level 2 creates \`${base}/\``;
265
+ // Is the folder every notes pointer names going to be there to read? The README is the file the AI
266
+ // is told to read before it writes, and the level-2 scaffold creates it with the folder. The LEVEL
267
+ // alone is a proxy that is wrong in both directions: a level-1 install can land beside a notes
268
+ // folder that already exists, and a re-run at a lower level does not delete what a higher one made
269
+ // (round 1, findings 4 and 5). One boolean drives the home-file collapse and both rendered files,
270
+ // so they can never disagree about the same folder.
271
+ const scaffoldExists = (() => { try { return fs.statSync(path.join(root, base, 'README.md')).isFile(); } catch (_) { return false; } })();
272
+ const willScaffold = level >= 2 && kind !== 'cloud'; // this run's own scaffold, written further down
273
+ const notesScaffolded = kind !== 'cloud' && (scaffoldExists || willScaffold);
265
274
  const notesWhy = kind === 'cloud' ? 'reached through its connector, no local files'
266
- : level < 2 ? NOTES_LATER
275
+ : !notesScaffolded ? NOTES_LATER
267
276
  : kind !== 'disk' ? 'local fallback folder `notes/`'
268
- : null; // disk, level 2+: the four paths, retargeted at notes_path
277
+ : null; // disk, scaffold present: the four paths, retargeted at notes_path
269
278
  const home = (name) => {
270
279
  let t = fs.readFileSync(path.join(PKG, 'templates', name), 'utf8');
271
280
  if (level < 3) {
@@ -323,13 +332,25 @@ async function main() {
323
332
  // changed answer that the kept file still carries the old value of is named as a conflict.
324
333
  const user = probe(root, 'USER.md');
325
334
  let userAction = 'create';
335
+ let staleNotesInUser = false;
326
336
  const changedKeys = prevAnswers ? Object.keys(answers).filter(k => JSON.stringify(answers[k]) !== JSON.stringify(prevAnswers[k])) : [];
327
337
  if (user.exists) {
328
338
  if (!fs.lstatSync(user.full).isFile()) die('USER.md exists and is not a regular file');
339
+ const current = fs.readFileSync(user.full, 'utf8');
340
+ // Two candidate renders per answer set, one saying the notes folder is there and one saying it is
341
+ // not (#25). A match against EITHER means the file is still exactly what this installer wrote,
342
+ // so regenerating loses nothing; anything else is yours and is kept.
343
+ const untouched = (ans) => [true, false].some(ns => current === onboarding.renderUser(ans, { notesScaffolded: ns }));
329
344
  if (changedKeys.length) {
330
- const current = fs.readFileSync(user.full, 'utf8');
331
- userAction = current === onboarding.renderUser(prevAnswers) ? 'regenerate' : 'conflict';
345
+ userAction = untouched(prevAnswers) ? 'regenerate' : 'conflict';
346
+ } else if (notesScaffolded && current === onboarding.renderUser(answers, { notesScaffolded: false })) {
347
+ // Same answers, but the file says the folder is absent and it is not (this run created it, or
348
+ // it was already there). The real paths go back, and only on a byte-for-byte match.
349
+ userAction = 'relevel';
332
350
  } else userAction = 'keep';
351
+ // A kept file that does not name the folder README while the folder is there is stale, however it
352
+ // was worded: keying the notice on one sentence let an edit to that sentence silence it (finding 6).
353
+ if (userAction === 'keep' && notesScaffolded && !current.includes(`\`${base}/README.md\``)) staleNotesInUser = true;
333
354
  }
334
355
 
335
356
  // Upgrade from a lower level. Two repairs, each matched byte for byte against a line THIS installer
@@ -369,13 +390,17 @@ async function main() {
369
390
 
370
391
  // ---- WRITE ----
371
392
  for (const u of upgrades) { fs.writeFileSync(u.full, u.text); console.log(`update ${u.name} (${u.why.join('; ')})`); }
372
- if (userAction === 'create') { fs.writeFileSync(user.full, onboarding.renderUser(answers), { flag: 'wx' }); console.log('wrote USER.md (from your answers)'); }
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(', ')})`); }
393
+ if (userAction === 'create') { fs.writeFileSync(user.full, onboarding.renderUser(answers, { notesScaffolded }), { flag: 'wx' }); console.log('wrote USER.md (from your answers)'); }
394
+ else if (userAction === 'regenerate') { fs.writeFileSync(user.full, onboarding.renderUser(answers, { notesScaffolded })); console.log(`update USER.md (regenerated: it matched your previous answers byte for byte; changed: ${changedKeys.join(', ')})`); }
395
+ else if (userAction === 'relevel') { fs.writeFileSync(user.full, onboarding.renderUser(answers, { notesScaffolded })); console.log(`update USER.md (notes pointers now name ${base}/, which is there; it matched the render that said it was not, byte for byte)`); }
374
396
  else if (userAction === 'conflict') {
375
397
  console.log(`kept USER.md (you edited it, so it was not regenerated)`);
376
398
  console.log(` ANSWERS CHANGED: ${changedKeys.join(', ')}. USER.md still carries the old value(s) and the rendered profile sections come from USER.md.`);
377
399
  console.log(` Fix by hand, or delete USER.md and re-run to regenerate it from the new answers. AGENT_ONBOARDING.md already carries the new answers.`);
378
- } else console.log('kept USER.md (exists)');
400
+ } else {
401
+ console.log('kept USER.md (exists)');
402
+ if (staleNotesInUser) console.log(` NOTE: you edited USER.md while it still said there is no local notes folder. ${base}/ exists now. Fix the two "Where things live" lines by hand, or delete USER.md and re-run.`);
403
+ }
379
404
  for (const p of plan) {
380
405
  if (p.src) copyIfAbsent(p.src, root, p.rel);
381
406
  else {
@@ -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.5.0/docs/companions.md.
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.1/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.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.
3
+ Tier 3 from the tiers doc (https://github.com/aunysillyme/agent-personalizer/blob/v0.5.1/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.5.0",
3
+ "version": "0.5.1",
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",
@@ -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.5.0';
20
+ const VERSION = '0.5.1';
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
@@ -47,6 +47,29 @@ const kindOf = (a) => TOOL[a.notes_tool].kind;
47
47
  /* the folder on disk that scaffolds and home-file pointers use: the user's path for a disk tool,
48
48
  the fixed fallback for everything else (cloud tools get no folder named after a workspace) */
49
49
  const baseFor = (a) => kindOf(a) === 'disk' ? a.notes_path : FALLBACK;
50
+ /* Is the local notes folder the rendered instructions name NOT there? Every non-cloud tool gets one
51
+ (a disk tool's own path, a read-only or unknown tool's fallback) and the level-2 scaffold is what
52
+ creates it, so below level 2 nothing may name a path inside it: the first session would be told to
53
+ read and write into a folder the installer never created. #19 fixed that for the home files, which
54
+ the installer collapses to one line; #25 was the same bug in the two files rendered from here,
55
+ which that one line points AT.
56
+
57
+ The LEVEL is only a proxy, and it is wrong in both directions: a hand-written config carries no
58
+ level, a level-1 install can land in a folder that already has a notes folder, and a re-run at a
59
+ lower level does not remove the folder a higher one created. So `opts.notesScaffolded` (the
60
+ caller's own look at the disk, which is the ground truth) wins whenever the caller passes it, and
61
+ the level is the fallback for a caller that has no root to look in. Round 1, findings 3 to 5.
62
+
63
+ This file is copied into level-3 installs, so the look at the disk stays in the CALLER: these two
64
+ renders are pure functions of the answers plus this one boolean. */
65
+ function notesPending(a, opts) {
66
+ if (kindOf(a) === 'cloud') return false; // no local folder at any level
67
+ if (opts && typeof opts.notesScaffolded === 'boolean') return !opts.notesScaffolded;
68
+ return (opts && Number.isInteger(opts.level) ? opts.level : 2) < 2;
69
+ }
70
+ /* the phrase a pending USER.md carries where the folder rules would be */
71
+ const NOTES_PENDING_MARK = 'no local notes folder yet, so no folder rules yet';
72
+ const notesLater = (base) => `\`--level 2\` creates \`${base}/\``;
50
73
 
51
74
  const QUESTIONS = [
52
75
  { id: 'name', ask: 'What should the AI call you?', type: 'text', default: 'the user' },
@@ -178,7 +201,8 @@ const esc = (s) => String(s).replace(/`/g, "'");
178
201
  character as the character itself. */
179
202
  const md = (s) => String(s).replace(/[`~<>#*_\[\]|\\]/g, (c) => '\\' + c).replace(/^([-+]|\d+[.)])(?=\s|$)/, (m) => '\\' + m);
180
203
 
181
- function renderUser(a) {
204
+ function renderUser(a, opts) {
205
+ const pending = notesPending(a, opts);
182
206
  return `# USER.md
183
207
 
184
208
  *Who I am, how to talk to me, how firmly I mean things, how I want output shaped. Every AI reads this first. Generated from my onboarding answers; edit freely, it is mine.*
@@ -221,9 +245,9 @@ Two guards. First: loosen only descriptive claims about me. Never loosen a state
221
245
 
222
246
  ## Where things live
223
247
 
224
- - **My notes:** ${md(toolFor(a).name)}, ${toolFor(a).kind === 'disk' ? `\`${esc(a.notes_path)}/\`` : `"${md(a.notes_path)}"`}${toolFor(a).kind === 'readonly' ? ' (read-only for the AI)' : toolFor(a).kind === 'other' ? ' (the AI asks before its first write there)' : ''}
248
+ - **My notes:** ${md(toolFor(a).name)}, ${toolFor(a).kind === 'disk' ? `\`${esc(a.notes_path)}/\`` : `"${md(a.notes_path)}"`}${toolFor(a).kind === 'readonly' ? ' (read-only for the AI)' : toolFor(a).kind === 'other' ? ' (the AI asks before its first write there)' : ''}${pending && toolFor(a).kind === 'disk' ? ` (not on disk yet; ${notesLater(esc(a.notes_path))})` : ''}
225
249
  - **My task tracker:** ${md(a.tracker)}
226
- - **Rules the AI must read before writing anything to my notes:** ${toolFor(a).kind === 'disk' ? `\`${esc(a.notes_path)}/README.md\`` : toolFor(a).kind === 'cloud' ? `the index ${toolFor(a).unit || 'page'} of "${md(a.notes_path)}", and \`AGENT_ONBOARDING.md\` § Where you may write` : `\`${FALLBACK}/README.md\` (the local fallback folder the AI writes to), and \`AGENT_ONBOARDING.md\` § Where you may write`}
250
+ - **Rules the AI must read before writing anything to my notes:** ${pending ? `\`AGENT_ONBOARDING.md\` § Where you may write (${NOTES_PENDING_MARK}; ${notesLater(esc(baseFor(a)))} and its README)` : toolFor(a).kind === 'disk' ? `\`${esc(a.notes_path)}/README.md\`` : toolFor(a).kind === 'cloud' ? `the index ${toolFor(a).unit || 'page'} of "${md(a.notes_path)}", and \`AGENT_ONBOARDING.md\` § Where you may write` : `\`${FALLBACK}/README.md\` (the local fallback folder the AI writes to), and \`AGENT_ONBOARDING.md\` § Where you may write`}
227
251
  `;
228
252
  }
229
253
 
@@ -232,16 +256,38 @@ Two guards. First: loosen only descriptive claims about me. Never loosen a state
232
256
  conservative posture. p = location escaped for a code span, q = location escaped for prose. */
233
257
 
234
258
 
235
- function renderOnboarding(a) {
259
+ function renderOnboarding(a, opts) {
236
260
  const tool = toolFor(a);
237
261
  const disk = tool.kind === 'disk';
262
+ const pending = notesPending(a, opts); // the local folder is intended but level 2 has not created it
238
263
  const base = esc(baseFor(a)); // where filesystem writes go, if any
239
264
  const unit = tool.unit || 'page';
240
265
  const naming = { 'kebab-case': 'kebab-case: `my-note-title.md`', 'snake_case': 'snake_case: `my_note_title.md`', 'any': 'no naming rule; match the folder you are writing into' }[a.file_naming];
241
266
  const askList = a.always_ask.map(v => `- **${v}**: ${label(Q.always_ask, v)}`).join('\n') || '- nothing declared; use your judgement and say what you did';
242
267
 
243
268
  let writeSection;
244
- if (disk) {
269
+ if (pending) {
270
+ // Level 1 writes four files and no folders, so every path under base/ is a dead pointer until a
271
+ // level-2 run creates it. Two things stay true regardless: the notes TOOL and its location exist
272
+ // already for a read-only or unknown tool (only the local fallback folder is missing, so do not
273
+ // tell them their own notebook is coming at level 2), and the write policy they chose is not
274
+ // dropped, only deferred to "once it exists".
275
+ const laterLine = {
276
+ 'notes-freely': `anywhere under \`${base}/\`, under that folder's rules, and nowhere else unasked`,
277
+ 'logs-and-inbox-only': `only the session log (\`${base}/sessions/\`), the decisions log (\`${base}/decisions.md\`) and the inbox (\`${base}/inbox/\`)`,
278
+ 'ask-before-every-write': 'ask before every write, every time, showing what you would write and where',
279
+ }[a.write_policy];
280
+ const whereLine = disk
281
+ ? `- **Notes will live in ${md(tool.name)}:** ${tool.reach}, once that folder exists.`
282
+ : `- **Notes live in ${md(tool.name)}:** reach them as ${tool.reach}. ${tool.posture}`;
283
+ const absentLine = disk
284
+ ? `- **That folder is not on disk yet, so nothing under \`${base}/\` exists to read or write.**`
285
+ : `- **The local fallback folder \`${base}/\` that your writes would go to does not exist yet.**`;
286
+ writeSection = `${whereLine}
287
+ ${absentLine} This is a level-1 install: four profile files, no folders. ${notesLater(base)} with its README, session log, decisions log and inbox.
288
+ - **So do not write files there, and do not create that folder yourself.** Propose the write instead: say what would go in it and where it would live, and let them run the level-2 install (or tell you to make the folder).
289
+ - **Once it exists**, the policy they chose applies: you may write ${laterLine}. Every folder you write into has a README, and any write, edit or delete means that README is corrected in the same pass. A stale index is worse than none, because the next agent believes it.`;
290
+ } else if (disk) {
245
291
  const writeLine = {
246
292
  'notes-freely': `You may create and edit files anywhere under \`${base}/\`, under that folder's rules. Nowhere else without being asked.`,
247
293
  'logs-and-inbox-only': `You may write only to the session log (\`${base}/sessions/\`), the decisions log (\`${base}/decisions.md\`) and the inbox (\`${base}/inbox/\`). Anything else: propose it, do not write it.`,
@@ -302,7 +348,7 @@ ${a.work ? `- **What they do:** ${md(a.work)}\n` : ''}${a.focus ? `- **Current f
302
348
  ### Read this first, in order
303
349
 
304
350
  ${bullets(a.read_first.map(md), 'USER.md')}
305
- - ${tool.kind === 'cloud' ? `The index ${unit} of "${md(a.notes_path)}", before writing there.` : `\`${base}/README.md\`, the rules of the folder you may write into, before writing there.`}
351
+ - ${pending ? `Nothing else yet: there is no notes folder to read, and no folder README (${notesLater(base)} and its README). See § Where you may write below.` : tool.kind === 'cloud' ? `The index ${unit} of "${md(a.notes_path)}", before writing there.` : `\`${base}/README.md\`, the rules of the folder you may write into, before writing there.`}
306
352
  ${a.tracker !== 'none' ? `- The task tracker (${md(a.tracker)}): what is open and what is already decided, before proposing work.\n` : ''}
307
353
  ### Where you may write
308
354
 
@@ -337,8 +383,26 @@ const WRITE_POLICY = {
337
383
  'logs-and-inbox-only': 'only the session log, the decisions log and the inbox; propose anything else, do not write it',
338
384
  'ask-before-every-write': 'ASK BEFORE EVERY WRITE, every time; show what you would write and where',
339
385
  };
340
- function writesLine(a) {
386
+ /* The writes line for a folder that is not there yet. It carries BOTH halves in one clause per
387
+ policy: do not create anything unasked (the operative rule while the folder is absent) and the
388
+ policy that applies once it exists. ask-before-every-write keeps its full text, including "show
389
+ what you would write and where": that clause IS the consent, and someone who pasted the two
390
+ ChatGPT boxes and nothing else has no other copy of it (round 1, finding 1). Every line here is
391
+ shorter than the non-pending line it replaces, because the ChatGPT boxes are plain text on a
392
+ ~1500-character budget with about two characters of slack on this repo's own fixture, and the
393
+ harness installs all three policies at level 1 and refuses an over-budget box. */
394
+ const WRITE_POLICY_PENDING = {
395
+ 'notes-freely': 'Create nothing unasked; once it exists, anywhere under it, under its rules, nowhere else',
396
+ 'logs-and-inbox-only': 'Create nothing unasked; once it exists, only the session log, decisions log and inbox',
397
+ 'ask-before-every-write': WRITE_POLICY['ask-before-every-write'],
398
+ };
399
+ function writesLine(a, opts) {
341
400
  const t = toolFor(a);
401
+ // No backticks, and the policy in its SHORT form: this line also goes into the ChatGPT boxes, which
402
+ // are plain text on a ~1500-character budget with almost no slack, so the pending line is kept no
403
+ // longer than the line it replaces. The strictest policy has to survive the trim, so the policy is
404
+ // named, not dropped; AGENT_ONBOARDING.md § Where you may write carries all of it in full.
405
+ if (notesPending(a, opts)) return `Writes: no notes folder yet (level 2 creates ${esc(baseFor(a))}/). ${WRITE_POLICY_PENDING[a.write_policy]}.`;
342
406
  const where = t.kind === 'cloud' ? `${md(t.name)} "${md(a.notes_path)}" through its connector, no filesystem writes`
343
407
  : t.kind === 'readonly' ? `${md(t.name)} is read-only for you; the local fallback folder is ${esc(FALLBACK)}/`
344
408
  : t.kind === 'other' ? `${md(t.name)} is unknown here: ask before the first write there; local fallback folder ${esc(FALLBACK)}/ meanwhile`
@@ -352,7 +416,7 @@ function contractBlock(a, opts) {
352
416
  '',
353
417
  `Always ask before: ${a.always_ask.join(', ') || 'nothing declared'}.`,
354
418
  a.off_limits.length ? `Off limits in any output: ${a.off_limits.map(md).join(', ')}.` : null,
355
- writesLine(a),
419
+ writesLine(a, opts),
356
420
  files ? `Read first: ${a.read_first.map(md).join(' → ')}.` : null,
357
421
  `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)}.`,
358
422
  `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).' : ''}`,
@@ -372,4 +436,4 @@ function compactProfile(a) {
372
436
  ].filter(Boolean).join('\n');
373
437
  }
374
438
 
375
- module.exports = { QUESTIONS, QUICK, PINNED, TOOL, VERSION, DOCS, FALLBACK, asks, defaults, sparse, validate, parseAnswer, renderUser, renderOnboarding, contractBlock, compactProfile, kindOf, baseFor };
439
+ module.exports = { QUESTIONS, QUICK, PINNED, TOOL, VERSION, DOCS, FALLBACK, NOTES_PENDING_MARK, notesPending, asks, defaults, sparse, validate, parseAnswer, renderUser, renderOnboarding, contractBlock, compactProfile, kindOf, baseFor };
package/render/render.cjs CHANGED
@@ -302,11 +302,22 @@ function rulesFor(rules, key, answers) {
302
302
  && (!r.meta.requires || a[r.meta.requires.answer] === r.meta.requires.value));
303
303
  }
304
304
  const answersOf = (cfg) => (cfg && cfg.onboarding) ? cfg.onboarding : null;
305
-
306
- function renderTarget(key, target, profile, rules, cfg) {
305
+ /* Do the notes pointers in a rendered file name something that is there? The README is the file the
306
+ AI is told to read before it writes, and the level-2 scaffold creates it with the folder, so its
307
+ presence is the sharpest one-stat answer. The LEVEL is not: a hand-written config carries none, a
308
+ level-1 install can land beside an existing notes folder, and a re-run at a lower level does not
309
+ delete what a higher one made (round 1, findings 3 to 5). Cloud answers have no local folder at
310
+ all, and notesPending() short-circuits on that before this is consulted. */
311
+ const notesScaffolded = (root, answers) => {
312
+ if (!answers) return true;
313
+ try { return fs.statSync(path.join(root, onboarding.baseFor(answers), 'README.md')).isFile(); }
314
+ catch (_) { return false; }
315
+ };
316
+
317
+ function renderTarget(key, target, profile, rules, cfg, root) {
307
318
  if (target.source === 'onboarding') {
308
319
  if (!cfg || !cfg.onboarding) die(`target "${key}": no onboarding answers in .agent-personalizer.json. Run the installer (it asks), or pass --answers <file>`);
309
- return onboarding.renderOnboarding(cfg.onboarding);
320
+ return onboarding.renderOnboarding(cfg.onboarding, { notesScaffolded: notesScaffolded(root, cfg.onboarding) });
310
321
  }
311
322
  const answers = answersOf(cfg);
312
323
  const lines = [`## ${target.header}`, '', '_Generated by agent-personalizer from `USER.md`, `rules/` and your onboarding answers. Edit those, then re-render. Do not edit between the markers._', ''];
@@ -322,7 +333,7 @@ function renderTarget(key, target, profile, rules, cfg) {
322
333
  return parts.join('\n\n');
323
334
  }).join('\n\n');
324
335
  const box1 = answers ? onboarding.compactProfile(answers) : (profile || '(no USER.md found)');
325
- const box2 = answers ? [onboarding.contractBlock(answers, { files: false }).split('\n').slice(2).join('\n'), ruleText].filter(Boolean).join('\n\n') : ruleText;
336
+ const box2 = answers ? [onboarding.contractBlock(answers, { files: false, notesScaffolded: notesScaffolded(root, answers) }).split('\n').slice(2).join('\n'), ruleText].filter(Boolean).join('\n\n') : ruleText;
326
337
  const over = [];
327
338
  const warn = (label, text) => {
328
339
  if (text.length > target.limit) { over.push(label); return `\n> **${label} is OVER BUDGET: ${text.length} characters, the box allows about ${target.limit}.** Nothing was cut for you. Trim from the bottom up: the box is ordered by consequence (restrictions first, style last), so the last lines are the cheapest to lose.`; }
@@ -415,7 +426,7 @@ function main() {
415
426
  const cfgC = readConfig(root);
416
427
  const inject = rulesFor(rules, key, answersOf(cfgC)).filter(r => r.meta.inject === true);
417
428
  const out = [`[agent-personalizer] Session-start contract for ${key}. Injected in full at the start of every session so these rules are in context at the moment of decision.`, ''];
418
- if (cfgC && cfgC.onboarding && withPersonal) out.push(onboarding.contractBlock(cfgC.onboarding), '');
429
+ if (cfgC && cfgC.onboarding && withPersonal) out.push(onboarding.contractBlock(cfgC.onboarding, { notesScaffolded: notesScaffolded(root, cfgC.onboarding) }), '');
419
430
  for (const r of inject) {
420
431
  out.push(`## ${r.meta.title || r.meta.id || r.file}`, '', r.sections.universal);
421
432
  if (withPersonal && r.sections.personal) out.push('', r.sections.personal);
@@ -444,7 +455,7 @@ function main() {
444
455
  const target = TARGETS[key];
445
456
  if (!target) die(`unknown target "${key}" (known: ${KNOWN.join(', ')})`);
446
457
  const file = safeTargetPath(root, target.file, key);
447
- const block = renderTarget(key, target, profile, rules, cfg);
458
+ const block = renderTarget(key, target, profile, rules, cfg, root);
448
459
  let existing = null;
449
460
  if (fs.existsSync(file)) {
450
461
  existing = decodeUtf8(fs.readFileSync(file), target.file);