create-agentic-workspace 0.18.2 → 0.18.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-agentic-workspace",
3
- "version": "0.18.2",
3
+ "version": "0.18.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",
@@ -36,7 +36,7 @@
36
36
  "marketplace_name": "agentic-foundry",
37
37
  "marketplace_repo": "lukasrepublic/agentic-foundry",
38
38
  "plugin_name": "foundry",
39
- "plugin_version": "1.18.2",
39
+ "plugin_version": "1.18.4",
40
40
  "pins_researched": "2026-08-02"
41
41
  }
42
42
  }
@@ -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.18.2",
4
+ "generated_for_plugin_version": "1.18.4",
5
5
  "entries": [
6
6
  {
7
7
  "rule": "Bash(~/.claude/plugins/cache/*/foundry/*/scripts/foundry-acceptance-contract-validate.py:*)",
@@ -372,6 +372,10 @@
372
372
  "script": "foundry_audit_log.py",
373
373
  "rationale": "library: no argparse/__main__; shared audit-log helper imported by other scripts"
374
374
  },
375
+ {
376
+ "script": "foundry_yaml_load.py",
377
+ "rationale": "library: no argparse/__main__; shared C-accelerated safe-YAML loader + per-process file memo imported by the doctor, the capability preflight and the release loader"
378
+ },
375
379
  {
376
380
  "script": "foundry_audit_preconditions.py",
377
381
  "rationale": "the shipped __main__ is a manual-invocation debug CLI for a human/operator; never instructed by any skill/hook"
@@ -274,9 +274,17 @@ export function buildSettings(map, pins) {
274
274
  permissions: { allow: byTier.allow, ask: byTier.ask, deny: byTier.deny },
275
275
  extraKnownMarketplaces: { [pins.marketplace_name]: marketplaceEntry },
276
276
  enabledPlugins: { [`${pins.plugin_name}@${pins.marketplace_name}`]: true },
277
+ // v1.18.3 (AC-BCL-4(c) amended, operator directive 2026-09-30): the status line ships with the
278
+ // scaffold — a new workspace had none. The one value permitted, naming the framework wrapper the
279
+ // create path writes beside it (statuslineWiring.mjs). Grants nothing; the trust dialog gates it.
280
+ statusLine: { ...STATUSLINE_VALUE },
277
281
  };
278
282
  }
279
283
 
284
+ export const STATUSLINE_VALUE = Object.freeze({
285
+ type: 'command', command: '$CLAUDE_PROJECT_DIR/.claude/hooks/foundry-statusline.sh', padding: 0,
286
+ });
287
+
280
288
  /** One capability-preview line per bundled-map entry, grouped by tier, carrying rule/tier/
281
289
  * rationale (AC-BCL-3). */
282
290
  export function renderCapabilityLines(map) {
package/src/run.mjs CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  } from './floorReconcile.mjs';
20
20
  import { reconcileGitignorePlan, applyGitignorePlan, renderGitignoreRow } from './gitignoreReconcile.mjs';
21
21
  import { planAmendmentsBackfill, applyAmendmentsBackfill, renderAmendmentsRow } from './amendmentsBackfill.mjs';
22
- import { planStatuslineWiring, applyStatuslineWiring, renderStatuslineRows } from './statuslineWiring.mjs';
22
+ import { planStatuslineWiring, applyStatuslineWiring, renderStatuslineRows, wrapperIsOurs } from './statuslineWiring.mjs';
23
23
 
24
24
  export { DECLARED_PATH_SET };
25
25
 
@@ -156,6 +156,7 @@ export async function runCli(argv, { cwd, isTTY, input, output, homeDir, pkgDir
156
156
  const map = loadMap(path.join(pkgDir, 'permission-floor.json'));
157
157
  const pins = loadPins(pkgDir);
158
158
  const settingsObj = buildSettings(map, pins);
159
+ if (!wrapperIsOurs(physicalRoot)) delete settingsObj.statusLine;
159
160
  const settingsBytes = Buffer.from(`${JSON.stringify(settingsObj, null, 2)}\n`, 'utf-8');
160
161
 
161
162
  const managedFiles = buildManagedFiles({
@@ -200,12 +201,14 @@ export async function runCli(argv, { cwd, isTTY, input, output, homeDir, pkgDir
200
201
  // --existing run never touches .claude/settings.json (AC-BCL-9: an existing settings file is
201
202
  // reported drifted, left byte-identical, never merged); --reconcile-floor is the one opt-in
202
203
  // that already permits a narrow-key write to it, and this wiring is the same class of write.
203
- // The greenfield create path never wires it — feat-foundry-bootstrap-cli AC-BCL-4(c) closes
204
- // the pre-session key set, deliberately. planStatuslineWiring returns an empty plan when
205
- // settings.json is absent. The upgrader (update.mjs) always reconciles the floor, so it
206
- // always wires.
207
- const statuslinePlan = answers.existing && answers.reconcileFloor
208
- ? planStatuslineWiring({ physicalRoot, templatesDir: path.join(pkgDir, 'templates') })
204
+ // The upgrader (update.mjs) always reconciles the floor, so it always wires.
205
+ // v1.18.3 (operator directive 2026-09-30): ALSO whenever this run creates .claude/settings.json
206
+ // itself — the greenfield path, or --existing into a folder that has none. Until then a new user
207
+ // started with no status line at all. An existing settings.json is still never merged without
208
+ // --reconcile-floor (AC-BCL-9).
209
+ const settingsCreated = plan.some((f) => f.relPath === '.claude/settings.json' && f.action === 'create');
210
+ const statuslinePlan = (answers.existing && answers.reconcileFloor) || settingsCreated
211
+ ? planStatuslineWiring({ physicalRoot, templatesDir: path.join(pkgDir, 'templates'), settingsWillBeCreated: settingsCreated })
209
212
  : null;
210
213
  for (const row of renderStatuslineRows(statuslinePlan)) print(row);
211
214
 
@@ -7,10 +7,12 @@
7
7
  // nothing when its one cache glob missed — on the operator's second machine the bar was simply
8
8
  // absent, with no line saying which piece was missing.
9
9
  //
10
- // This module is the WRITER, and it runs only post-trust — from `update-agentic-workspace` and from
11
- // `create-agentic-workspace --existing` on a workspace whose `.claude/settings.json` already exists.
12
- // The greenfield create path never calls it: feat-foundry-bootstrap-cli AC-BCL-4(c) (a frozen
13
- // security Block) closes the pre-session settings key set, and that reasoning stands.
10
+ // This module is the WRITER. It runs from `update-agentic-workspace`, from `create-agentic-workspace
11
+ // --existing --reconcile-floor` on a workspace whose `.claude/settings.json` already exists, and — since
12
+ // v1.18.3 — from the create path whenever that run writes `.claude/settings.json` itself. Until then
13
+ // the greenfield path never wired it (AC-BCL-4(c) closed the pre-session key set), so every new user
14
+ // started without the bar; the operator directed the fix on 2026-09-30. The key is declared, not
15
+ // granted: the platform's trust dialog still gates the first run of any project command.
14
16
  //
15
17
  // Two artifacts, two disciplines:
16
18
  // * the wrappers are FRAMEWORK-OWNED: absent -> create; present with the framework marker ->
@@ -38,6 +40,17 @@ export const RETIRED_KEYS = Object.freeze([
38
40
  { key: 'subagentStatusLine', rel: '.claude/hooks/foundry-subagent-statusline.sh' },
39
41
  ]);
40
42
 
43
+ /** True when the wrapper path is absent or a regular file carrying the framework marker — i.e. the
44
+ * file a `statusLine` key would run is one this framework writes. The create path omits the key from
45
+ * a new settings.json otherwise (security review Risk 2: never wire a file the framework did not write). */
46
+ export function wrapperIsOurs(physicalRoot) {
47
+ const abs = confinedJoin(physicalRoot, WRAPPERS[0].rel);
48
+ if (abs === null) return false;
49
+ const st = fs.lstatSync(abs, { throwIfNoEntry: false });
50
+ if (!st) return true;
51
+ return st.isFile() && fs.readFileSync(abs, 'utf-8').includes(MARKER);
52
+ }
53
+
41
54
  export function desiredSettingsValue(rel) {
42
55
  return { type: 'command', command: `$CLAUDE_PROJECT_DIR/${rel}`, padding: 0 };
43
56
  }
@@ -45,10 +58,14 @@ export function desiredSettingsValue(rel) {
45
58
  /** Plan only. `files[]` rows carry `{ rel, abs, action: create|converged|unchanged|kept|refused, bytes }`;
46
59
  * `keys[]` rows carry `{ key, action: wired|already-wired }`; `settingsPresent` says whether the
47
60
  * post-trust precondition held (when it did not, the plan is empty and renders nothing). */
48
- export function planStatuslineWiring({ physicalRoot, templatesDir }) {
61
+ export function planStatuslineWiring({ physicalRoot, templatesDir, settingsWillBeCreated = false }) {
49
62
  const target = resolveTarget(physicalRoot);
50
- const plan = { settingsPresent: target.present, settingsPath: target.path, files: [], keys: [], applied: false };
51
- if (!target.present) return plan;
63
+ // v1.18.3 (operator directive 2026-09-30, amends feat-foundry-bootstrap-cli AC-BCL-4(c)): the create
64
+ // path wires the status line too, in the settings.json it is about to write — a new user saw no bar.
65
+ // PREVIEW ONLY: the create path re-plans after its write, when the file exists, and applies that.
66
+ const preview = !target.present && settingsWillBeCreated;
67
+ const plan = { settingsPresent: target.present || preview, settingsPath: target.path, files: [], keys: [], applied: false };
68
+ if (!plan.settingsPresent) return plan;
52
69
  for (const w of WRAPPERS) {
53
70
  const abs = confinedJoin(physicalRoot, w.rel);
54
71
  const bytes = fs.readFileSync(path.join(templatesDir, w.template));
@@ -65,7 +82,7 @@ export function planStatuslineWiring({ physicalRoot, templatesDir }) {
65
82
  }
66
83
  plan.files.push({ rel: w.rel, abs, action, bytes, ...(action === 'refused' && st ? { reason: 'not a regular file' } : {}) });
67
84
  }
68
- const settings = readTarget(target.path);
85
+ const settings = preview ? {} : readTarget(target.path);
69
86
  for (const w of WRAPPERS) {
70
87
  const present = Object.prototype.hasOwnProperty.call(settings, w.key);
71
88
  // Security review (Risk 2): never wire a key at a file this framework did not write or could
@@ -29,11 +29,19 @@ set +e
29
29
  # overlapped, each refresh spawning another, until the machine ran out of memory and Claude Code
30
30
  # itself crashed (an adopter's WSL session: 44,616 spawns in 21 minutes, SIGBUS). So: one render per
31
31
  # project at a time (an mkdir lock), its output cached for FOUNDRY_STATUSLINE_TTL seconds (default 5),
32
- # and a refresh that finds a render in flight prints the last line and exits at once. The cache-hit
33
- # path spawns only `cat` (and `date` where bash has no EPOCHSECONDS). Cache: ~/.cache/foundry-statusline.
32
+ # and a refresh that finds a render in flight waits briefly for it. The cache-hit path spawns only
33
+ # `cat` (and `date` where bash has no EPOCHSECONDS). Cache: ~/.cache/foundry-statusline.
34
34
  # Security review (v1.18.2, Block): the cache lives in the user's OWN cache dir, never a shared /tmp,
35
35
  # and is used only when it is a real directory owned by this user (not a symlink) — otherwise the
36
36
  # wrapper renders directly, uncached (fail-open), so a planted dir/link is never read or written.
37
+ #
38
+ # v1.18.3 — the cache is KEYED, not just timed. Claude Code re-runs the status line only on events
39
+ # (a message, a mode change), never on a clock, so a cached line served after the context moved stayed
40
+ # on screen until the NEXT event: every new session showed no `tok` bar at all after its first reply
41
+ # (the first render, before any reply, has no context figure and was cached). A cached line is reused
42
+ # only while the session, its directory and the context figure are the ones it was rendered from —
43
+ # read from the payload with bash pattern matching, no spawn — and a refresh that finds a render in
44
+ # flight for a different key waits for it (≤ ~2 s) instead of printing a line it knows is stale.
37
45
  if [ -z "${FOUNDRY_STATUSLINE_INNER:-}" ]; then
38
46
  PAYLOAD="$(cat 2>/dev/null || true)"
39
47
  _d="${XDG_CACHE_HOME:-${HOME:-/nonexistent}/.cache}/foundry-statusline"
@@ -44,20 +52,40 @@ if [ -z "${FOUNDRY_STATUSLINE_INNER:-}" ]; then
44
52
  fi
45
53
  _k="${CLAUDE_PROJECT_DIR:-$PWD}"; _k="${_k//[^A-Za-z0-9]/_}"
46
54
  _cache="$_d/${_k}.out"; _lock="$_d/${_k}.lock"
55
+ _key=""
56
+ _re='"session_id"[[:space:]]*:[[:space:]]*"([^"]*)"'
57
+ [[ $PAYLOAD =~ $_re ]] && _key="${BASH_REMATCH[1]}"
58
+ _re='"current_dir"[[:space:]]*:[[:space:]]*"([^"]*)"'
59
+ [[ $PAYLOAD =~ $_re ]] && _key="${_key}|${BASH_REMATCH[1]}"
60
+ _re='"remaining_percentage"[[:space:]]*:[[:space:]]*([0-9.]+)'
61
+ if [[ $PAYLOAD =~ $_re ]]; then _key="${_key}|${BASH_REMATCH[1]}"; else _key="${_key}|-"; fi
47
62
  _now="${EPOCHSECONDS:-$(date +%s)}"; _ttl="${FOUNDRY_STATUSLINE_TTL:-5}"
48
63
  _ts=0; [ -r "$_cache.ts" ] && read -r _ts < "$_cache.ts" 2>/dev/null
49
64
  case "$_ts" in ''|*[!0-9]*) _ts=0 ;; esac
50
- if [ -r "$_cache" ] && [ "$_ts" -le "$_now" ] && [ $(( _now - _ts )) -lt "$_ttl" ]; then
65
+ _ck=""; [ -r "$_cache.key" ] && _ck="$(< "$_cache.key")"
66
+ if [ -r "$_cache" ] && [ "$_ck" = "$_key" ] && [ "$_ts" -le "$_now" ] && [ $(( _now - _ts )) -lt "$_ttl" ]; then
51
67
  printf '%s' "$(< "$_cache")"; exit 0
52
68
  fi
53
- if ! mkdir "$_lock" 2>/dev/null; then
69
+ _tries=0
70
+ while ! mkdir "$_lock" 2>/dev/null; do
54
71
  # a lock whose ts is not written yet is FRESH (a render just started), never stale
55
72
  _lt="$_now"; [ -r "$_lock/ts" ] && read -r _lt < "$_lock/ts" 2>/dev/null
56
73
  case "$_lt" in ''|*[!0-9]*) _lt="$_now" ;; esac
57
- if [ $(( _now - _lt )) -gt 30 ]; then rm -f "$_lock/ts" 2>/dev/null; rmdir "$_lock" 2>/dev/null; fi
58
- [ -r "$_cache" ] && printf '%s' "$(< "$_cache")"
59
- exit 0
60
- fi
74
+ # a stale lock is cleared once; one that cannot be removed (a stray file inside it) is never
75
+ # retried in a tight loop (security review R1) — the refresh falls through to the bounded wait
76
+ if [ $(( _now - _lt )) -gt 30 ] && [ "$_tries" -eq 0 ]; then
77
+ rm -f "$_lock/ts" 2>/dev/null
78
+ _tries=1
79
+ rmdir "$_lock" 2>/dev/null && continue
80
+ fi
81
+ _ck=""; [ -r "$_cache.key" ] && _ck="$(< "$_cache.key")"
82
+ if [ "$_ck" = "$_key" ] || [ "$_tries" -ge 20 ]; then
83
+ [ -r "$_cache" ] && printf '%s' "$(< "$_cache")"
84
+ exit 0
85
+ fi
86
+ _tries=$(( _tries + 1 )); sleep 0.1 2>/dev/null || sleep 1
87
+ done
88
+ trap 'rm -f "$_lock/ts" 2>/dev/null; rmdir "$_lock" 2>/dev/null' EXIT
61
89
  printf '%s\n' "$_now" > "$_lock/ts" 2>/dev/null
62
90
  # bounded: a hung render (git on a stalled filesystem) is killed at 20 s where `timeout` exists,
63
91
  # so it can never outlive the 30 s stale-lock window and overlap the next one
@@ -67,8 +95,9 @@ if [ -z "${FOUNDRY_STATUSLINE_INNER:-}" ]; then
67
95
  _out="$(printf '%s' "$PAYLOAD" | FOUNDRY_STATUSLINE_INNER=1 bash "$0" "$@" 2>/dev/null)"
68
96
  fi
69
97
  printf '%s' "$_out" > "$_cache.tmp" 2>/dev/null && mv -f "$_cache.tmp" "$_cache" 2>/dev/null
98
+ printf '%s' "$_key" > "$_cache.key" 2>/dev/null
70
99
  printf '%s\n' "${EPOCHSECONDS:-$(date +%s)}" > "$_cache.ts" 2>/dev/null
71
- rm -f "$_lock/ts" 2>/dev/null; rmdir "$_lock" 2>/dev/null
100
+ rm -f "$_lock/ts" 2>/dev/null; rmdir "$_lock" 2>/dev/null; trap - EXIT
72
101
  printf '%s' "$_out"
73
102
  exit 0
74
103
  fi
@@ -95,10 +124,13 @@ if [ -z "$selected" ]; then
95
124
  done | sort -V -k1,1 | tail -1 | cut -f2-
96
125
  )"
97
126
  fi
98
- # 3. the self-hosting source checkout
127
+ # 3. the self-hosting source checkout — only a real clone (its own `.git` DIRECTORY): a cloned repo
128
+ # cannot commit a nested `.git` directory, so files merely shipped in a project tree never resolve here
129
+ # (v1.18.3 security review R3 — the create path now wires the line before the plugin is installed,
130
+ # when steps 1–2 miss and this step would otherwise run the project's own copy)
99
131
  if [ -z "$selected" ] || [ ! -r "$selected" ]; then
100
132
  src="${CLAUDE_PROJECT_DIR:-$PWD}/agentic-foundry/scripts/${RENDERER}"
101
- [ -r "$src" ] && selected="$src"
133
+ [ -r "$src" ] && [ -d "${CLAUDE_PROJECT_DIR:-$PWD}/agentic-foundry/.git" ] && [ ! -L "${CLAUDE_PROJECT_DIR:-$PWD}/agentic-foundry/.git" ] && selected="$src"
102
134
  fi
103
135
 
104
136
  # The resolved file must be the shipped renderer, not merely a file at a plausible path (security
@@ -117,6 +149,13 @@ DIR=""; REM=""
117
149
  if command -v jq >/dev/null 2>&1; then
118
150
  DIR="$(jqr '(.workspace.current_dir // .workspace.project_dir // .cwd // empty)')"
119
151
  REM="$(jqr '(.context_window.remaining_percentage // empty)')"
152
+ else
153
+ # v1.18.3: no jq (a fresh Windows/WSL or slim-container host) still gets the bar — the two fields are
154
+ # read by bash pattern matching
155
+ _re='"current_dir"[[:space:]]*:[[:space:]]*"([^"]*)"'
156
+ [[ $PAYLOAD =~ $_re ]] && DIR="${BASH_REMATCH[1]}"
157
+ _re='"remaining_percentage"[[:space:]]*:[[:space:]]*([0-9.]+)'
158
+ [[ $PAYLOAD =~ $_re ]] && REM="${BASH_REMATCH[1]}"
120
159
  fi
121
160
  [ -n "$DIR" ] || DIR="${CLAUDE_PROJECT_DIR:-$PWD}"
122
161
  LABEL="$(basename "$DIR" 2>/dev/null)"
@@ -126,7 +165,8 @@ OUT="⌂ ${LABEL}"
126
165
  case "$REM" in
127
166
  ''|*[!0-9.]*) ;;
128
167
  *)
129
- USED="$(printf '%.0f' "$(printf '100 - %s\n' "$REM" | bc -l 2>/dev/null || echo 0)" 2>/dev/null)"
168
+ # awk, not bc: bc is absent from many slim images, and its absence printed a false `0%`
169
+ USED="$(awk -v r="$REM" 'BEGIN{ u=100-r; print int(u+0.5) }' 2>/dev/null)"
130
170
  [ -n "$USED" ] || USED=0
131
171
  [ "$USED" -lt 0 ] 2>/dev/null && USED=0
132
172
  [ "$USED" -gt 100 ] 2>/dev/null && USED=100