@jenga-ai/agent 1.0.1 → 1.1.1
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/README.md +10 -7
- package/agents/developer.md +82 -2
- package/agents/scrum-master.md +215 -21
- package/agents/tester.md +90 -8
- package/hooks/on_session_end.sh +171 -20
- package/mcp/router/embedder.js +1 -1
- package/mcp/training_runner/index.js +239 -0
- package/mcp/training_runner/package-lock.json +1065 -0
- package/mcp/training_runner/package.json +15 -0
- package/package.json +14 -16
- package/scripts/check-permission-level.sh +107 -0
- package/scripts/check-publicignore-match.sh +122 -0
- package/scripts/check-worktree-liveness.sh +193 -0
- package/scripts/generate-rapport-manifest.sh +43 -0
- package/scripts/idea_manager.sh +47 -0
- package/scripts/install-worktree-commit-guard.sh +134 -0
- package/scripts/jenga-permission-level-switch.sh +109 -0
- package/scripts/smoke-harness.sh +139 -0
- package/scripts/validate-board.sh +62 -0
- package/scripts/with-lock.sh +158 -0
- package/scripts/worktree-remove-guard.sh +204 -0
- package/skills/clearify/SKILL.md +52 -0
- package/skills/close-story/SKILL.md +203 -0
- package/skills/close-story/scripts/check-story-closeable.sh +195 -0
- package/skills/close-story/scripts/compute-scope-divergence.sh +128 -0
- package/skills/close-story/scripts/extract-diff-stats.sh +48 -0
- package/skills/close-story/scripts/extract-task-diff-stats.sh +97 -0
- package/skills/close-story/scripts/update-task-frontmatter.sh +103 -0
- package/skills/commit/SKILL.md +30 -3
- package/skills/distribute/CONFIG_SCHEMA.md +148 -0
- package/skills/distribute/SKILL.md +173 -0
- package/skills/distribute/scripts/check-version.sh +74 -0
- package/skills/distribute/scripts/commit-version-bump.sh +108 -0
- package/skills/distribute/scripts/distribute-changes.sh +381 -0
- package/skills/do/SKILL.md +352 -1
- package/skills/do/assets/intent-vs-diff-prompt.md +69 -0
- package/skills/doc/assets/path-objectives.yaml +13 -0
- package/skills/doc-sync/SKILL.md +16 -0
- package/skills/doc-sync/assets/doc_targets.md +11 -0
- package/skills/idea/SKILL.md +56 -0
- package/skills/idea/assets/idea_handoff_template.md +26 -0
- package/skills/idea/assets/idea_template.md +3 -0
- package/skills/init/SKILL.md +101 -7
- package/skills/init/assets/directory_structure.txt +1 -0
- package/skills/init/assets/strategy_stub_template.md +38 -0
- package/skills/init/assets/workflow_template.json +1 -1
- package/skills/init/scripts/apply-project-visibility.sh +176 -0
- package/skills/init/scripts/detect-existing-codebase.sh +166 -0
- package/skills/init/scripts/init.sh +35 -1
- package/skills/jenga/SKILL.md +206 -14
- package/skills/jenga/scripts/board-scan.sh +238 -0
- package/skills/jenga/scripts/cascade-resolve.sh +297 -0
- package/skills/jenga/scripts/render-confirmation.sh +679 -0
- package/skills/jenga/scripts/render-picker.sh +439 -0
- package/skills/jenga/scripts/resolve-id.sh +367 -0
- package/skills/jenga-permission-level/SKILL.md +81 -0
- package/skills/proceed/SKILL.md +1 -1
- package/skills/publish/SKILL.md +8 -5
- package/skills/publish/assets/ci-contract.md +2 -2
- package/skills/publish/assets/ownership-matrix.md +1 -1
- package/skills/publish/scripts/finalize_changelog.sh +115 -0
- package/skills/publish/scripts/generate_release_notes.sh +475 -28
- package/skills/publish/scripts/npm_ci_pipeline.sh +44 -6
- package/skills/publish/scripts/publish_deploy.sh +38 -8
- package/skills/publish/scripts/run_gates.sh +2 -2
- package/skills/reconcile/SKILL.md +117 -5
- package/skills/reconcile/scripts/detect-unlinked-code.sh +741 -0
- package/skills/skillify/assets/init-new/assets/directory_structure.txt +5 -1
- package/skills/spinoff/SKILL.md +12 -7
- package/skills/todo/SKILL.md +2 -0
- package/skills/uncharted/SKILL.md +711 -0
- package/skills/uncharted/assets/SEGMENT_PROPOSAL_TEMPLATE.md +129 -0
- package/skills/uncharted/assets/UNDERSTANDING_DOC_TEMPLATE.md +160 -0
- package/skills/uncharted/scripts/apply-subsystem-cap.sh +573 -0
- package/skills/uncharted/scripts/detect-dependencies.sh +732 -0
- package/skills/uncharted/scripts/detect-tests.sh +553 -0
- package/skills/uncharted/scripts/discover-subsystems.sh +1029 -0
- package/skills/uncharted/scripts/enumerate-target.sh +470 -0
- package/skills/uncharted/scripts/import-source.sh +517 -0
- package/skills/uncharted/scripts/inspect-provenance.sh +573 -0
- package/skills/uncharted/scripts/resolve-segment-target.sh +640 -0
- package/skills/uncharted/scripts/run-engine.sh +655 -0
- package/skills/uncharted/scripts/validate-proposed-items.sh +125 -0
- package/skills/uncharted/scripts/write-backfilled-epics.sh +498 -0
- package/skills/wtf/SKILL.md +20 -0
- package/templates/CHANGELOG_TEMPLATE.md +13 -0
- package/templates/PROBLEM_RAPPORT_TEMPLATE.md +4 -1
- package/templates/SCRUM_BOARD_SCHEMA.md +206 -10
- package/templates/permission-levels/README.md +73 -0
- package/templates/permission-levels/level-1-locked.json +71 -0
- package/templates/permission-levels/level-2-guarded.json +64 -0
- package/templates/permission-levels/level-3-standard.json +62 -0
- package/templates/permission-levels/level-4-elevated.json +60 -0
- package/templates/permission-levels/level-5-unrestricted.json +58 -0
- package/skills/convert/SKILL.md +0 -124
- package/skills/convert/convert_cli.py +0 -235
- package/skills/convert/tests/sample.csv +0 -4
- package/skills/convert/tests/sample.json +0 -5
- package/skills/convert/tests/sample.jsonl +0 -3
- package/skills/convert/tests/sample.yaml +0 -18
- package/skills/convert/tests/sample_obj.csv +0 -2
- package/skills/convert/tests/sample_obj.json +0 -9
- package/skills/mirror-public/SKILL.md +0 -237
- package/skills/mirror-public/assets/config.json +0 -5
- package/skills/mirror-public/scripts/mirror.sh +0 -374
- package/skills/self-sync/SKILL.md +0 -73
- package/skills/self-sync/scripts/run.js +0 -136
- package/skills/train/SKILL.md +0 -116
- package/skills/train/assets/dashboard-templates/classifiers.html +0 -106
- package/skills/train/assets/dashboard-templates/nlp.html +0 -102
- package/skills/train/assets/dashboard-templates/transformers.html +0 -98
- package/skills/train/assets/results-parsers/__init__.py +0 -9
- package/skills/train/assets/results-parsers/classifiers.py +0 -84
- package/skills/train/assets/results-parsers/nlp.py +0 -88
- package/skills/train/assets/results-parsers/reporter.py +0 -154
- package/skills/train/assets/results-parsers/transformers.py +0 -120
- package/skills/train/train_cli.py +0 -786
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: distribute
|
|
3
|
+
description: Distribute JengaAgent framework files from this private monorepo to one or more consuming projects via the local filesystem. Manages release type selection, version bumping, dry-run preview, per-target file copy, and a post-distribution git commit.
|
|
4
|
+
keywords:
|
|
5
|
+
- distribute
|
|
6
|
+
- private distribution
|
|
7
|
+
- filesystem distribute
|
|
8
|
+
- framework update
|
|
9
|
+
- version bump
|
|
10
|
+
- distribute to projects
|
|
11
|
+
examples:
|
|
12
|
+
- "/distribute"
|
|
13
|
+
- "/distribute /path/to/consuming-project"
|
|
14
|
+
- "/distribute --dry-run"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Distribute
|
|
18
|
+
|
|
19
|
+
Copies JengaAgent framework files from this monorepo to all active consuming projects registered in `distribute.config.json`. Manages the full version lifecycle: release type selection, `package.json` version bump, dry-run preview, per-target file copy, and a final git commit of the version bump.
|
|
20
|
+
|
|
21
|
+
Distinct from `/self-sync` (which mirrors root → in-repo `.claude/.agents/`) and `/mirror-public` (which syncs to the public GitHub repo). Do not call either of those skills from within this flow.
|
|
22
|
+
|
|
23
|
+
## Instructions
|
|
24
|
+
|
|
25
|
+
Follow these steps in order. Do not skip any step.
|
|
26
|
+
|
|
27
|
+
### Step 1 — Path argument check
|
|
28
|
+
|
|
29
|
+
If the user passed a path argument (e.g. `/distribute /path/to/project`):
|
|
30
|
+
|
|
31
|
+
1. Verify the path exists on disk. If it does not, print an error and halt.
|
|
32
|
+
2. Read `distribute.config.json` at the repo root.
|
|
33
|
+
3. Derive `name` from the directory name of the path (e.g. `my-project` from `/home/user/my-project`).
|
|
34
|
+
4. Add a new entry to the `targets` array:
|
|
35
|
+
```json
|
|
36
|
+
{ "name": "<derived-name>", "path": "<absolute-or-relative-path>", "active": true }
|
|
37
|
+
```
|
|
38
|
+
5. Write the updated `distribute.config.json`.
|
|
39
|
+
6. Confirm the addition to the user: `Added <name> (<path>) to distribute.config.json.`
|
|
40
|
+
|
|
41
|
+
If no path argument was passed, skip this step.
|
|
42
|
+
|
|
43
|
+
### Step 2 — Release type prompt
|
|
44
|
+
|
|
45
|
+
Ask the user to choose a release type. Present all four options:
|
|
46
|
+
|
|
47
|
+
| Type | Effect |
|
|
48
|
+
|------|--------|
|
|
49
|
+
| `major` | Breaking change. Bumps major version in `package.json`. Distributes to ALL active targets. |
|
|
50
|
+
| `minor` | New feature. Bumps minor version in `package.json`. Distributes to ALL active targets. |
|
|
51
|
+
| `patch` | Bug fix. Bumps patch version in `package.json`. Distributes to ALL active targets. |
|
|
52
|
+
| `amend` | No version bump. Distributes only to targets whose `jenga.config.json` version is behind the current `package.json` version, or targets that have no `jenga.config.json`. |
|
|
53
|
+
|
|
54
|
+
Wait for the user's answer before continuing.
|
|
55
|
+
|
|
56
|
+
### Step 3 — Config validation
|
|
57
|
+
|
|
58
|
+
Read `distribute.config.json`.
|
|
59
|
+
|
|
60
|
+
For each entry in `targets`:
|
|
61
|
+
- If `active` is `false`: print `Skipping <name> — inactive.` Do not include it in the distribution run.
|
|
62
|
+
- If the `path` does not exist on disk: print `Skipping <name> — path not found: <path>.` Do not include it in the distribution run.
|
|
63
|
+
- If release type is `amend`: run `bash skills/distribute/scripts/check-version.sh <path>`.
|
|
64
|
+
- Exit 0 → include the target.
|
|
65
|
+
- Exit 1 → print `Skipping <name> — already up to date.` Do not include it in the distribution run (record it in the final report as "already up to date").
|
|
66
|
+
- Exit 2 → print `Skipping <name> — invalid path or config.` Do not include it.
|
|
67
|
+
- Otherwise (major / minor / patch): include all active, path-valid targets.
|
|
68
|
+
|
|
69
|
+
Print the final list of targets that will receive distribution. If the list is empty, print `No targets eligible for distribution.` and halt.
|
|
70
|
+
|
|
71
|
+
### Step 4 — Version bump (non-amend only)
|
|
72
|
+
|
|
73
|
+
Skip this step entirely for `amend`.
|
|
74
|
+
|
|
75
|
+
For `major`, `minor`, or `patch`:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm version <type> --no-git-tag-version
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Run this at the monorepo root. If the command fails (non-zero exit), print the error, and halt — do not proceed to distribution with an unbumped or failed version.
|
|
82
|
+
|
|
83
|
+
On success, read the new version from `package.json` and print: `Version bumped to <new-version>.`
|
|
84
|
+
|
|
85
|
+
### Step 5 — Dry-run preview
|
|
86
|
+
|
|
87
|
+
For each eligible target (from Step 3), run:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bash skills/distribute/scripts/distribute-changes.sh <project_path> --dry-run
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Display the full output for each target. Then ask the user:
|
|
94
|
+
|
|
95
|
+
`Proceed with distribution to the above targets? [y/N]`
|
|
96
|
+
|
|
97
|
+
Wait for confirmation. If the user does not confirm, halt without making any changes. If a version bump was already applied in Step 4 and the user aborts here, inform them that `package.json` has been bumped but not committed, and they must either re-run `/distribute` or revert manually.
|
|
98
|
+
|
|
99
|
+
### Step 6 — Execute distribution
|
|
100
|
+
|
|
101
|
+
For each eligible target in sequence:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
bash skills/distribute/scripts/distribute-changes.sh <project_path>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Record the exit code and any output. If a target fails (non-zero exit), record the failure and continue to the next target. Do not abort the run on partial failure.
|
|
108
|
+
|
|
109
|
+
### Step 7 — Report results
|
|
110
|
+
|
|
111
|
+
Print a per-target summary:
|
|
112
|
+
|
|
113
|
+
**Succeeded:**
|
|
114
|
+
- List each target name and the version distributed (read from `package.json`)
|
|
115
|
+
|
|
116
|
+
**Failed:**
|
|
117
|
+
- List each target name and the error output; note that manual retry is required
|
|
118
|
+
|
|
119
|
+
**Already up to date (amend mode only):**
|
|
120
|
+
- List each target skipped due to version match
|
|
121
|
+
|
|
122
|
+
**Skipped:**
|
|
123
|
+
- List inactive or missing-path targets from Step 3
|
|
124
|
+
|
|
125
|
+
### Step 8 — Commit version bump (non-amend only, only if at least one target succeeded)
|
|
126
|
+
|
|
127
|
+
Skip this step for `amend`. Skip this step if no targets succeeded in Step 6.
|
|
128
|
+
|
|
129
|
+
Call:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
bash skills/distribute/scripts/commit-version-bump.sh
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Report the resulting commit SHA to the user.
|
|
136
|
+
|
|
137
|
+
If at least one target failed and at least one succeeded, note that the version bump commit reflects the distributed version; failed targets need manual retry and will receive the same version on retry.
|
|
138
|
+
|
|
139
|
+
### Step 9 — Do not call downstream skills
|
|
140
|
+
|
|
141
|
+
Do not invoke `/self-sync` or `/mirror-public` at any point in this flow. They are separate skills with separate responsibilities and separate triggers.
|
|
142
|
+
|
|
143
|
+
## Scripts
|
|
144
|
+
|
|
145
|
+
| Script | Purpose |
|
|
146
|
+
|--------|---------|
|
|
147
|
+
| `skills/distribute/scripts/distribute-changes.sh <path> [--dry-run]` | Copy framework files to a single consuming project |
|
|
148
|
+
| `skills/distribute/scripts/commit-version-bump.sh` | Commit the `package.json` version bump |
|
|
149
|
+
| `skills/distribute/scripts/check-version.sh <path>` | Amend mode: exits 0 if target needs update, 1 if up to date, 2 if invalid |
|
|
150
|
+
|
|
151
|
+
## Config
|
|
152
|
+
|
|
153
|
+
`distribute.config.json` at the repo root is the registry of consuming projects.
|
|
154
|
+
|
|
155
|
+
Schema reference: `skills/distribute/CONFIG_SCHEMA.md`
|
|
156
|
+
|
|
157
|
+
Each target entry:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"name": "my-project",
|
|
162
|
+
"path": "/absolute/or/relative/path/to/project",
|
|
163
|
+
"active": true
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Guard Rails
|
|
168
|
+
|
|
169
|
+
- Never call `/self-sync` or `/mirror-public` from this skill.
|
|
170
|
+
- Never inline file copy logic — all filesystem work goes through `distribute-changes.sh`.
|
|
171
|
+
- Never commit anything other than `package.json` via `commit-version-bump.sh`.
|
|
172
|
+
- Never skip the dry-run confirmation gate — even in non-interactive contexts, print the dry-run output and require explicit `y` from the user.
|
|
173
|
+
- Never proceed past Step 4 if `npm version` fails.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# check-version.sh <project_path>
|
|
3
|
+
#
|
|
4
|
+
# Compares the monorepo version (package.json) against the target project's
|
|
5
|
+
# jenga.config.json version field.
|
|
6
|
+
#
|
|
7
|
+
# Exit codes:
|
|
8
|
+
# 0 — target needs an update: jenga.config.json absent OR versions differ
|
|
9
|
+
# 1 — already up to date: versions match exactly
|
|
10
|
+
# 2 — invalid input: <project_path> missing or monorepo package.json missing
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
# Resolve monorepo root from this script's own location (two levels up)
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
|
+
MONOREPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
19
|
+
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
# Validate arguments
|
|
22
|
+
# ---------------------------------------------------------------------------
|
|
23
|
+
if [[ $# -ne 1 ]]; then
|
|
24
|
+
echo "Usage: check-version.sh <project_path>" >&2
|
|
25
|
+
exit 2
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
PROJECT_PATH="$1"
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------------------
|
|
31
|
+
# Validate paths
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
PACKAGE_JSON="${MONOREPO_ROOT}/package.json"
|
|
34
|
+
|
|
35
|
+
if [[ ! -d "$PROJECT_PATH" ]]; then
|
|
36
|
+
echo "check-version: project path does not exist: ${PROJECT_PATH}" >&2
|
|
37
|
+
exit 2
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
if [[ ! -f "$PACKAGE_JSON" ]]; then
|
|
41
|
+
echo "check-version: monorepo package.json not found at ${PACKAGE_JSON}" >&2
|
|
42
|
+
exit 2
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# ---------------------------------------------------------------------------
|
|
46
|
+
# Read monorepo version
|
|
47
|
+
# ---------------------------------------------------------------------------
|
|
48
|
+
MONOREPO_VERSION="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('${PACKAGE_JSON}','utf8')).version || '')")"
|
|
49
|
+
|
|
50
|
+
if [[ -z "$MONOREPO_VERSION" ]]; then
|
|
51
|
+
echo "check-version: could not read version from ${PACKAGE_JSON}" >&2
|
|
52
|
+
exit 2
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# ---------------------------------------------------------------------------
|
|
56
|
+
# Read target version (absent jenga.config.json => needs update)
|
|
57
|
+
# ---------------------------------------------------------------------------
|
|
58
|
+
JENGA_CONFIG="${PROJECT_PATH}/jenga.config.json"
|
|
59
|
+
|
|
60
|
+
if [[ ! -f "$JENGA_CONFIG" ]]; then
|
|
61
|
+
# No config file — target needs to be initialised
|
|
62
|
+
exit 0
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
TARGET_VERSION="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('${JENGA_CONFIG}','utf8')).version || '')")"
|
|
66
|
+
|
|
67
|
+
# ---------------------------------------------------------------------------
|
|
68
|
+
# Compare using exact string equality
|
|
69
|
+
# ---------------------------------------------------------------------------
|
|
70
|
+
if [[ "$MONOREPO_VERSION" == "$TARGET_VERSION" ]]; then
|
|
71
|
+
exit 1 # Already up to date
|
|
72
|
+
else
|
|
73
|
+
exit 0 # Needs update
|
|
74
|
+
fi
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# commit-version-bump.sh — Commit the package.json version bump as a standalone git commit.
|
|
3
|
+
#
|
|
4
|
+
# Called by the /distribute skill after a successful non-amend distribution run.
|
|
5
|
+
# No arguments. Reads the new version from package.json at the monorepo root.
|
|
6
|
+
#
|
|
7
|
+
# Behaviour:
|
|
8
|
+
# 1. Resolve monorepo root from this script's own location (two levels up from scripts/).
|
|
9
|
+
# 2. Read the version field from <monorepo_root>/package.json.
|
|
10
|
+
# 3. Stage only package.json: git add package.json.
|
|
11
|
+
# 4. If nothing changed, exit 0 with an informational message.
|
|
12
|
+
# 5. Create commit: "chore: bump version to <version>".
|
|
13
|
+
# 6. Exit 0 on success, non-zero with a descriptive message on failure.
|
|
14
|
+
#
|
|
15
|
+
# Exit codes:
|
|
16
|
+
# 0 success (commit created, or nothing to commit)
|
|
17
|
+
# 1 fatal error (package.json missing, version unreadable, git commit failed)
|
|
18
|
+
|
|
19
|
+
set -uo pipefail
|
|
20
|
+
|
|
21
|
+
# ---------------------------------------------------------------------------
|
|
22
|
+
# Path resolution
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
+
# scripts/ -> distribute/ -> skills/ -> <monorepo_root>
|
|
27
|
+
MONOREPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
28
|
+
PACKAGE_JSON="$MONOREPO_ROOT/package.json"
|
|
29
|
+
|
|
30
|
+
# ---------------------------------------------------------------------------
|
|
31
|
+
# Helpers
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
log_info() {
|
|
35
|
+
printf '→ %s\n' "$1"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fail() {
|
|
39
|
+
printf 'commit-version-bump: error: %s\n' "$1" >&2
|
|
40
|
+
exit 1
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# ---------------------------------------------------------------------------
|
|
44
|
+
# Validate prerequisites
|
|
45
|
+
# ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
if [[ ! -f "$PACKAGE_JSON" ]]; then
|
|
48
|
+
fail "package.json not found at $PACKAGE_JSON"
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if ! command -v node >/dev/null 2>&1; then
|
|
52
|
+
fail "node is required to read package.json but was not found in PATH"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# ---------------------------------------------------------------------------
|
|
56
|
+
# Read version from package.json
|
|
57
|
+
# ---------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
VERSION="$(node -p "require('$PACKAGE_JSON').version" 2>/dev/null)" || \
|
|
60
|
+
fail "Failed to read version from $PACKAGE_JSON"
|
|
61
|
+
|
|
62
|
+
if [[ -z "$VERSION" ]]; then
|
|
63
|
+
fail "version field is empty or missing in $PACKAGE_JSON"
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
log_info "Version read from package.json: $VERSION"
|
|
67
|
+
|
|
68
|
+
# ---------------------------------------------------------------------------
|
|
69
|
+
# Stage package.json
|
|
70
|
+
# ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
git -C "$MONOREPO_ROOT" add "$PACKAGE_JSON" || fail "git add failed for $PACKAGE_JSON"
|
|
73
|
+
|
|
74
|
+
# ---------------------------------------------------------------------------
|
|
75
|
+
# Check whether there is anything to commit
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
if git -C "$MONOREPO_ROOT" diff --cached --quiet; then
|
|
79
|
+
log_info "Nothing to commit — package.json is already clean"
|
|
80
|
+
exit 0
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
# ---------------------------------------------------------------------------
|
|
84
|
+
# Verify only package.json is staged (safety check)
|
|
85
|
+
# ---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
STAGED_FILES="$(git -C "$MONOREPO_ROOT" diff --cached --name-only)"
|
|
88
|
+
STAGED_COUNT="$(printf '%s\n' "$STAGED_FILES" | grep -c .)"
|
|
89
|
+
|
|
90
|
+
if [[ "$STAGED_COUNT" -gt 1 ]]; then
|
|
91
|
+
fail "Unexpected staged files detected. Only package.json should be staged. Found:
|
|
92
|
+
$STAGED_FILES"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# ---------------------------------------------------------------------------
|
|
96
|
+
# Commit
|
|
97
|
+
# ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
COMMIT_MSG="chore: bump version to $VERSION"
|
|
100
|
+
|
|
101
|
+
log_info "Creating commit: $COMMIT_MSG"
|
|
102
|
+
|
|
103
|
+
if ! git -C "$MONOREPO_ROOT" commit -m "$COMMIT_MSG"; then
|
|
104
|
+
fail "git commit failed for version bump to $VERSION"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
log_info "Committed successfully: $COMMIT_MSG"
|
|
108
|
+
exit 0
|