@erclx/aitk 2.0.0 → 2.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aitk",
3
3
  "description": "Automated governance, versioning, and discovery tools for Claude Code.",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "author": {
6
6
  "name": "Eric Le",
7
7
  "url": "https://github.com/erclx"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@erclx/aitk",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "description": "Infrastructure and quality tooling for developer workflows",
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -15,8 +15,13 @@ require_sandbox_anchor_config() {
15
15
  fi
16
16
  }
17
17
 
18
+ resolve_sandbox_anchor_repo() {
19
+ printf '%s\n' "${1:-${ANCHOR_REPO:-}}"
20
+ }
21
+
18
22
  sandbox_anchor_url() {
19
- local repo_name="${1:-${ANCHOR_REPO:-}}"
23
+ local repo_name
24
+ repo_name="$(resolve_sandbox_anchor_repo "$@")"
20
25
 
21
26
  if [ -z "$repo_name" ] || [ -z "${GITHUB_ORG:-}" ]; then
22
27
  log_error "sandbox_anchor_url needs GITHUB_ORG and a repository name. Call require_sandbox_anchor_config first."
@@ -52,7 +57,7 @@ configure_sandbox_git_identity() {
52
57
 
53
58
  # Every scenario that needs a remote points at the same throwaway repository, so
54
59
  # the name lives here rather than in each one.
55
- SANDBOX_ANCHOR_REPO="toolkit-sandbox"
60
+ SANDBOX_ANCHOR_REPO="aitk-sandbox"
56
61
 
57
62
  # A scenario calls this from its own use_anchor hook rather than this file
58
63
  # defining the hook. manage-sandbox.sh keys off `type -t use_anchor`, so
@@ -62,11 +67,58 @@ use_sandbox_anchor() {
62
67
  export ANCHOR_REPO="${1:-$SANDBOX_ANCHOR_REPO}"
63
68
  }
64
69
 
70
+ # gh answers an absent repository and an unreachable host with the same exit
71
+ # status, so the 404 is the only thing separating them. Anything else is a
72
+ # network or credential fault, where creating a repository would be the wrong
73
+ # answer and would fail for the same reason the read did.
74
+ ensure_sandbox_anchor_repo() {
75
+ local repo_name gh_error
76
+
77
+ repo_name="$(resolve_sandbox_anchor_repo "$@")"
78
+
79
+ if [ -z "$repo_name" ] || [ -z "${GITHUB_ORG:-}" ]; then
80
+ log_error "ensure_sandbox_anchor_repo needs GITHUB_ORG and a repository name. Call require_sandbox_anchor_config first."
81
+ fi
82
+
83
+ if gh_error="$(gh api "repos/${GITHUB_ORG}/${repo_name}" --silent 2>&1)"; then
84
+ return 0
85
+ fi
86
+
87
+ case "$gh_error" in
88
+ *"HTTP 404"*) ;;
89
+ *) log_error "Cannot reach ${GITHUB_ORG}/${repo_name}: ${gh_error}" ;;
90
+ esac
91
+
92
+ # An absent anchor is nearly always a wrong GITHUB_ORG or a rename nobody
93
+ # performed, and provisioning stages a fixture rather than cloning while every
94
+ # scenario force-pushes to main, so a repository created here would carry all
95
+ # nine to a pass against something that is not the anchor. Refusing is the safe
96
+ # default and creating is the opt-in, the shape `aitk tooling sync --write`
97
+ # already sets. `aitk records push` refuses outright for the reason
98
+ # `.claude/context/development/scratch.md` records, so the two still differ.
99
+ # The sibling SANDBOX_ flags are presence tests, so any non-empty value turns
100
+ # them on. This one allowlists instead, because a presence test would have
101
+ # SANDBOX_ANCHOR_CREATE=false provisioning a repository. Both spellings are
102
+ # accepted so the `true` those siblings are set to does not land on a refusal.
103
+ case "${SANDBOX_ANCHOR_CREATE:-}" in
104
+ 1 | true) ;;
105
+ *) log_error "${GITHUB_ORG}/${repo_name} does not exist. Check GITHUB_ORG and whether a rename is pending, then create it with 'gh repo create ${GITHUB_ORG}/${repo_name} --private' or re-run with SANDBOX_ANCHOR_CREATE=true." ;;
106
+ esac
107
+
108
+ log_warn "${GITHUB_ORG}/${repo_name} does not exist and SANDBOX_ANCHOR_CREATE is set. Creating it as private."
109
+ if ! gh_error="$(gh repo create "${GITHUB_ORG}/${repo_name}" --private 2>&1)"; then
110
+ log_error "Could not create ${GITHUB_ORG}/${repo_name}: ${gh_error}"
111
+ fi
112
+ log_info "Created ${GITHUB_ORG}/${repo_name} as a private repository."
113
+ }
114
+
65
115
  # A remote is useless without an author, so the scenarios that reach one always
66
116
  # configure both. configure_sandbox_git_identity stays callable on its own for
67
- # the scenarios that never push. The remove keeps this idempotent against a
68
- # sandbox tree that already carries an origin.
117
+ # the scenarios that never push. The probe runs first so an absent remote is
118
+ # reported before the scenario stages anything. The remove keeps this idempotent
119
+ # against a sandbox tree that already carries an origin.
69
120
  configure_sandbox_anchor_remote() {
121
+ ensure_sandbox_anchor_repo "$@"
70
122
  configure_sandbox_git_identity
71
123
  git remote remove origin 2>/dev/null || true
72
124
  git remote add origin "$(sandbox_anchor_url "$@")"