@justfortytwo/installer 0.1.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 +70 -0
- package/dist/commands/doctor.d.ts +36 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +126 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/enrich.d.ts +2 -0
- package/dist/commands/enrich.d.ts.map +1 -0
- package/dist/commands/enrich.js +26 -0
- package/dist/commands/enrich.js.map +1 -0
- package/dist/commands/forget.d.ts +2 -0
- package/dist/commands/forget.d.ts.map +1 -0
- package/dist/commands/forget.js +19 -0
- package/dist/commands/forget.js.map +1 -0
- package/dist/commands/init.d.ts +48 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +284 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/pair.d.ts +2 -0
- package/dist/commands/pair.d.ts.map +1 -0
- package/dist/commands/pair.js +26 -0
- package/dist/commands/pair.js.map +1 -0
- package/dist/commands/rollback.d.ts +2 -0
- package/dist/commands/rollback.d.ts.map +1 -0
- package/dist/commands/rollback.js +32 -0
- package/dist/commands/rollback.js.map +1 -0
- package/dist/commands/unbind.d.ts +16 -0
- package/dist/commands/unbind.d.ts.map +1 -0
- package/dist/commands/unbind.js +67 -0
- package/dist/commands/unbind.js.map +1 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +60 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/engine.d.ts +37 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +170 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/render.d.ts +78 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +113 -0
- package/dist/render.js.map +1 -0
- package/dist/state.d.ts +58 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +93 -0
- package/dist/state.js.map +1 -0
- package/package.json +79 -0
package/dist/state.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// state.ts — persistence for the two gitignored files under `.fortytwo/`.
|
|
2
|
+
//
|
|
3
|
+
// `.fortytwo/identity.json` — captured answers from `init` (agent name, owner
|
|
4
|
+
// details, channel bindings). This is the SOURCE OF TRUTH the persona
|
|
5
|
+
// renderer (render.ts) reads to materialize `context/*`. It is gitignored: it
|
|
6
|
+
// holds personal data and must never be versioned. Re-running `init` or
|
|
7
|
+
// `enrich` mutates it; `render` only READS it.
|
|
8
|
+
//
|
|
9
|
+
// `.fortytwo/state.json` — the installed version set (the resolved sibling
|
|
10
|
+
// package versions at the last successful `update`/`init`). This is the
|
|
11
|
+
// rollback ledger: before each update we snapshot the current set into
|
|
12
|
+
// `previous` so `rollback` can restore it. Distribution policy is
|
|
13
|
+
// "semver ranges, latest-compatible" — there is NO curated bill-of-materials,
|
|
14
|
+
// so the only record of "what worked" is what we capture HERE at install time.
|
|
15
|
+
//
|
|
16
|
+
// Both files live under the project root's `.fortytwo/` dir. Neither is created
|
|
17
|
+
// until `init` runs. Reads of a missing file return `null` (callers decide if
|
|
18
|
+
// that's fatal) rather than throwing — except where a command explicitly
|
|
19
|
+
// requires prior init (e.g. rollback needs state.json).
|
|
20
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, renameSync } from 'node:fs';
|
|
21
|
+
import { dirname, join, resolve } from 'node:path';
|
|
22
|
+
export const FORTYTWO_DIR = '.fortytwo';
|
|
23
|
+
export const IDENTITY_FILE = 'identity.json';
|
|
24
|
+
export const STATE_FILE = 'state.json';
|
|
25
|
+
function fortytwoPath(root, file) {
|
|
26
|
+
return join(resolve(root), FORTYTWO_DIR, file);
|
|
27
|
+
}
|
|
28
|
+
function readJson(path) {
|
|
29
|
+
// TODO(impl): return null when the file is absent; throw on malformed JSON
|
|
30
|
+
// (a corrupt state file is a real error the user must see, not silently eat).
|
|
31
|
+
if (!existsSync(path))
|
|
32
|
+
return null;
|
|
33
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
34
|
+
}
|
|
35
|
+
function writeJson(path, value) {
|
|
36
|
+
// Atomic write: a crash mid-write must not truncate the rollback ledger.
|
|
37
|
+
// Write to a temp file in the SAME dir (so rename stays on one filesystem),
|
|
38
|
+
// then rename — rename is atomic on POSIX.
|
|
39
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
40
|
+
const tmp = `${path}.tmp`;
|
|
41
|
+
writeFileSync(tmp, JSON.stringify(value, null, 2) + '\n', 'utf8');
|
|
42
|
+
renameSync(tmp, path);
|
|
43
|
+
}
|
|
44
|
+
// --- identity.json ---
|
|
45
|
+
export function readIdentity(root = process.cwd()) {
|
|
46
|
+
return readJson(fortytwoPath(root, IDENTITY_FILE));
|
|
47
|
+
}
|
|
48
|
+
export function writeIdentity(identity, root = process.cwd()) {
|
|
49
|
+
const existing = readIdentity(root);
|
|
50
|
+
const now = new Date().toISOString();
|
|
51
|
+
writeJson(fortytwoPath(root, IDENTITY_FILE), {
|
|
52
|
+
...identity,
|
|
53
|
+
createdAt: existing?.createdAt ?? identity.createdAt ?? now,
|
|
54
|
+
updatedAt: now,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// --- state.json ---
|
|
58
|
+
export function readState(root = process.cwd()) {
|
|
59
|
+
return readJson(fortytwoPath(root, STATE_FILE));
|
|
60
|
+
}
|
|
61
|
+
export function writeState(state, root = process.cwd()) {
|
|
62
|
+
writeJson(fortytwoPath(root, STATE_FILE), state);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Record a freshly-resolved version set, rotating the existing `current` into
|
|
66
|
+
* `previous` so `rollback` has a target. Called by `update` (and `init`).
|
|
67
|
+
* TODO(impl): on the very first install, `previous` stays null.
|
|
68
|
+
*/
|
|
69
|
+
function samePins(a, b) {
|
|
70
|
+
if (!a || a.length !== b.length)
|
|
71
|
+
return false;
|
|
72
|
+
return a.every((p, i) => {
|
|
73
|
+
const q = b[i];
|
|
74
|
+
return !!q && p.name === q.name && p.resolved === q.resolved && p.range === q.range;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export function recordVersionSet(next, root = process.cwd()) {
|
|
78
|
+
const prior = readState(root);
|
|
79
|
+
// Don't burn the rollback target by re-recording an identical set (e.g.
|
|
80
|
+
// re-running `update` with the same resolves) — keep `previous` pointing at the
|
|
81
|
+
// last set that actually DIFFERED. NOTE: rollback is single-step: `previous`
|
|
82
|
+
// holds only the immediately-prior set, not a full history.
|
|
83
|
+
const previous = prior ? (samePins(prior.current, next) ? prior.previous : prior.current) : null;
|
|
84
|
+
const state = {
|
|
85
|
+
stateVersion: 1,
|
|
86
|
+
current: next,
|
|
87
|
+
previous,
|
|
88
|
+
lastUpdatedAt: new Date().toISOString(),
|
|
89
|
+
};
|
|
90
|
+
writeState(state, root);
|
|
91
|
+
return state;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,0EAA0E;AAC1E,iDAAiD;AACjD,EAAE;AACF,+EAA+E;AAC/E,0EAA0E;AAC1E,yEAAyE;AACzE,oEAAoE;AACpE,gFAAgF;AAChF,iFAAiF;AACjF,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,yEAAyE;AACzE,wDAAwD;AAExD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,G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gF;IAChF,6EAA6E;IAC7E,4DAA4D;IAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjG,MAAM,KAAK,GAAiB;QAC1B,YAAY,EAAE,CAAC;QACf,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACxC,CAAC;IACF,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justfortytwo/installer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "All-in-one installer and lifecycle CLI for fortytwo — scaffolds the persona surface and provisions the npm engine (memory MCP, safety gate, channel adapters, embedder).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Enrico Deleo",
|
|
8
|
+
"url": "https://enricodeleo.com"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://forty-two.it",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/justfortytwo/installer.git"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"create-fortytwo": "dist/index.js",
|
|
21
|
+
"fortytwo": "dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"justfortytwo",
|
|
35
|
+
"fortytwo",
|
|
36
|
+
"claude-code",
|
|
37
|
+
"personal-assistant",
|
|
38
|
+
"cli",
|
|
39
|
+
"installer"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"typescript": "^5.4.0",
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"vitest": "^2.1.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@justfortytwo/memory": "^0.1.0",
|
|
49
|
+
"@justfortytwo/gate": "^0.1.0",
|
|
50
|
+
"@justfortytwo/persona": "^0.1.0",
|
|
51
|
+
"@justfortytwo/telegram": "^0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@justfortytwo/memory": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@justfortytwo/gate": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@justfortytwo/persona": {
|
|
61
|
+
"optional": true
|
|
62
|
+
},
|
|
63
|
+
"@justfortytwo/telegram": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"fortytwo": {
|
|
68
|
+
"comment": "Compatibility contract this CLI version was authored against. doctor cross-checks the *installed* sibling packages against these ranges; update/rollback record the resolved set into .fortytwo/state.json. TODO(wire): bump these as sibling contracts evolve.",
|
|
69
|
+
"compat": {
|
|
70
|
+
"@justfortytwo/memory": "^0.1.0",
|
|
71
|
+
"@justfortytwo/gate": "^0.1.0",
|
|
72
|
+
"@justfortytwo/persona": "^0.1.0",
|
|
73
|
+
"@justfortytwo/telegram": "^0.1.0"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|