agent-personalizer 0.4.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/LICENSE +21 -0
- package/README.md +155 -0
- package/bin/agent-personalizer.js +388 -0
- package/check/forbidden.example.txt +31 -0
- package/check/gate.cjs +349 -0
- package/docs/companions.md +62 -0
- package/docs/paste-guide.md +66 -0
- package/docs/tiers.md +89 -0
- package/examples/freelance-illustrator/.agent-personalizer.json +52 -0
- package/examples/freelance-illustrator/AGENTS.md +180 -0
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +70 -0
- package/examples/freelance-illustrator/CLAUDE.md +184 -0
- package/examples/freelance-illustrator/USER.md +49 -0
- package/examples/freelance-illustrator/notes/README.md +39 -0
- package/examples/freelance-illustrator/notes/decisions.md +18 -0
- package/examples/freelance-illustrator/notes/inbox/2026-09-03-shot-list-for-six-prints.md +14 -0
- package/examples/freelance-illustrator/notes/inbox/README.md +19 -0
- package/examples/freelance-illustrator/notes/sessions/2026-W36.md +41 -0
- package/examples/freelance-illustrator/rules/00-read-the-profile-first.md +24 -0
- package/examples/freelance-illustrator/rules/10-evidence-before-assertion.md +24 -0
- package/examples/freelance-illustrator/rules/20-one-owner-per-rule.md +24 -0
- package/examples/freelance-illustrator/rules/30-folder-index-is-part-of-the-change.md +26 -0
- package/examples/freelance-illustrator/rules/40-sign-every-edit.md +25 -0
- package/examples/freelance-illustrator/rules/50-output-style.md +21 -0
- package/examples/freelance-illustrator/rules/60-act-or-ask.md +30 -0
- package/hooks/README.md +39 -0
- package/hooks/claude-code/session-start.sh +14 -0
- package/package.json +49 -0
- package/render/onboarding.cjs +360 -0
- package/render/render.cjs +559 -0
- package/render/targets.json +57 -0
- package/rules/00-read-the-profile-first.md +24 -0
- package/rules/10-evidence-before-assertion.md +24 -0
- package/rules/20-one-owner-per-rule.md +24 -0
- package/rules/30-folder-index-is-part-of-the-change.md +26 -0
- package/rules/40-sign-every-edit.md +25 -0
- package/rules/50-output-style.md +21 -0
- package/rules/60-act-or-ask.md +30 -0
- package/rules/README.md +55 -0
- package/templates/AGENTS.md +30 -0
- package/templates/CLAUDE.md +30 -0
- package/templates/FOLDER_README.md +35 -0
- package/templates/INBOX_README.md +19 -0
- package/templates/USER.md +52 -0
- package/templates/decisions-log.md +16 -0
- package/templates/session-log.md +22 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/*
|
|
3
|
+
onboarding.cjs: the agent-onboarding interview and its two renders.
|
|
4
|
+
|
|
5
|
+
The user answers a short set of questions (or accepts the defaults). From ONE answer set:
|
|
6
|
+
renderUser(answers) -> USER.md the human profile (who I am, how to talk to me)
|
|
7
|
+
renderOnboarding(answers) -> AGENT_ONBOARDING.md the agent-facing manual: how to talk, output
|
|
8
|
+
shape, what to read first, where to write,
|
|
9
|
+
how to save, what to ask before doing
|
|
10
|
+
contractBlock(answers) -> the short block a session-start hook injects
|
|
11
|
+
|
|
12
|
+
Defaults are the generalized shape of one working setup. Every default is a question the user
|
|
13
|
+
can answer differently; nothing here is imposed. No network, no environment, no secrets.
|
|
14
|
+
|
|
15
|
+
This file is COPIED into level-3 installs, so it must not require package.json or anything
|
|
16
|
+
else from the repo: VERSION is a literal, kept equal to package.json by the harness, and
|
|
17
|
+
DOCS points at the matching tag on GitHub so an installed copy never links to a file the
|
|
18
|
+
destination does not have.
|
|
19
|
+
*/
|
|
20
|
+
const VERSION = '0.4.0';
|
|
21
|
+
const DOCS = `https://github.com/aunysillyme/agent-personalizer/blob/v${VERSION}/docs`;
|
|
22
|
+
|
|
23
|
+
/* THE single source for notes tools. Add a tool here and nowhere else: the interview option, the
|
|
24
|
+
kind that drives the write section and the scaffold, and the prose all come from this table.
|
|
25
|
+
kind: disk = files the AI edits directly; cloud = reached through a connector, no filesystem;
|
|
26
|
+
readonly = no agent door today, so writes fall back to a local folder; other = named by the user,
|
|
27
|
+
conservative posture. p = location escaped for a code span, q = location escaped for prose. */
|
|
28
|
+
const TOOL = {
|
|
29
|
+
'obsidian': { kind: 'disk', label: 'an Obsidian vault (pairs with obsidian-tc, see the companions doc)', name: 'Obsidian',
|
|
30
|
+
reach: (p, q, n, tc) => tc
|
|
31
|
+
? `the vault at \`${p}/\`, through **obsidian-tc** (governed MCP: folder ACLs, human-in-the-loop confirmation for destructive tools, audit log) rather than raw filesystem access; see ${DOCS}/companions.md`
|
|
32
|
+
: `the vault at \`${p}/\` as plain files (obsidian-tc is not installed; ${DOCS}/companions.md explains what it would add: folder ACLs, human-in-the-loop confirmation, an audit log)`, posture: null },
|
|
33
|
+
'notion': { kind: 'cloud', label: 'Notion', name: 'Notion', unit: 'page', reach: (p, q) => `the workspace "${q}" through Notion's own MCP connector`, posture: 'Write only into the pages or databases named in this file. Propose a new top-level page; never create one unasked.' },
|
|
34
|
+
'google-docs': { kind: 'cloud', label: 'Google Docs / Drive', name: 'Google Docs', unit: 'doc', reach: (p, q) => `"${q}" through the Google Drive / Docs connector`, posture: 'Draft into a doc named for the topic. Never edit the existing text of a shared doc without being asked.' },
|
|
35
|
+
'apple-notes': { kind: 'cloud', label: 'Apple Notes', name: 'Apple Notes', unit: 'note', reach: (p, q) => `the "${q}" folder through a separately installed local Apple Notes MCP (not built into any AI app; the user installs and connects it)`, posture: 'Read, and create new notes. Never edit or delete an existing note.' },
|
|
36
|
+
'onenote': { kind: 'readonly', label: 'Microsoft OneNote', name: 'Microsoft OneNote', reach: (p, q) => `"${q}", read-only (no first-class agent door today)`, posture: 'Treat it as read-only. Write to the local fallback folder below and say what to paste back.' },
|
|
37
|
+
'evernote': { kind: 'readonly', label: 'Evernote', name: 'Evernote', reach: (p, q) => `"${q}", read-only (no first-class agent door today)`, posture: 'Treat it as read-only. Write to the local fallback folder below and say what to paste back.' },
|
|
38
|
+
'logseq': { kind: 'disk', label: 'Logseq', name: 'Logseq', reach: (p, q) => `the graph folder at \`${p}/\`, as plain files`, posture: null },
|
|
39
|
+
'folder': { kind: 'disk', label: 'a plain folder of markdown files', name: 'a folder of markdown files', reach: (p, q) => `\`${p}/\` on disk`, posture: null },
|
|
40
|
+
'other': { kind: 'other', label: 'something else (name it in the next answer)', name: null, reach: (p, q) => `"${q}"`, posture: 'Ask before the first write into it, and say which tool and location you mean. Until told otherwise, write only to the local fallback folder below.' },
|
|
41
|
+
};
|
|
42
|
+
/* name comes back RAW and is md-escaped exactly once at each prose render site */
|
|
43
|
+
const toolFor = (a) => { const t = TOOL[a.notes_tool]; return { kind: t.kind, unit: t.unit, posture: t.posture, name: t.name || a.notes_tool_name || 'an unnamed notes tool', reach: t.reach(esc(a.notes_path), md(a.notes_path), a.notes_tool_name || '', a.obsidian_tc === 'yes') }; };
|
|
44
|
+
const FALLBACK = 'notes';
|
|
45
|
+
/* kind without rendering anything (safe before validation completes) */
|
|
46
|
+
const kindOf = (a) => TOOL[a.notes_tool].kind;
|
|
47
|
+
/* the folder on disk that scaffolds and home-file pointers use: the user's path for a disk tool,
|
|
48
|
+
the fixed fallback for everything else (cloud tools get no folder named after a workspace) */
|
|
49
|
+
const baseFor = (a) => kindOf(a) === 'disk' ? a.notes_path : FALLBACK;
|
|
50
|
+
|
|
51
|
+
const QUESTIONS = [
|
|
52
|
+
{ id: 'name', ask: 'What should the AI call you?', type: 'text', default: 'the user' },
|
|
53
|
+
{ id: 'pronouns', ask: 'Your pronouns (leave blank to skip)', type: 'text', default: '' },
|
|
54
|
+
{ id: 'work', ask: 'What you do, in one line', type: 'text', default: '' },
|
|
55
|
+
{ id: 'focus', ask: 'Your current focus, one or two projects', type: 'text', default: '' },
|
|
56
|
+
{ id: 'tone', ask: 'How direct should the AI be?', type: 'choice', default: 'direct',
|
|
57
|
+
options: [['direct', 'direct answers, no hedging, say what you think'], ['balanced', 'direct but soften disagreement'], ['gentle', 'lead with what works before what does not']] },
|
|
58
|
+
{ id: 'length', ask: 'How long should replies be?', type: 'choice', default: 'short',
|
|
59
|
+
options: [['short', 'short by default, detail on request'], ['adaptive', 'as long as the question needs'], ['thorough', 'complete every time']] },
|
|
60
|
+
{ id: 'mistakes', ask: 'When the AI is wrong, how should it handle it?', type: 'choice', default: 'one-line',
|
|
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
|
+
{ 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']] },
|
|
64
|
+
{ id: 'lead_with', ask: 'What should a reply open with?', type: 'choice', default: 'verdict',
|
|
65
|
+
options: [['verdict', 'the answer or the verdict'], ['summary', 'a one-paragraph summary'], ['context', 'the context, then the answer']] },
|
|
66
|
+
{ id: 'structure', ask: 'How should replies be shaped?', type: 'choice', default: 'bullets',
|
|
67
|
+
options: [['bullets', 'lead-in line, then bullets, one item per line'], ['prose', 'short paragraphs'], ['tables-when-comparing', 'bullets by default, a table when comparing three or more things']] },
|
|
68
|
+
{ id: 'evidence', ask: 'Where should evidence for a claim go?', type: 'choice', default: 'inline',
|
|
69
|
+
options: [['inline', 'in the reply: paths, counts, dates'], ['linked', 'a link to where it lives'], ['none', 'not needed']] },
|
|
70
|
+
{ id: 'never', ask: 'Words, punctuation or habits the AI must never use (comma-separated, blank for none)', type: 'list', default: [] },
|
|
71
|
+
{ id: 'read_first', ask: 'Files the AI reads first, in order (comma-separated)', type: 'list', default: ['USER.md', 'AGENT_ONBOARDING.md'] },
|
|
72
|
+
{ id: 'notes_tool', ask: 'Where do your notes live?', type: 'choice', default: 'folder',
|
|
73
|
+
options: Object.entries(TOOL).map(([k, t]) => [k, t.label]) },
|
|
74
|
+
{ id: 'obsidian_tc', ask: 'If Obsidian: do you use obsidian-tc, the governed MCP?', type: 'choice', default: 'no',
|
|
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: 'If "other": the name of the tool (blank otherwise)', type: 'text', default: '' },
|
|
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
|
+
{ id: 'tracker', ask: 'Your task tracker, if the AI should read it ("none" to skip)', type: 'text', default: 'none' },
|
|
79
|
+
{ id: 'write_policy', ask: 'How freely may the AI write into your notes?', type: 'choice', default: 'notes-freely',
|
|
80
|
+
options: [['notes-freely', 'anywhere under the notes folder, under the folder rules'], ['logs-and-inbox-only', 'only the session log, decisions log and inbox'], ['ask-before-every-write', 'ask before every write']] },
|
|
81
|
+
{ id: 'file_naming', ask: 'File naming for anything the AI creates', type: 'choice', default: 'kebab-case',
|
|
82
|
+
options: [['kebab-case', 'my-note-title.md'], ['snake_case', 'my_note_title.md'], ['any', 'no rule']] },
|
|
83
|
+
{ id: 'signature', ask: 'Should every AI edit end with a signature line (who, model, date, what changed)?', type: 'choice', default: 'yes',
|
|
84
|
+
options: [['yes', 'one line, overwritten each edit'], ['no', 'no signature']] },
|
|
85
|
+
{ id: 'off_limits', ask: 'Folders or topics that never enter shared output (comma-separated, blank for none)', type: 'list', default: [] },
|
|
86
|
+
{ id: 'always_ask', ask: 'Actions the AI must always ask before (comma-separated from: delete, publish, send, spend, settings, standing-rules; blank for all)', type: 'multi',
|
|
87
|
+
default: ['delete', 'publish', 'send', 'spend', 'settings', 'standing-rules'],
|
|
88
|
+
options: [['delete', 'deleting or overwriting anything'], ['publish', 'publishing or posting anything public'], ['send', 'sending a message on your behalf'], ['spend', 'spending money'], ['settings', 'changing account or system settings'], ['standing-rules', 'creating a standing rule, schedule or automation']] },
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const IDS = new Set(QUESTIONS.map(q => q.id));
|
|
92
|
+
/* the questions --quick asks; every other answer takes its default */
|
|
93
|
+
const QUICK = ['name', 'tone', 'length', 'notes_tool', 'notes_path', 'write_policy', 'always_ask'];
|
|
94
|
+
/* only the answers that differ from the defaults: what the installer stores, so the config reads as
|
|
95
|
+
"what this person chose" and a future default applies to everyone who never chose otherwise */
|
|
96
|
+
/* PINNED answers are always stored, default or not: they govern what the AI may touch, so a future
|
|
97
|
+
change of a default must never move them under a person who chose the current value. */
|
|
98
|
+
const PINNED = ['write_policy', 'always_ask', 'off_limits', 'notes_tool', 'notes_path', 'signature'];
|
|
99
|
+
function sparse(a) { const d = defaults(), out = {}; for (const k of Object.keys(a)) if (PINNED.includes(k) || JSON.stringify(a[k]) !== JSON.stringify(d[k])) out[k] = a[k]; return out; }
|
|
100
|
+
|
|
101
|
+
function defaults() {
|
|
102
|
+
const a = {};
|
|
103
|
+
for (const q of QUESTIONS) a[q.id] = Array.isArray(q.default) ? [...q.default] : q.default;
|
|
104
|
+
return a;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Strict validation: unknown keys, wrong types and unknown choices are errors, never defaults.
|
|
108
|
+
Returns the completed answer set (missing keys take their default). */
|
|
109
|
+
const RESERVED = /<!--\s*agent-personalizer/i;
|
|
110
|
+
const okString = (v, max) => typeof v === 'string' && v.length <= max && !/[\r\n\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(v) && !RESERVED.test(v);
|
|
111
|
+
|
|
112
|
+
function validate(input) {
|
|
113
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new Error('answers must be an object');
|
|
114
|
+
for (const k of Object.keys(input)) if (!IDS.has(k)) throw new Error(`unknown answer "${k}" (known: ${[...IDS].join(', ')})`);
|
|
115
|
+
const out = defaults();
|
|
116
|
+
for (const q of QUESTIONS) {
|
|
117
|
+
if (!(q.id in input)) continue;
|
|
118
|
+
const v = input[q.id];
|
|
119
|
+
if (q.type === 'text') {
|
|
120
|
+
if (!okString(v, 400)) throw new Error(`"${q.id}" must be one line of plain text (up to 400 characters, no control characters, no render marker)`);
|
|
121
|
+
out[q.id] = v.trim();
|
|
122
|
+
} else if (q.type === 'choice') {
|
|
123
|
+
const allowed = q.options.map(o => o[0]);
|
|
124
|
+
if (!allowed.includes(v)) throw new Error(`"${q.id}" must be one of: ${allowed.join(', ')}`);
|
|
125
|
+
out[q.id] = v;
|
|
126
|
+
} else if (q.type === 'list') {
|
|
127
|
+
if (!Array.isArray(v) || v.length > 50 || v.some(s => !okString(s, 200))) throw new Error(`"${q.id}" must be a list of up to 50 short plain strings (no control characters, no render marker)`);
|
|
128
|
+
out[q.id] = v.map(s => s.trim()).filter(Boolean);
|
|
129
|
+
} else if (q.type === 'multi') {
|
|
130
|
+
const allowed = q.options.map(o => o[0]);
|
|
131
|
+
if (!Array.isArray(v) || v.some(s => !allowed.includes(s))) throw new Error(`"${q.id}" must be a list drawn from: ${allowed.join(', ')}`);
|
|
132
|
+
out[q.id] = allowed.filter(s => v.includes(s));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Cross-field checks. For a tool the AI reaches on disk, notes_path is a folder the installer
|
|
136
|
+
// creates and the home files point at, so it must be a plain relative path: no leading slash,
|
|
137
|
+
// no "..", no empty segment, no backslash, nothing but [A-Za-z0-9._ -] per segment.
|
|
138
|
+
if (kindOf(out) === 'disk' && !SAFE_REL.test(out.notes_path))
|
|
139
|
+
throw new Error(`"notes_path" for ${out.notes_tool} must be a relative folder path such as "notes" or "docs/vault" (letters, digits, space, . _ -, segments joined by /; no leading /, no ..)`);
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
const SAFE_REL = /^(?!\.\.?(?:\/|$))[A-Za-z0-9._ -]+(?:\/(?!\.\.?(?:\/|$))[A-Za-z0-9._ -]+)*$/;
|
|
143
|
+
|
|
144
|
+
/* Parse one typed interview answer (a string) for a question; '' means the default. */
|
|
145
|
+
function parseAnswer(q, raw) {
|
|
146
|
+
const s = String(raw).trim();
|
|
147
|
+
if (s === '') return Array.isArray(q.default) ? [...q.default] : q.default;
|
|
148
|
+
if (q.type === 'text') return s;
|
|
149
|
+
if (q.type === 'choice') return s;
|
|
150
|
+
return s.split(',').map(x => x.trim()).filter(Boolean);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const label = (q, v) => { const o = q.options && q.options.find(x => x[0] === v); return o ? o[1] : v; };
|
|
154
|
+
const Q = Object.fromEntries(QUESTIONS.map(q => [q.id, q]));
|
|
155
|
+
const bullets = (arr, empty) => arr.length ? arr.map(x => `- ${x}`).join('\n') : `- ${empty}`;
|
|
156
|
+
/* md(): for values placed INSIDE an inline-code span; a code span cannot carry structure, so only
|
|
157
|
+
the backtick that would close it needs neutralizing. */
|
|
158
|
+
const esc = (s) => String(s).replace(/`/g, "'");
|
|
159
|
+
/* md(): for values placed in prose or list items. Backslash-escapes every character that can open
|
|
160
|
+
Markdown structure or raw HTML (fences, headings, lists, quotes, tables, links, emphasis, comments),
|
|
161
|
+
so a value such as "~~~" or "<!--" or "# x" renders as literal text and cannot swallow or reshape
|
|
162
|
+
the trusted instructions around it. CommonMark renders a backslash-escaped ASCII punctuation
|
|
163
|
+
character as the character itself. */
|
|
164
|
+
const md = (s) => String(s).replace(/[`~<>#*_\[\]|\\]/g, (c) => '\\' + c).replace(/^([-+]|\d+[.)])(?=\s|$)/, (m) => '\\' + m);
|
|
165
|
+
|
|
166
|
+
function renderUser(a) {
|
|
167
|
+
return `# USER.md
|
|
168
|
+
|
|
169
|
+
*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.*
|
|
170
|
+
|
|
171
|
+
## Who I am
|
|
172
|
+
|
|
173
|
+
- **Name and pronouns:** ${md(a.name)}${a.pronouns ? `, ${md(a.pronouns)}` : ''}
|
|
174
|
+
- **What I do:** ${a.work ? md(a.work) : '(fill in)'}
|
|
175
|
+
- **Current focus:** ${a.focus ? md(a.focus) : '(fill in)'}
|
|
176
|
+
- **Off limits:** ${a.off_limits.length ? a.off_limits.map(md).join(', ') : 'nothing declared yet'}
|
|
177
|
+
|
|
178
|
+
## How to talk to me
|
|
179
|
+
|
|
180
|
+
- **Directness:** ${label(Q.tone, a.tone)}
|
|
181
|
+
- **Length:** ${label(Q.length, a.length)}
|
|
182
|
+
- **When you are wrong:** ${label(Q.mistakes, a.mistakes)}
|
|
183
|
+
- **When you are unsure:** ${label(Q.unsure, a.unsure)}
|
|
184
|
+
- **Never:** ${a.never.length ? a.never.map(md).join('; ') : 'nothing declared yet'}
|
|
185
|
+
|
|
186
|
+
## How firmly I mean things
|
|
187
|
+
|
|
188
|
+
I do not say everything at the same strength. Read the rung before you act, and when unsure, read it one rung LOOSER, never tighter. A loose read costs one correction. A tight read becomes a silent rule that misfires for months.
|
|
189
|
+
|
|
190
|
+
| Rung | What it is | How it sounds |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| **Gesture** | a word I reached for, not a definition. Act on the thing, quote the word as mine. | "kind of", "basically", "closest word", a made-up -y word |
|
|
193
|
+
| **Preference** | a default, never a gate. | "I like", "it's fine", "usually", "depends" |
|
|
194
|
+
| **Practice** | a technique I actually use, with conditions. | "I always", describing what I did and why |
|
|
195
|
+
| **Rule** | a gate. It blocks shipping. | "I have to", "never", "every time", "100% of the time" |
|
|
196
|
+
|
|
197
|
+
Two guards. First: loosen only descriptive claims about me. Never loosen a stated prohibition or a must. Second: any sentence you write of the shape "the user is / does / wants / always / never" is a claim about me. That is the moment to check the rung.
|
|
198
|
+
|
|
199
|
+
## How I want output shaped
|
|
200
|
+
|
|
201
|
+
- **Lead with:** ${label(Q.lead_with, a.lead_with)}
|
|
202
|
+
- **Structure:** ${label(Q.structure, a.structure)}
|
|
203
|
+
- **Evidence:** ${label(Q.evidence, a.evidence)}
|
|
204
|
+
- **Code:** fenced blocks only
|
|
205
|
+
- **Closing:** no recap, no offer of next steps
|
|
206
|
+
|
|
207
|
+
## Where things live
|
|
208
|
+
|
|
209
|
+
- **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)' : ''}
|
|
210
|
+
- **My task tracker:** ${md(a.tracker)}
|
|
211
|
+
- **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`}
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* kind: disk = files the AI edits directly; cloud = reached through a connector, no filesystem;
|
|
216
|
+
readonly = no agent door today, so writes fall back to a local folder; other = named by the user,
|
|
217
|
+
conservative posture. p = location escaped for a code span, q = location escaped for prose. */
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
function renderOnboarding(a) {
|
|
221
|
+
const tool = toolFor(a);
|
|
222
|
+
const disk = tool.kind === 'disk';
|
|
223
|
+
const base = esc(baseFor(a)); // where filesystem writes go, if any
|
|
224
|
+
const unit = tool.unit || 'page';
|
|
225
|
+
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];
|
|
226
|
+
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';
|
|
227
|
+
|
|
228
|
+
let writeSection;
|
|
229
|
+
if (disk) {
|
|
230
|
+
const writeLine = {
|
|
231
|
+
'notes-freely': `You may create and edit files anywhere under \`${base}/\`, under that folder's rules. Nowhere else without being asked.`,
|
|
232
|
+
'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.`,
|
|
233
|
+
'ask-before-every-write': 'Ask before every write, every time. Show what you would write and where.',
|
|
234
|
+
}[a.write_policy];
|
|
235
|
+
writeSection = `- **Notes live in ${md(tool.name)}:** reach them as ${tool.reach}.
|
|
236
|
+
- ${writeLine}
|
|
237
|
+
- **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.
|
|
238
|
+
- **Session log:** append a dated section to this week's note in \`${base}/sessions/\`. **Decisions:** one line each in \`${base}/decisions.md\`. **Inbox:** one file per item in \`${base}/inbox/\`; finished items are deleted, not marked done.`;
|
|
239
|
+
} else if (tool.kind === 'cloud') {
|
|
240
|
+
const writeLine = {
|
|
241
|
+
'notes-freely': `You may create and edit ${unit}s inside the location named above, under the posture above. Nowhere else without being asked.`,
|
|
242
|
+
'logs-and-inbox-only': `You may write only to a "Session log" ${unit} and a "Decisions" ${unit} inside the location named above. Anything else: propose it, do not write it.`,
|
|
243
|
+
'ask-before-every-write': 'Ask before every write, every time. Show what you would write and where.',
|
|
244
|
+
}[a.write_policy];
|
|
245
|
+
writeSection = `- **Notes live in ${md(tool.name)}:** reach them as ${tool.reach}. ${tool.posture}
|
|
246
|
+
- ${writeLine}
|
|
247
|
+
- **No filesystem writes.** Nothing about this person's notes is a local file; if a task needs a scratch file, say so and use the folder they give you.
|
|
248
|
+
- **Every section has an index ${unit}.** When you add or change a ${unit}, update the index ${unit} that lists it in the same pass. A stale index is worse than none, because the next agent believes it.
|
|
249
|
+
- **Session log:** a dated entry at the top of the "Session log" ${unit}. **Decisions:** one line each in the "Decisions" ${unit}. **Open items:** one block each in an "Inbox" ${unit}; finished items are removed, not marked done.`;
|
|
250
|
+
} else {
|
|
251
|
+
// readonly and other: the tool itself is read-only or unknown; writes fall back to a local folder
|
|
252
|
+
const writeLine = {
|
|
253
|
+
'notes-freely': `You may create and edit files anywhere under the local fallback folder \`${base}/\`, under that folder's rules.`,
|
|
254
|
+
'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/\`) in the local fallback folder. Anything else: propose it, do not write it.`,
|
|
255
|
+
'ask-before-every-write': 'Ask before every write, every time. Show what you would write and where.',
|
|
256
|
+
}[a.write_policy];
|
|
257
|
+
writeSection = `- **Notes live in ${md(tool.name)}:** reach them as ${tool.reach}. ${tool.posture}
|
|
258
|
+
- **Local fallback folder:** \`${base}/\`. ${writeLine}
|
|
259
|
+
- **Every folder you write into has a README.** 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.
|
|
260
|
+
- **Session log:** append a dated section to this week's note in \`${base}/sessions/\`. **Decisions:** one line each in \`${base}/decisions.md\`. **Inbox:** one file per item in \`${base}/inbox/\`; finished items are deleted, not marked done.`;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return `## Agent onboarding
|
|
264
|
+
|
|
265
|
+
_Generated by agent-personalizer from ${md(a.name)}'s own answers (stored in \`.agent-personalizer.json\`). Re-run the installer to change an answer. Read this after \`USER.md\`, before your first substantive reply._
|
|
266
|
+
|
|
267
|
+
### Who you are working with
|
|
268
|
+
|
|
269
|
+
- **Call them:** ${md(a.name)}${a.pronouns ? ` (${md(a.pronouns)})` : ''}
|
|
270
|
+
${a.work ? `- **What they do:** ${md(a.work)}\n` : ''}${a.focus ? `- **Current focus:** ${md(a.focus)}\n` : ''}- **How firmly they mean things:** read the rungs in \`USER.md\` § How firmly I mean things, and default one rung looser when unsure.
|
|
271
|
+
|
|
272
|
+
### How to talk
|
|
273
|
+
|
|
274
|
+
- **Directness:** ${label(Q.tone, a.tone)}.
|
|
275
|
+
- **Length:** ${label(Q.length, a.length)}.
|
|
276
|
+
- **When you are wrong:** ${label(Q.mistakes, a.mistakes)}.
|
|
277
|
+
- **When you are unsure:** ${label(Q.unsure, a.unsure)}.
|
|
278
|
+
- **Never:** ${a.never.length ? a.never.map(md).join('; ') : 'nothing declared'}.
|
|
279
|
+
|
|
280
|
+
### Output shape
|
|
281
|
+
|
|
282
|
+
- **Open with:** ${label(Q.lead_with, a.lead_with)}.
|
|
283
|
+
- **Structure:** ${label(Q.structure, a.structure)}.
|
|
284
|
+
- **Evidence:** ${label(Q.evidence, a.evidence)}.
|
|
285
|
+
- **Code:** fenced blocks only. **Closing:** no recap.
|
|
286
|
+
|
|
287
|
+
### Read this first, in order
|
|
288
|
+
|
|
289
|
+
${bullets(a.read_first.map(md), 'USER.md')}
|
|
290
|
+
- ${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.`}
|
|
291
|
+
${a.tracker !== 'none' ? `- The task tracker (${md(a.tracker)}): what is open and what is already decided, before proposing work.\n` : ''}
|
|
292
|
+
### Where you may write
|
|
293
|
+
|
|
294
|
+
${writeSection}
|
|
295
|
+
|
|
296
|
+
### How to save a file
|
|
297
|
+
|
|
298
|
+
- **Naming:** ${naming}.
|
|
299
|
+
- **One owner per fact.** Before writing, search for where the same thing already lives and edit there. Never restate a rule in a second file; link to the file that owns it.
|
|
300
|
+
- **Read before you append.** Never duplicate content that is already in the file.
|
|
301
|
+
${a.signature === 'yes' ? '- **Sign every edit.** Last line of the file: `Last edited by: <ai> <model> <YYYY-MM-DD> · <what changed, ten words or fewer>`. `Created by:` on a new file. One line, overwritten, never stacked.\n' : '- **No signature line** was requested; keep the file exactly as its folder expects.\n'}
|
|
302
|
+
### Before you act
|
|
303
|
+
|
|
304
|
+
Settle every FACT yourself: a read, a search, a probe, one tool call. Never hand back "worth confirming X" when one call settles X. A MANDATE is theirs. Always ask before:
|
|
305
|
+
|
|
306
|
+
${askList}
|
|
307
|
+
|
|
308
|
+
Never close a task on a claim. Verify against the artifact, then say what you checked. Then stop: no closing recap, no unrequested next steps.
|
|
309
|
+
|
|
310
|
+
### Off limits
|
|
311
|
+
|
|
312
|
+
${bullets(a.off_limits.map(x => `${md(x)}: never surfaced, quoted or summarized in any reply or deliverable, even if a search returns it`), 'nothing declared yet')}
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/* The short block a session-start hook injects (and the ChatGPT "respond" box carries).
|
|
317
|
+
Order is by consequence, so a token budget trims style before it trims a restriction:
|
|
318
|
+
always-ask, off-limits, write policy and location, then read order, then how to talk.
|
|
319
|
+
opts.files=false drops the lines that only make sense with file access (read order, paths). */
|
|
320
|
+
const WRITE_POLICY = {
|
|
321
|
+
'notes-freely': 'anywhere under the notes location named here, under its own rules, nowhere else unasked',
|
|
322
|
+
'logs-and-inbox-only': 'only the session log, the decisions log and the inbox; propose anything else, do not write it',
|
|
323
|
+
'ask-before-every-write': 'ASK BEFORE EVERY WRITE, every time; show what you would write and where',
|
|
324
|
+
};
|
|
325
|
+
function writesLine(a) {
|
|
326
|
+
const t = toolFor(a);
|
|
327
|
+
const where = t.kind === 'cloud' ? `${md(t.name)} "${md(a.notes_path)}" through its connector, no filesystem writes`
|
|
328
|
+
: t.kind === 'readonly' ? `${md(t.name)} is read-only for you; the local fallback folder is ${esc(FALLBACK)}/`
|
|
329
|
+
: t.kind === 'other' ? `${md(t.name)} is unknown here: ask before the first write there; local fallback folder ${esc(FALLBACK)}/ meanwhile`
|
|
330
|
+
: `${md(t.name)} at ${esc(a.notes_path)}/${a.notes_tool === 'obsidian' && a.obsidian_tc === 'yes' ? ', through obsidian-tc' : ''}`;
|
|
331
|
+
return `Writes: ${WRITE_POLICY[a.write_policy]}. Notes: ${where}.`;
|
|
332
|
+
}
|
|
333
|
+
function contractBlock(a, opts) {
|
|
334
|
+
const files = !opts || opts.files !== false;
|
|
335
|
+
return [
|
|
336
|
+
`## How to work with ${md(a.name)}`,
|
|
337
|
+
'',
|
|
338
|
+
`Always ask before: ${a.always_ask.join(', ') || 'nothing declared'}.`,
|
|
339
|
+
a.off_limits.length ? `Off limits in any output: ${a.off_limits.map(md).join(', ')}.` : null,
|
|
340
|
+
writesLine(a),
|
|
341
|
+
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: ${label(Q.unsure, a.unsure)}.`,
|
|
343
|
+
`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
|
+
a.never.length ? `Never: ${a.never.map(md).join('; ')}.` : null,
|
|
345
|
+
].filter(x => x !== null).join('\n');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/* ChatGPT box 1, "what to know about you": the profile without the firmness table, sized for a
|
|
349
|
+
custom-instructions box. The full USER.md stays the owning copy. */
|
|
350
|
+
function compactProfile(a) {
|
|
351
|
+
return [
|
|
352
|
+
`Call me ${md(a.name)}${a.pronouns ? ` (${md(a.pronouns)})` : ''}.`,
|
|
353
|
+
a.work ? `I do: ${md(a.work)}.` : null,
|
|
354
|
+
a.focus ? `Current focus: ${md(a.focus)}.` : null,
|
|
355
|
+
a.off_limits.length ? `Off limits, never surfaced in any reply: ${a.off_limits.map(md).join(', ')}.` : null,
|
|
356
|
+
'How firmly I mean things: "kind of" or a made-up word is a gesture; "I like" is a preference; "I always" is a practice; "never" or "I have to" is a rule. When unsure read one rung looser, never tighter; never loosen a stated prohibition.',
|
|
357
|
+
].filter(Boolean).join('\n');
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
module.exports = { QUESTIONS, QUICK, PINNED, TOOL, VERSION, DOCS, FALLBACK, defaults, sparse, validate, parseAnswer, renderUser, renderOnboarding, contractBlock, compactProfile, kindOf, baseFor };
|