youmd 0.8.22 → 0.8.23

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": "youmd",
3
- "version": "0.8.22",
3
+ "version": "0.8.23",
4
4
  "description": "Identity context protocol for the agent internet — an MCP where the context is you. CLI for the You.md platform.",
5
5
  "bin": {
6
6
  "you": "dist/you.js",
@@ -26,6 +26,15 @@ GIT_USER_EMAIL="${GIT_USER_EMAIL:-houston@bamf.ai}"
26
26
  AGENT_SHARED="${HOME}/.agent-shared"
27
27
  SCISTACK="${HOME}/.claude/scistack"
28
28
 
29
+ # Per-user stack-source registry for AUTO-CLONE on a fresh machine (so the
30
+ # skill/stack layer self-installs — no manual `git clone`). Resolved per-repo from:
31
+ # 1) SKILLSTACK_REPO_REMOTES env ("/abs/path=https://git/url /path2=...")
32
+ # 2) ~/.you/stack-sources file (one "abs_path=remote_url" per line, '#' comments)
33
+ # This is intentionally NOT hardcoded to any one user's repos: each You.md user
34
+ # registers their OWN agent-shared / science-stack remotes (You.md writes the file
35
+ # from the user's identity). A repo with no resolvable remote is skipped, never cloned.
36
+ STACK_SOURCES_FILE="${STACK_SOURCES_FILE:-${YOU_HOME:-${YOUMD_HOME:-${HOME}/.you}}/stack-sources}"
37
+
29
38
  # 4 loose skills that live in ~/.claude/skills/ but aren't in any repo
30
39
  LOOSE_SKILLS="agent-runtime-guard agent-stack-sync continue skill-governor"
31
40
 
@@ -180,6 +189,48 @@ mirror_loose_skills_from_repo() {
180
189
  done
181
190
  }
182
191
 
192
+ # ---------------------------------------------------------------------------
193
+ # Resolve the clone remote for a repo path (env map first, then built-in).
194
+ # Prints the URL, or nothing if no remote is known for that path.
195
+ # ---------------------------------------------------------------------------
196
+ repo_remote() {
197
+ local repo="$1"
198
+ # 1) env map
199
+ if [ -n "${SKILLSTACK_REPO_REMOTES:-}" ]; then
200
+ local pair
201
+ for pair in ${SKILLSTACK_REPO_REMOTES}; do
202
+ case "${pair}" in
203
+ "${repo}="*) printf '%s' "${pair#*=}"; return 0 ;;
204
+ esac
205
+ done
206
+ fi
207
+ # 2) per-user ~/.you/stack-sources file (abs_path=remote_url per line)
208
+ if [ -f "${STACK_SOURCES_FILE}" ]; then
209
+ local line key val
210
+ while IFS= read -r line; do
211
+ case "${line}" in ''|\#*) continue ;; esac
212
+ key="${line%%=*}"
213
+ val="${line#*=}"
214
+ # expand a leading ~ in the registered path
215
+ case "${key}" in "~/"*) key="${HOME}/${key#\~/}" ;; esac
216
+ if [ "${key}" = "${repo}" ] && [ -n "${val}" ]; then
217
+ printf '%s' "${val}"
218
+ return 0
219
+ fi
220
+ done < "${STACK_SOURCES_FILE}"
221
+ fi
222
+ printf ''
223
+ }
224
+
225
+ # Run a freshly-cloned repo's own setup so its symlinks/mirrors exist immediately.
226
+ hydrate_cloned_repo() {
227
+ local repo="$1"
228
+ if [ "${repo}" = "${AGENT_SHARED}" ] && [ -x "${repo}/bin/sync-agent-shared.sh" ]; then
229
+ log "Hydrating freshly-cloned agent-shared (instruction symlinks + agent mirrors)..."
230
+ "${repo}/bin/sync-agent-shared.sh" >>"${LOG_FILE}" 2>&1 || log_warn "sync-agent-shared.sh failed (non-fatal)"
231
+ fi
232
+ }
233
+
183
234
  # ---------------------------------------------------------------------------
184
235
  # SYNC ONE REPO
185
236
  # Returns 0 on success, 1 on non-fatal failure.
@@ -191,10 +242,26 @@ sync_repo() {
191
242
 
192
243
  log "=== Syncing repo: ${repo} ==="
193
244
 
194
- # Guard: must be a git repo
245
+ # Auto-clone if missing (fresh machine) so skills/stacks self-install.
195
246
  if [ ! -d "${repo}/.git" ]; then
196
- log_warn "Skipping ${repo}: not a git repository."
197
- return 1
247
+ local remote
248
+ remote="$(repo_remote "${repo}")"
249
+ if [ -z "${remote}" ]; then
250
+ log_warn "Skipping ${repo}: not a git repository and no known remote to clone."
251
+ return 1
252
+ fi
253
+ if is_dry; then
254
+ log_dry "Would clone ${remote} → ${repo}"
255
+ return 0
256
+ fi
257
+ log "Cloning ${remote} → ${repo} (missing on this machine)..."
258
+ mkdir -p "$(dirname "${repo}")"
259
+ if GIT_TERMINAL_PROMPT=0 git clone "${remote}" "${repo}" >>"${LOG_FILE}" 2>&1; then
260
+ log "Cloned ${repo_name}."
261
+ else
262
+ log_warn "Skipping ${repo}: clone of ${remote} failed (private/unreachable — ensure GitHub auth)."
263
+ return 1
264
+ fi
198
265
  fi
199
266
 
200
267
  # Guard: must not be mid-merge/rebase
@@ -308,13 +375,19 @@ main() {
308
375
  # Step 1: Mirror loose skills into agent-shared BEFORE syncing it
309
376
  mirror_loose_skills_to_repo
310
377
 
311
- # Step 2: Sync each repo
378
+ # Step 2: Sync each repo (auto-cloning any that are missing + registered).
312
379
  local agent_shared_synced=0
313
380
  for repo in ${SKILLSTACK_REPOS}; do
381
+ local was_missing=0
382
+ [ ! -d "${repo}/.git" ] && was_missing=1
314
383
  if sync_repo "${repo}"; then
315
384
  if [ "${repo}" = "${AGENT_SHARED}" ]; then
316
385
  agent_shared_synced=1
317
386
  fi
387
+ # On a fresh clone, run the repo's own setup so symlinks/mirrors exist now.
388
+ if [ "${was_missing}" -eq 1 ] && ! is_dry; then
389
+ hydrate_cloned_repo "${repo}"
390
+ fi
318
391
  fi
319
392
  done
320
393
 
@@ -326,6 +399,19 @@ main() {
326
399
  log_warn "Skipping reverse loose-skill mirror because agent-shared sync did not complete cleanly."
327
400
  fi
328
401
 
402
+ # Step 4: Ensure science-stack skills are symlinked into ~/.claude/skills/
403
+ # (idempotent; picks up any newly-pulled skills each sync). Only runs if a
404
+ # scistack checkout with its own sync script is present.
405
+ if [ -x "${SCISTACK}/bin/sync-to-claude.sh" ]; then
406
+ if is_dry; then
407
+ log_dry "Would run scistack sync-to-claude.sh + build-index.sh"
408
+ else
409
+ "${SCISTACK}/bin/sync-to-claude.sh" >>"${LOG_FILE}" 2>&1 || log_warn "scistack sync-to-claude.sh failed (non-fatal)"
410
+ [ -x "${SCISTACK}/bin/build-index.sh" ] && "${SCISTACK}/bin/build-index.sh" >>"${LOG_FILE}" 2>&1 || true
411
+ log "scistack science skills symlinked into ~/.claude/skills/."
412
+ fi
413
+ fi
414
+
329
415
  log "============================================================"
330
416
  log "skillstack-sync DONE [${mode}]"
331
417
  log "============================================================"