create-agentic-workspace 0.17.3 → 0.17.4
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/package.json +3 -2
- package/permission-floor.json +1 -1
- package/retired-artifacts.json +22 -0
- package/src/floorReconcile.mjs +32 -2
- package/src/retiredArtifacts.mjs +193 -0
- package/src/update.mjs +71 -2
- package/src/upgradeReport.mjs +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-agentic-workspace",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
4
4
|
"description": "The pre-session bootstrap wizard for an Agentic Foundry workspace: declares (never grants) the permission floor, absorbs foundry-bootstrap.sh's out-of-session identity wiring, and scaffolds a seven-file schema-valid workspace. Zero dependencies, no lifecycle scripts, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"src",
|
|
25
25
|
"templates",
|
|
26
26
|
"permission-floor.json",
|
|
27
|
+
"retired-artifacts.json",
|
|
27
28
|
"package.json",
|
|
28
29
|
"README.md"
|
|
29
30
|
],
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"marketplace_name": "agentic-foundry",
|
|
35
36
|
"marketplace_repo": "lukasrepublic/agentic-foundry",
|
|
36
37
|
"plugin_name": "foundry",
|
|
37
|
-
"plugin_version": "1.17.
|
|
38
|
+
"plugin_version": "1.17.4",
|
|
38
39
|
"pins_researched": "2026-08-02"
|
|
39
40
|
}
|
|
40
41
|
}
|
package/permission-floor.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"plugin_root_glob": "~/.claude/plugins/cache/*/foundry/*",
|
|
4
|
-
"generated_for_plugin_version": "1.17.
|
|
4
|
+
"generated_for_plugin_version": "1.17.4",
|
|
5
5
|
"entries": [
|
|
6
6
|
{
|
|
7
7
|
"rule": "Bash(~/.claude/plugins/cache/*/foundry/*/scripts/foundry-acceptance-contract-validate.py:*)",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"_comment": "Workspace-side artifacts an earlier release wrote and no current release reads (hotfix-v1.17.4, ER #236). The updater reports every present entry as [stale] on every run and removes it only under --cleanup. `path` is relative to the workspace root; a single `*` is allowed in the LAST segment only (a basename glob). `kind` is `file` or `dir`; a path of the other kind, or a symlink, is reported and never removed. Nothing outside this list is ever touched; `.claude/skills`, `.claude/agents` and operator files are never candidates.",
|
|
4
|
+
"entries": [
|
|
5
|
+
{ "path": ".foundry/wiring-hash.pin", "kind": "file", "retired_in": "0.24.0", "reason": "the wiring-hash auto-heal and its pin were removed with the live-seam merge gate" },
|
|
6
|
+
{ "path": ".foundry/active-workflow.json", "kind": "file", "retired_in": "0.5.0", "reason": "the macro-workflow engine's active-workflow pointer; the engine was retired" },
|
|
7
|
+
{ "path": ".foundry/context-snapshots", "kind": "dir", "retired_in": "0.25.0", "reason": "the bespoke context-lifecycle snapshots; /foundry:context wraps native /compact and --resume now" },
|
|
8
|
+
{ "path": ".foundry/branch-protection-unenforced.json", "kind": "file", "retired_in": "0.24.0", "reason": "branch-protection-as-code's marker; Tier A is applied by hand and observed, never written from here" },
|
|
9
|
+
{ "path": ".foundry/hasher-ref", "kind": "file", "retired_in": "0.24.0", "reason": "the retired hasher reference; no current script reads it" },
|
|
10
|
+
{ "path": ".claude/settings.json.bak", "kind": "file", "retired_in": "1.7.0", "reason": "a backup an early settings migration left behind; the updater writes atomically and keeps no .bak" },
|
|
11
|
+
{ "path": ".claude/dispatch-queue", "kind": "dir", "retired_in": "1.10.0", "reason": "the retired dispatch-queue's old location; the multi-repo worktree manifest lives under .foundry/dispatch-queue" },
|
|
12
|
+
{ "path": ".claude/dispatcher-mode.json", "kind": "file", "retired_in": "1.10.0", "reason": "the retired dispatcher's mode file" },
|
|
13
|
+
{ "path": ".claude/dispatcher-mode.json.example", "kind": "file", "retired_in": "1.10.0", "reason": "the retired dispatcher's example" },
|
|
14
|
+
{ "path": ".claude/dispatcher-mode.json.lock", "kind": "file", "retired_in": "1.10.0", "reason": "the retired dispatcher's lock" },
|
|
15
|
+
{ "path": ".claude/dispatch-log.jsonl.example", "kind": "file", "retired_in": "1.10.0", "reason": "the retired dispatcher's example log" },
|
|
16
|
+
{ "path": ".claude/context-state", "kind": "dir", "retired_in": "0.25.0", "reason": "the bespoke context-state store; native session state replaced it" },
|
|
17
|
+
{ "path": ".claude/resume", "kind": "dir", "retired_in": "0.25.0", "reason": "the bespoke resume store; native --resume replaced it" },
|
|
18
|
+
{ "path": ".claude/logs", "kind": "dir", "retired_in": "1.10.0", "reason": "the retired dispatcher's logs" },
|
|
19
|
+
{ "path": ".claude/session-learnings", "kind": "dir", "retired_in": "1.0.0", "reason": "the old learnings location; the partition is .foundry/session-learnings" },
|
|
20
|
+
{ "path": ".claude/hooks/*-exec-guard.sh", "kind": "file", "exclude_prefix": "foundry-", "retired_in": "1.8.0", "reason": "the retired session-context framework's cloud-cli exec guard; a hook still named by a command in .claude/settings*.json is refused, never removed" }
|
|
21
|
+
]
|
|
22
|
+
}
|
package/src/floorReconcile.mjs
CHANGED
|
@@ -272,13 +272,25 @@ function shippedRootNames(map) {
|
|
|
272
272
|
return set;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
/** The `(name, sub)` keys of every wildcard-shaped `ask` row a settings object carries — what
|
|
276
|
+
* `planRetirements({ askCoveredBy })` takes for the local file (hotfix-v1.17.4). */
|
|
277
|
+
export function askRootKeys(settingsObj, map) {
|
|
278
|
+
const keys = new Set();
|
|
279
|
+
const perms = (settingsObj && settingsObj.permissions) || {};
|
|
280
|
+
for (const rule of perms.ask || []) {
|
|
281
|
+
const parsed = typeof rule === 'string' ? parseFloorRootShape(rule, map.plugin_root_glob) : null;
|
|
282
|
+
if (parsed) keys.add(rootNameKey(parsed));
|
|
283
|
+
}
|
|
284
|
+
return keys;
|
|
285
|
+
}
|
|
286
|
+
|
|
275
287
|
/** Compute the rows the reconcile SHALL remove (AC-FRR-1), WITHOUT touching the filesystem. Every
|
|
276
288
|
* `allow`/`ask` row shaped exactly like the floor's own root-glob rows, whose `(name, sub)` pair the
|
|
277
289
|
* shipped map no longer declares, is queued for removal. `deny` is never a candidate (AC-FRR-2) —
|
|
278
290
|
* retirement only narrows a grant or a prompt, and a deny row read back as "extra" is, if anything,
|
|
279
291
|
* a reason to leave it exactly where the operator (or an earlier release) put it. Returns
|
|
280
292
|
* `{ retirements: { allow: [...], ask: [...] }, total }`. */
|
|
281
|
-
export function planRetirements({ settingsObj, map }) {
|
|
293
|
+
export function planRetirements({ settingsObj, map, askCoveredBy = null }) {
|
|
282
294
|
const shipped = shippedRootNames(map);
|
|
283
295
|
const shippedAsk = new Set();
|
|
284
296
|
for (const e of map.entries) {
|
|
@@ -286,6 +298,13 @@ export function planRetirements({ settingsObj, map }) {
|
|
|
286
298
|
const parsed = parseFloorRootShape(e.rule, map.plugin_root_glob);
|
|
287
299
|
if (parsed) shippedAsk.add(rootNameKey(parsed));
|
|
288
300
|
}
|
|
301
|
+
// hotfix-v1.17.4 (PR #237 security review Risk 3): for a file this pass does NOT also reconcile
|
|
302
|
+
// (`.claude/settings.local.json`), "the wildcard ask row replaces it" is only true when the
|
|
303
|
+
// TRACKED file actually carries that wildcard row — so the caller passes the tracked file's ask
|
|
304
|
+
// keys (`askRootKeys`) and a pinned `ask` row is retired only when both sets hold the pair.
|
|
305
|
+
// `null` (the tracked-file call sites, where the same pass adds the wildcard row) keeps the
|
|
306
|
+
// v1.17.3 rule unchanged.
|
|
307
|
+
const askReplaced = (key) => shippedAsk.has(key) && (askCoveredBy === null || askCoveredBy.has(key));
|
|
289
308
|
const retirements = { allow: [], ask: [] };
|
|
290
309
|
const perms = (settingsObj && settingsObj.permissions) || {};
|
|
291
310
|
for (const tier of ['allow', 'ask']) {
|
|
@@ -305,7 +324,7 @@ export function planRetirements({ settingsObj, map }) {
|
|
|
305
324
|
const pinned = parseFloorPinnedShape(rule, map.plugin_root_glob);
|
|
306
325
|
if (pinned) {
|
|
307
326
|
if (tier === 'allow') retirements[tier].push(rule);
|
|
308
|
-
else if (
|
|
327
|
+
else if (askReplaced(rootNameKey(pinned))) retirements[tier].push(rule);
|
|
309
328
|
}
|
|
310
329
|
// any other shape -> never touched (AC-FRR-2)
|
|
311
330
|
}
|
|
@@ -438,8 +457,19 @@ export function writeTargetAtomically(targetPath, obj) {
|
|
|
438
457
|
const dir = path.dirname(targetPath);
|
|
439
458
|
const tmp = path.join(dir, `.settings.json.${process.pid}.tmp`);
|
|
440
459
|
const bytes = Buffer.from(`${JSON.stringify(obj, null, 2)}\n`, 'utf-8');
|
|
460
|
+
// hotfix-v1.17.4 (PR #237 security review Risk 5): a rename-install would otherwise reset the
|
|
461
|
+
// target's mode to the umask default — an operator's 0600 `settings.local.json` (it often holds
|
|
462
|
+
// `env`) must come back 0600. The original's permission bits are copied onto the temp file
|
|
463
|
+
// before the rename; a target that does not exist yet keeps the default.
|
|
464
|
+
let mode = null;
|
|
465
|
+
try {
|
|
466
|
+
mode = fs.statSync(targetPath).mode & 0o777;
|
|
467
|
+
} catch {
|
|
468
|
+
mode = null;
|
|
469
|
+
}
|
|
441
470
|
const fd = fs.openSync(tmp, 'wx');
|
|
442
471
|
try {
|
|
472
|
+
if (mode !== null) fs.fchmodSync(fd, mode);
|
|
443
473
|
fs.writeFileSync(fd, bytes);
|
|
444
474
|
fs.fsyncSync(fd);
|
|
445
475
|
} finally {
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// retiredArtifacts.mjs — the sweep for workspace-side files an earlier release wrote and no current
|
|
2
|
+
// release reads (hotfix-v1.17.4, ER #236). Driven by the shipped catalogue `cli/retired-artifacts.json`:
|
|
3
|
+
// every present entry is reported `[stale]` on every run; removal happens only under `--cleanup`,
|
|
4
|
+
// only for catalogued paths, only when the path is exactly the catalogued kind (a regular file, or a
|
|
5
|
+
// real directory) — a symlink or the other kind is reported `[refused]` and left alone, and so is a
|
|
6
|
+
// hook under `.claude/hooks/` that a hook command in `.claude/settings*.json` still names. Nothing
|
|
7
|
+
// outside the catalogue is ever a candidate: `.claude/skills`, `.claude/agents` and every operator
|
|
8
|
+
// file are invisible to this module by construction.
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { confinedJoin } from './util.mjs';
|
|
12
|
+
|
|
13
|
+
export const CATALOGUE_REL = 'retired-artifacts.json';
|
|
14
|
+
|
|
15
|
+
/** Load and validate the catalogue shipped beside `src/` (the package root). Refuses a malformed
|
|
16
|
+
* entry loudly rather than sweeping with a half-read list. */
|
|
17
|
+
export function loadRetiredCatalogue(pkgDir) {
|
|
18
|
+
const doc = JSON.parse(fs.readFileSync(path.join(pkgDir, CATALOGUE_REL), 'utf-8'));
|
|
19
|
+
if (!doc || doc.schema_version !== 1 || !Array.isArray(doc.entries)) {
|
|
20
|
+
throw new Error('retired-artifacts.json: unrecognised schema');
|
|
21
|
+
}
|
|
22
|
+
for (const e of doc.entries) {
|
|
23
|
+
if (typeof e.path !== 'string' || path.isAbsolute(e.path) || e.path.split(/[\\/]+/).includes('..')) {
|
|
24
|
+
throw new Error(`retired-artifacts.json: bad path ${JSON.stringify(e.path)}`);
|
|
25
|
+
}
|
|
26
|
+
if (e.kind !== 'file' && e.kind !== 'dir') throw new Error(`retired-artifacts.json: bad kind for ${e.path}`);
|
|
27
|
+
const star = e.path.indexOf('*');
|
|
28
|
+
if (star !== -1 && (e.path.lastIndexOf('*') !== star || e.path.slice(star).includes('/'))) {
|
|
29
|
+
throw new Error(`retired-artifacts.json: only one '*' in the last segment is allowed (${e.path})`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return doc;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Expand an entry to concrete relative paths present on disk: the path itself, or, for a
|
|
36
|
+
* basename glob, every directory entry that matches (names starting with `exclude_prefix` skipped). */
|
|
37
|
+
function candidates(physicalRoot, entry) {
|
|
38
|
+
if (!entry.path.includes('*')) return [entry.path];
|
|
39
|
+
const dirRel = path.posix.dirname(entry.path);
|
|
40
|
+
const pattern = path.posix.basename(entry.path);
|
|
41
|
+
const [pre, post] = pattern.split('*');
|
|
42
|
+
const dirAbs = confinedJoin(physicalRoot, dirRel);
|
|
43
|
+
if (!dirAbs) return [];
|
|
44
|
+
let names;
|
|
45
|
+
try {
|
|
46
|
+
names = fs.readdirSync(dirAbs);
|
|
47
|
+
} catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return names
|
|
51
|
+
.filter((n) => n.startsWith(pre) && n.endsWith(post) && n.length >= pre.length + post.length)
|
|
52
|
+
.filter((n) => !(entry.exclude_prefix && n.startsWith(entry.exclude_prefix)))
|
|
53
|
+
.map((n) => path.posix.join(dirRel, n));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const HOOKS_DIR_REL = '.claude/hooks/';
|
|
57
|
+
const SETTINGS_FILES = ['.claude/settings.json', '.claude/settings.local.json'];
|
|
58
|
+
|
|
59
|
+
/** Every `command` string under `hooks` in the two workspace settings files, joined — the text a
|
|
60
|
+
* hook candidate's basename is checked against (PR #237 security review Risk 1: a basename glob
|
|
61
|
+
* must never take a hook the operator still wires). `unreadable` is true when a settings file
|
|
62
|
+
* exists but does not parse: then nothing under `.claude/hooks/` is planned removable (fail-closed). */
|
|
63
|
+
function hookCommandText(physicalRoot) {
|
|
64
|
+
const parts = [];
|
|
65
|
+
let unreadable = false;
|
|
66
|
+
for (const rel of SETTINGS_FILES) {
|
|
67
|
+
const abs = confinedJoin(physicalRoot, rel);
|
|
68
|
+
if (!abs) continue;
|
|
69
|
+
let raw;
|
|
70
|
+
try {
|
|
71
|
+
if (!fs.lstatSync(abs).isFile()) continue;
|
|
72
|
+
raw = fs.readFileSync(abs, 'utf-8');
|
|
73
|
+
} catch {
|
|
74
|
+
continue; // absent: nothing wired there
|
|
75
|
+
}
|
|
76
|
+
let obj;
|
|
77
|
+
try {
|
|
78
|
+
obj = JSON.parse(raw);
|
|
79
|
+
} catch {
|
|
80
|
+
unreadable = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const walk = (v) => {
|
|
84
|
+
if (Array.isArray(v)) { for (const x of v) walk(x); return; }
|
|
85
|
+
if (v && typeof v === 'object') {
|
|
86
|
+
if (typeof v.command === 'string') parts.push(v.command);
|
|
87
|
+
for (const x of Object.values(v)) walk(x);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
if (obj && typeof obj === 'object' && obj.hooks) walk(obj.hooks);
|
|
91
|
+
}
|
|
92
|
+
return { text: parts.join('\n'), unreadable };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Plan: `{ rows: [{ relPath, kind, retired_in, reason, state, why?, entries? }], present, refused }`
|
|
96
|
+
* where `state` is `stale` (present, of the catalogued kind, and not wired) or `refused` (present
|
|
97
|
+
* but a symlink, the other kind, escaping the root, or — for a hook — still named by a hook command
|
|
98
|
+
* in `.claude/settings*.json`, or those files unreadable); absent paths are omitted. A `dir` row
|
|
99
|
+
* carries `entries` (its direct entry count) so the operator sees what a removal takes. Pure over
|
|
100
|
+
* the filesystem — nothing is written. */
|
|
101
|
+
export function planRetiredArtifacts({ physicalRoot, catalogue }) {
|
|
102
|
+
const rows = [];
|
|
103
|
+
let hooks = null; // read lazily, once, only when a hook candidate is present
|
|
104
|
+
for (const entry of catalogue.entries) {
|
|
105
|
+
for (const relPath of candidates(physicalRoot, entry)) {
|
|
106
|
+
const abs = confinedJoin(physicalRoot, relPath);
|
|
107
|
+
let st = null;
|
|
108
|
+
if (abs) {
|
|
109
|
+
try {
|
|
110
|
+
st = fs.lstatSync(abs);
|
|
111
|
+
} catch {
|
|
112
|
+
continue; // absent: nothing to say
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
// the path resolves OUTSIDE the workspace (a symlink escaping the root): present, reported,
|
|
116
|
+
// never touched
|
|
117
|
+
try {
|
|
118
|
+
st = fs.lstatSync(path.join(physicalRoot, relPath));
|
|
119
|
+
} catch {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const kindOk = abs && !st.isSymbolicLink() && (entry.kind === 'dir' ? st.isDirectory() : st.isFile());
|
|
124
|
+
const row = { relPath, kind: entry.kind, retired_in: entry.retired_in, reason: entry.reason, state: kindOk ? 'stale' : 'refused', why: kindOk ? null : 'kind' };
|
|
125
|
+
if (row.state === 'stale' && relPath.startsWith(HOOKS_DIR_REL)) {
|
|
126
|
+
if (hooks === null) hooks = hookCommandText(physicalRoot);
|
|
127
|
+
if (hooks.unreadable) { row.state = 'refused'; row.why = 'settings-unreadable'; }
|
|
128
|
+
else if (hooks.text.includes(path.posix.basename(relPath))) { row.state = 'refused'; row.why = 'referenced'; }
|
|
129
|
+
}
|
|
130
|
+
if (row.state === 'stale' && entry.kind === 'dir') {
|
|
131
|
+
try { row.entries = fs.readdirSync(abs).length; } catch { row.entries = null; }
|
|
132
|
+
}
|
|
133
|
+
rows.push(row);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
rows,
|
|
138
|
+
present: rows.filter((r) => r.state === 'stale').length,
|
|
139
|
+
refused: rows.filter((r) => r.state === 'refused').length,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Remove every `stale` row (re-checked with lstat immediately before each removal). Returns the
|
|
144
|
+
* count removed. A row whose state changed between plan and apply is skipped, never forced. */
|
|
145
|
+
export function applyRetiredArtifacts(plan, physicalRoot) {
|
|
146
|
+
let removed = 0;
|
|
147
|
+
for (const row of plan.rows) {
|
|
148
|
+
if (row.state !== 'stale') continue;
|
|
149
|
+
const abs = confinedJoin(physicalRoot, row.relPath);
|
|
150
|
+
if (!abs) continue;
|
|
151
|
+
let st;
|
|
152
|
+
try {
|
|
153
|
+
st = fs.lstatSync(abs);
|
|
154
|
+
} catch {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (st.isSymbolicLink()) continue;
|
|
158
|
+
if (row.kind === 'dir' ? !st.isDirectory() : !st.isFile()) continue;
|
|
159
|
+
try {
|
|
160
|
+
if (row.kind === 'dir') fs.rmSync(abs, { recursive: true, force: false });
|
|
161
|
+
else fs.unlinkSync(abs);
|
|
162
|
+
removed += 1;
|
|
163
|
+
row.state = 'removed';
|
|
164
|
+
} catch {
|
|
165
|
+
row.state = 'refused';
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
plan.removed = removed;
|
|
169
|
+
return removed;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The rows every writer prints. `cleanup` false → `[stale]` (nothing removed); true → `[removed]`
|
|
173
|
+
* for what went, `[refused]` for what did not. Empty when nothing catalogued is present. */
|
|
174
|
+
export function renderRetiredArtifactRows(plan, { cleanup }) {
|
|
175
|
+
const out = [];
|
|
176
|
+
for (const r of plan.rows) {
|
|
177
|
+
const size = r.kind === 'dir' && typeof r.entries === 'number' ? ` [${r.entries} entr${r.entries === 1 ? 'y' : 'ies'}]` : '';
|
|
178
|
+
if (r.state === 'stale') {
|
|
179
|
+
out.push(cleanup
|
|
180
|
+
? ` [stale] ${r.relPath}${size} — retired in v${r.retired_in} (${r.reason}) — NOT removed`
|
|
181
|
+
: ` [stale] ${r.relPath}${size} — retired in v${r.retired_in} (${r.reason}); remove with --cleanup`);
|
|
182
|
+
} else if (r.state === 'removed') {
|
|
183
|
+
out.push(` [removed] ${r.relPath}${size} — retired in v${r.retired_in}`);
|
|
184
|
+
} else if (r.why === 'referenced') {
|
|
185
|
+
out.push(` [refused] ${r.relPath} — still named by a hook command in .claude/settings*.json — left alone`);
|
|
186
|
+
} else if (r.why === 'settings-unreadable') {
|
|
187
|
+
out.push(` [refused] ${r.relPath} — .claude/settings*.json does not parse, so its hook wiring is unknown — left alone`);
|
|
188
|
+
} else {
|
|
189
|
+
out.push(` [refused] ${r.relPath} — present but not a regular ${r.kind} (a link, or the other kind) — left alone`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
}
|
package/src/update.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// machinery run.mjs's create path already uses (cli/src/reconcile.mjs, cli/src/floorReconcile.mjs).
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import { RefusalError, physicalResolve } from './util.mjs';
|
|
10
|
+
import { RefusalError, physicalResolve, confinedJoin } from './util.mjs';
|
|
11
11
|
import { loadMap, buildSettings } from './permissionFloor.mjs';
|
|
12
12
|
import { buildManagedFiles } from './scaffold.mjs';
|
|
13
13
|
import { planManagedFiles, applyPlan } from './reconcile.mjs';
|
|
@@ -19,6 +19,8 @@ import { planAmendmentsBackfill, applyAmendmentsBackfill, renderAmendmentsRow }
|
|
|
19
19
|
import { buildUpgradeReport, writeUpgradeReport, installedVersionBefore, versionOrNull, NEXT_LINE } from './upgradeReport.mjs';
|
|
20
20
|
import { planStatuslineWiring, applyStatuslineWiring, renderStatuslineRows, statuslineChanged } from './statuslineWiring.mjs';
|
|
21
21
|
import { policyPresent, missingSelfGuardDeny, applySelfGuardDeny, renderSelfGuardRow, selfGuardShapeOk } from './selfGuardDeny.mjs';
|
|
22
|
+
import { loadRetiredCatalogue, planRetiredArtifacts, applyRetiredArtifacts, renderRetiredArtifactRows } from './retiredArtifacts.mjs';
|
|
23
|
+
import { planRetirements, applyRetirements, askRootKeys } from './floorReconcile.mjs';
|
|
22
24
|
import {
|
|
23
25
|
ALLOWED_CLAUDE_SUBCOMMANDS, resolveClaudeOnPath, runClaude,
|
|
24
26
|
defaultScopes, snapshotScopes, classifyMigration, migrationActions, migrateScope,
|
|
@@ -48,6 +50,29 @@ export function parseUpdateArgv(argv) {
|
|
|
48
50
|
* itself defines (marketplace-refresh, plugin-update, reinitialization); the full orchestrator
|
|
49
51
|
* below may print a fourth `cleanup` row once the sibling atom's phase is wired in, which is a
|
|
50
52
|
* property of the RUNTIME composition, not of this formatter's own contract. */
|
|
53
|
+
/** hotfix-v1.17.4 (ER #236): the retirement-only plan over `.claude/settings.local.json`, which the
|
|
54
|
+
* tracked-file reconcile never reads. Read-only; `{ rel, abs, plan, error }` — `plan` null when the
|
|
55
|
+
* file is absent, not a regular file, or resolves outside the root; `error` set when it exists but
|
|
56
|
+
* does not parse (reported, never guessed). A pinned `ask` row is retired only when the TRACKED file
|
|
57
|
+
* carries the replacing wildcard row (`askCoveredBy`; PR #237 security review Risk 3). */
|
|
58
|
+
function planLocalRetirement({ physicalRoot, map, trackedSettingsObj }) {
|
|
59
|
+
const rel = '.claude/settings.local.json';
|
|
60
|
+
const abs = confinedJoin(physicalRoot, rel);
|
|
61
|
+
if (!abs) return { rel, abs: null, plan: null, error: 'resolves outside the workspace' };
|
|
62
|
+
try {
|
|
63
|
+
if (!fs.lstatSync(abs).isFile()) return { rel, abs, plan: null, error: 'not a regular file' };
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return { rel, abs, plan: null, error: e && e.code === 'ENOENT' ? null : e.message };
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const settingsObj = readTarget(abs);
|
|
69
|
+
const askCoveredBy = trackedSettingsObj ? askRootKeys(trackedSettingsObj, map) : new Set();
|
|
70
|
+
return { rel, abs, settingsObj, plan: planRetirements({ settingsObj, map, askCoveredBy }), error: null };
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return { rel, abs, plan: null, error: e.message };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
51
76
|
export function renderSummary(phases) {
|
|
52
77
|
const lines = ['Summary:'];
|
|
53
78
|
for (const p of phases) {
|
|
@@ -230,6 +255,18 @@ export async function runUpdate(argv, { cwd, configDir, homeDir, pkgDir, output,
|
|
|
230
255
|
if (previewAmendmentsRow) previewLines.push(previewAmendmentsRow);
|
|
231
256
|
// statusline-wiring (AC-SLW-1/-2): PREVIEW-ONLY rows; Phase 4 re-plans fresh from disk.
|
|
232
257
|
previewLines.push(...renderStatuslineRows(planStatuslineWiring({ physicalRoot, templatesDir })));
|
|
258
|
+
// retired-artifacts (hotfix-v1.17.4, ER #236): PREVIEW-ONLY rows; Phase 4 re-plans fresh from disk.
|
|
259
|
+
const retiredCatalogue = loadRetiredCatalogue(pkgDir);
|
|
260
|
+
previewLines.push(...renderRetiredArtifactRows(planRetiredArtifacts({ physicalRoot, catalogue: retiredCatalogue }), { cleanup: flags.cleanup }));
|
|
261
|
+
// settings.local.json retirement (hotfix-v1.17.4): PREVIEW-ONLY row (PR #237 review Risk 2 —
|
|
262
|
+
// every Phase 4 write is announced before the first write happens); Phase 4 re-plans fresh.
|
|
263
|
+
{
|
|
264
|
+
const lp = planLocalRetirement({
|
|
265
|
+
physicalRoot, map, trackedSettingsObj: floorTarget.present ? readTarget(floorTarget.path) : null,
|
|
266
|
+
});
|
|
267
|
+
if (lp.plan && lp.plan.total > 0) previewLines.push(` [permission-floor] ${lp.rel}: would retire allow=${lp.plan.retirements.allow.length}, ask=${lp.plan.retirements.ask.length} (never adds)`);
|
|
268
|
+
else if (lp.error) previewLines.push(` [permission-floor] ${lp.rel}: would not be reconciled (${lp.error})`);
|
|
269
|
+
}
|
|
233
270
|
print(previewLines.join('\n'));
|
|
234
271
|
|
|
235
272
|
const env = { ...spawnEnv, CLAUDE_CONFIG_DIR: configDir };
|
|
@@ -348,10 +385,40 @@ export async function runUpdate(argv, { cwd, configDir, homeDir, pkgDir, output,
|
|
|
348
385
|
const statuslinePlan = planStatuslineWiring({ physicalRoot, templatesDir });
|
|
349
386
|
applyStatuslineWiring(statuslinePlan);
|
|
350
387
|
for (const row of renderStatuslineRows(statuslinePlan)) print(row);
|
|
388
|
+
// retired-artifacts (hotfix-v1.17.4, ER #236): re-planned FRESH from disk; reported every run,
|
|
389
|
+
// removed only under --cleanup, only catalogued paths of the catalogued kind, never a hook a
|
|
390
|
+
// settings hook command still names.
|
|
391
|
+
const retiredPlan = planRetiredArtifacts({ physicalRoot, catalogue: retiredCatalogue });
|
|
392
|
+
let retiredRemoved = 0;
|
|
393
|
+
if (flags.cleanup && retiredPlan.present > 0) retiredRemoved = applyRetiredArtifacts(retiredPlan, physicalRoot);
|
|
394
|
+
for (const row of renderRetiredArtifactRows(retiredPlan, { cleanup: flags.cleanup })) print(row);
|
|
395
|
+
|
|
396
|
+
// settings.local.json (hotfix-v1.17.4): the tracked-file reconcile never reads it, so a
|
|
397
|
+
// version-pinned floor row an old init left there survived every upgrade. Only RETIREMENT is
|
|
398
|
+
// applied here (never additions — the local file is the operator's), with the same planner and
|
|
399
|
+
// the same never-clobber, mode-preserving write as the tracked file. The tracked file is re-read
|
|
400
|
+
// AFTER its own write above, so an `ask` row is retired only when the wildcard row that replaces
|
|
401
|
+
// it is really there (Risk 3); confined like every other path (Risk 4).
|
|
402
|
+
let localRetired = 0;
|
|
403
|
+
{
|
|
404
|
+
const lp = planLocalRetirement({
|
|
405
|
+
physicalRoot, map,
|
|
406
|
+
trackedSettingsObj: freshFloorTarget.present ? readTarget(freshFloorTarget.path) : null,
|
|
407
|
+
});
|
|
408
|
+
if (lp.plan && lp.plan.total > 0) {
|
|
409
|
+
writeTargetAtomically(lp.abs, applyRetirements(lp.settingsObj, lp.plan));
|
|
410
|
+
localRetired = lp.plan.total;
|
|
411
|
+
for (const tier of ['allow', 'ask']) for (const r of lp.plan.retirements[tier]) print(` [retired] ${lp.rel}: ${r}`);
|
|
412
|
+
print(` [permission-floor] ${lp.rel}: retired ${localRetired} version-pinned/gone row(s)`);
|
|
413
|
+
} else if (lp.error) {
|
|
414
|
+
print(` [permission-floor] ${lp.rel}: not reconciled (${lp.error})`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
351
418
|
phases.push({
|
|
352
419
|
name: 'reinitialization',
|
|
353
420
|
verdict: anyCreated || anyFloorAdded || anyGitignoreChanged || anyAmendmentsBackfilled
|
|
354
|
-
|| statuslineChanged(statuslinePlan) ? 'changed' : 'already current',
|
|
421
|
+
|| statuslineChanged(statuslinePlan) || retiredRemoved > 0 || localRetired > 0 ? 'changed' : 'already current',
|
|
355
422
|
});
|
|
356
423
|
|
|
357
424
|
print('');
|
|
@@ -363,6 +430,8 @@ export async function runUpdate(argv, { cwd, configDir, homeDir, pkgDir, output,
|
|
|
363
430
|
const report = buildUpgradeReport({
|
|
364
431
|
installedBefore, afterEntry, toPluginVersion: pins.plugin_version, phases, filePlan, amendmentsPlan,
|
|
365
432
|
updaterVersion, coreVersion: corePkg.version, updaterPluginVersion: pins.plugin_version,
|
|
433
|
+
retiredArtifacts: { present: retiredPlan.rows.filter((r) => r.state === 'stale').map((r) => r.relPath), removed: retiredRemoved, refused: retiredPlan.refused },
|
|
434
|
+
localRetired,
|
|
366
435
|
});
|
|
367
436
|
const reportPath = writeUpgradeReport(physicalRoot, report);
|
|
368
437
|
print('');
|
package/src/upgradeReport.mjs
CHANGED
|
@@ -32,6 +32,7 @@ export function versionOrNull(v) {
|
|
|
32
32
|
export function buildUpgradeReport({
|
|
33
33
|
installedBefore = null, afterEntry, toPluginVersion, phases, filePlan, amendmentsPlan, now = new Date(),
|
|
34
34
|
updaterVersion = null, coreVersion = null, updaterPluginVersion = null,
|
|
35
|
+
retiredArtifacts = null, localRetired = 0,
|
|
35
36
|
}) {
|
|
36
37
|
const seedRow = (filePlan || []).find((f) => f.seed);
|
|
37
38
|
return {
|
|
@@ -57,6 +58,11 @@ export function buildUpgradeReport({
|
|
|
57
58
|
: { backfilled: 0, present: 0, skipped: 0, total: 0 },
|
|
58
59
|
permissions_policy: seedRow ? (seedRow.action === 'create' ? 'created' : 'kept') : 'absent',
|
|
59
60
|
drifted: (filePlan || []).filter((f) => f.action === 'drifted').map((f) => f.relPath),
|
|
61
|
+
// hotfix-v1.17.4: what the sweep found (paths are workspace-relative catalogue entries, never free text)
|
|
62
|
+
retired_artifacts: retiredArtifacts
|
|
63
|
+
? { present: retiredArtifacts.present, removed: retiredArtifacts.removed, refused: retiredArtifacts.refused }
|
|
64
|
+
: { present: [], removed: 0, refused: 0 },
|
|
65
|
+
settings_local_retired: localRetired,
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
|