agent-personalizer 0.5.1 → 0.6.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 +129 -96
- package/bin/agent-personalizer.js +52 -66
- package/bin/install-plan.cjs +69 -0
- package/bin/uninstall.cjs +248 -0
- package/docs/README.md +13 -0
- package/docs/guarantees.md +61 -0
- package/docs/install.md +140 -0
- package/docs/paste-guide.md +4 -4
- package/docs/tiers.md +10 -1
- package/examples/freelance-illustrator/AGENT_ONBOARDING.md +1 -1
- package/hooks/README.md +1 -1
- package/llms.txt +26 -0
- package/package.json +6 -5
- package/render/onboarding.cjs +1 -1
- package/render/render.cjs +57 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-personalizer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "One interview writes a profile and rule files every AI you use reads: CLAUDE.md, AGENTS.md, GEMINI.md and ChatGPT, kept in sync from one source.",
|
|
5
5
|
"author": "aunysillyme (https://github.com/aunysillyme)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:aunysillyme/agent-personalizer",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"agent-personalizer": "bin/agent-personalizer.js"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"render": "node render/render.cjs",
|
|
30
|
-
"check": "node render/render.cjs --check",
|
|
29
|
+
"render": "node render/render.cjs --dir examples/freelance-illustrator",
|
|
30
|
+
"check": "node render/render.cjs --dir examples/freelance-illustrator --check",
|
|
31
31
|
"gate": "node check/gate.cjs",
|
|
32
32
|
"test": "sh test/run.sh"
|
|
33
33
|
},
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"docs",
|
|
46
46
|
"examples",
|
|
47
47
|
"README.md",
|
|
48
|
-
"LICENSE"
|
|
48
|
+
"LICENSE",
|
|
49
|
+
"llms.txt"
|
|
49
50
|
]
|
|
50
51
|
}
|
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.6.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
|
package/render/render.cjs
CHANGED
|
@@ -57,6 +57,7 @@ const fs = require('fs');
|
|
|
57
57
|
const path = require('path');
|
|
58
58
|
const crypto = require('crypto');
|
|
59
59
|
const onboarding = require('./onboarding.cjs');
|
|
60
|
+
const sha256 = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
|
|
60
61
|
|
|
61
62
|
class Refusal extends Error {}
|
|
62
63
|
/* die(): exit 2 with the reason. When a caller (the installer's preflight) sets module.exports.DIE_THROWS,
|
|
@@ -220,12 +221,21 @@ function readConfig(root) {
|
|
|
220
221
|
if (new Set(cfg.targets).size !== cfg.targets.length) die('config: .agent-personalizer.json lists a target twice');
|
|
221
222
|
}
|
|
222
223
|
if ('level' in cfg && !(Number.isInteger(cfg.level) && cfg.level >= 1 && cfg.level <= 4)) die(`config: .agent-personalizer.json "level" must be an integer 1-4 (found ${JSON.stringify(cfg.level)})`);
|
|
224
|
+
validatePreservedTargets(cfg);
|
|
223
225
|
if ('onboarding' in cfg) {
|
|
224
226
|
try { cfg.onboarding = onboarding.validate(cfg.onboarding); } catch (e) { die(`config: onboarding answers: ${e.message}`); }
|
|
225
227
|
}
|
|
226
228
|
return cfg;
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
/* Ownership only, never content or hashes: these files existed before the installer touched them. */
|
|
232
|
+
function validatePreservedTargets(cfg) {
|
|
233
|
+
if (!('preservedTargets' in cfg)) return;
|
|
234
|
+
if (!Array.isArray(cfg.preservedTargets) || cfg.preservedTargets.some(t => !KNOWN.includes(t) || !Array.isArray(cfg.targets) || !cfg.targets.includes(t))
|
|
235
|
+
|| new Set(cfg.preservedTargets).size !== cfg.preservedTargets.length)
|
|
236
|
+
die('config: "preservedTargets" must be a unique list of installed target names');
|
|
237
|
+
}
|
|
238
|
+
|
|
229
239
|
function readSource(p, where) {
|
|
230
240
|
mustBe(p, 'file', where);
|
|
231
241
|
const text = decodeUtf8(fs.readFileSync(p), where).replace(/\r\n/g, '\n');
|
|
@@ -567,7 +577,29 @@ function main() {
|
|
|
567
577
|
for (const l of leftovers) console.error(` ${l}`);
|
|
568
578
|
process.exit(2);
|
|
569
579
|
}
|
|
580
|
+
recordInstalled(root, plan);
|
|
581
|
+
}
|
|
570
582
|
|
|
583
|
+
/* After a successful commit, record the exact bytes just written for each rendered target, so
|
|
584
|
+
--uninstall can recognize them later even after this package has moved on to a newer release.
|
|
585
|
+
For a target this run OWNS outright (not in the stored preservedTargets, i.e. not a file that
|
|
586
|
+
already existed before its target was first installed), the whole file is generated by this
|
|
587
|
+
tool, so the whole file's bytes are recorded. For a pre-existing home file, only the marker
|
|
588
|
+
block belongs to this tool, so only the block is hashed; the surrounding bytes are the user's
|
|
589
|
+
and are never fingerprinted. Read only; never runs during --check (nothing was written), and
|
|
590
|
+
a config predating this field, or none at all, is left exactly as it is. */
|
|
591
|
+
function recordInstalled(root, plan) {
|
|
592
|
+
const cfgPath = path.join(root, '.agent-personalizer.json');
|
|
593
|
+
let raw;
|
|
594
|
+
try { raw = JSON.parse(fs.readFileSync(cfgPath, 'utf8')); } catch (_) { return; }
|
|
595
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return;
|
|
596
|
+
const installed = (raw.installed && typeof raw.installed === 'object' && !Array.isArray(raw.installed)) ? { ...raw.installed } : {};
|
|
597
|
+
for (const p of plan) {
|
|
598
|
+
const preserved = !p.raw && Array.isArray(raw.preservedTargets) && raw.preservedTargets.includes(p.key);
|
|
599
|
+
installed[p.target.file] = sha256(Buffer.from(preserved ? p.block : p.output));
|
|
600
|
+
}
|
|
601
|
+
raw.installed = installed;
|
|
602
|
+
fs.writeFileSync(cfgPath, JSON.stringify(raw, null, 2) + '\n');
|
|
571
603
|
}
|
|
572
604
|
|
|
573
605
|
/* Everything the renderer would refuse about the SOURCES already present in a folder, checked without
|
|
@@ -578,5 +610,29 @@ function preflightSources(root) {
|
|
|
578
610
|
loadProfile(root);
|
|
579
611
|
}
|
|
580
612
|
|
|
581
|
-
|
|
613
|
+
/* Pure output planning for uninstall. Uses this package's renderer, never executable code from
|
|
614
|
+
the installed folder. The caller preflights all paths before asking for these bytes. */
|
|
615
|
+
function renderedContents(root, cfg) {
|
|
616
|
+
const rules = loadRules(root, null);
|
|
617
|
+
const profile = loadProfile(root);
|
|
618
|
+
renderTarget.boxes = null;
|
|
619
|
+
renderTarget.overBudget = [];
|
|
620
|
+
return cfg.targets.flatMap(key => {
|
|
621
|
+
const target = TARGETS[key];
|
|
622
|
+
if (!target) die(`unknown target "${key}"`);
|
|
623
|
+
safeTargetPath(root, target.file, key);
|
|
624
|
+
const block = renderTarget(key, target, profile, rules, cfg, root);
|
|
625
|
+
const out = [{ key, rel: target.file, block }];
|
|
626
|
+
if (target.boxes) for (const [which, rel] of Object.entries(target.boxFiles || {})) {
|
|
627
|
+
safeTargetPath(root, rel, `${key}:${which}`);
|
|
628
|
+
out.push({ key: `${key}:${which}`, rel, block: renderTarget.boxes[which], raw: true });
|
|
629
|
+
}
|
|
630
|
+
return out;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/* parseFrontmatter and parseSections are exported so another renderer can read the same rule-file
|
|
635
|
+
format with the same validation (for example one that renders CLAUDE.md sections and session-start
|
|
636
|
+
hook bodies from rules in this format). Set DIE_THROWS to get a Refusal instead of an exit. */
|
|
637
|
+
module.exports = { main, fenceMap, markerState, splice, between, preflightSources, parseFrontmatter, parseSections, readConfig, validatePreservedTargets, renderedContents, Refusal, DIE_THROWS: false };
|
|
582
638
|
if (require.main === module) main();
|