gitea-cli-skill 0.2.0 → 0.3.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/assets/SKILL.md CHANGED
@@ -83,8 +83,10 @@ Destructive ops: always `list`/`get` first, then `--force`. Deleted resources ca
83
83
 
84
84
  ## On-Demand Reference
85
85
 
86
- For full command flags and detailed workflow steps, read the reference file:
86
+ For full command flags and detailed workflow steps, read:
87
87
 
88
88
  ```
89
- ~/.claude/skills/gitea-cli/REFERENCE.md
89
+ references/command-reference.md
90
90
  ```
91
+
92
+ Located in the same skill directory as this file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitea-cli-skill",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Install gitea-cli as a Claude Code skill",
5
5
  "bin": {
6
6
  "gitea-cli-skill": "src/index.js"
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ const GITEA_HOST = 'https://x.xgit.pro';
12
12
  const GITEA_OWNER = 'chenqi';
13
13
  const GITEA_REPO = 'git-cli';
14
14
  const SKILL_NAME = 'gitea-cli';
15
+ const PKG_VERSION = require(path.resolve(__dirname, '..', 'package.json')).version;
15
16
 
16
17
  // ── Platform definitions ────────────────────────────────────────────────────
17
18
 
@@ -158,6 +159,23 @@ function configureContext({ giteaCliBin, host, token, contextName, defaultOwner,
158
159
  execSync(cmdArgs.join(' '), { stdio: 'inherit', timeout: 10000 });
159
160
  }
160
161
 
162
+ // ── Version consistency check ────────────────────────────────────────────────
163
+
164
+ function checkVersionConsistency(binaryPath) {
165
+ if (!fs.existsSync(binaryPath)) return;
166
+ try {
167
+ const raw = execSync(`"${binaryPath}" --version`, { encoding: 'utf-8', timeout: 5000 }).trim();
168
+ // Parse version from output like "gitea-cli version 0.3.0" or just "0.3.0"
169
+ const match = raw.match(/(\d+\.\d+\.\d+)/);
170
+ if (!match) return;
171
+ const binVersion = match[1];
172
+ if (binVersion !== PKG_VERSION) {
173
+ console.warn(` ⚠ Version mismatch: npm=${PKG_VERSION}, binary=${binVersion}`);
174
+ console.warn(' Run `npx gitea-cli-skill@latest update` to sync.');
175
+ }
176
+ } catch { /* non-blocking */ }
177
+ }
178
+
161
179
  // ── Install command ─────────────────────────────────────────────────────────
162
180
 
163
181
  async function install(args) {
@@ -170,18 +188,26 @@ async function install(args) {
170
188
 
171
189
  console.log(`Installing gitea-cli skill (${osArch.os}-${osArch.arch}) to ${skillDir}...`);
172
190
 
173
- // 1. Copy SKILL.md and REFERENCE.md
191
+ // 1. Copy SKILL.md and references/
174
192
  fs.mkdirSync(skillDir, { recursive: true });
175
193
  const srcSkill = path.resolve(__dirname, '..', 'assets', 'SKILL.md');
176
194
  const destSkill = path.join(skillDir, 'SKILL.md');
177
195
  fs.copyFileSync(srcSkill, destSkill);
178
196
  console.log(` SKILL.md -> ${destSkill}`);
179
197
 
180
- const srcRef = path.resolve(__dirname, '..', 'assets', 'REFERENCE.md');
181
- const destRef = path.join(skillDir, 'REFERENCE.md');
198
+ const srcRef = path.resolve(__dirname, '..', 'assets', 'references', 'command-reference.md');
199
+ const destRef = path.join(skillDir, 'references', 'command-reference.md');
182
200
  if (fs.existsSync(srcRef)) {
201
+ fs.mkdirSync(path.dirname(destRef), { recursive: true });
183
202
  fs.copyFileSync(srcRef, destRef);
184
- console.log(` REFERENCE.md -> ${destRef}`);
203
+ console.log(` references/command-reference.md -> ${destRef}`);
204
+ }
205
+
206
+ // Cleanup: remove legacy REFERENCE.md from old location
207
+ const legacyRef = path.join(skillDir, 'REFERENCE.md');
208
+ if (fs.existsSync(legacyRef)) {
209
+ fs.unlinkSync(legacyRef);
210
+ console.log(' Removed legacy REFERENCE.md');
185
211
  }
186
212
 
187
213
  // 2. Check existing binary
@@ -214,6 +240,9 @@ async function install(args) {
214
240
  }
215
241
  }
216
242
 
243
+ // 4. Version consistency check
244
+ checkVersionConsistency(destBinary);
245
+
217
246
  console.log(`\nDone!`);
218
247
  }
219
248
 
@@ -331,6 +360,58 @@ async function addContext(args) {
331
360
  configureContext({ giteaCliBin, host, token, contextName, defaultOwner, defaultRepo });
332
361
  }
333
362
 
363
+ // ── Update command ────────────────────────────────────────────────────────────
364
+
365
+ async function update(args) {
366
+ const { host: explicitHost, platform: platformName, target: targetPath, local: localDir } = args;
367
+ const giteaHost = explicitHost || GITEA_HOST;
368
+ const osArch = detectOSArch();
369
+ const skillDir = resolveSkillDir(platformName, targetPath);
370
+ const scriptsDir = path.join(skillDir, 'scripts', `${osArch.os}-${osArch.arch}`);
371
+
372
+ console.log(`Updating gitea-cli skill (${osArch.os}-${osArch.arch}) at ${skillDir}...`);
373
+
374
+ // 1. Refresh SKILL.md and references/
375
+ const srcSkill = path.resolve(__dirname, '..', 'assets', 'SKILL.md');
376
+ const destSkill = path.join(skillDir, 'SKILL.md');
377
+ if (fs.existsSync(srcSkill)) {
378
+ fs.mkdirSync(skillDir, { recursive: true });
379
+ fs.copyFileSync(srcSkill, destSkill);
380
+ console.log(` SKILL.md -> ${destSkill}`);
381
+ }
382
+
383
+ const srcRef = path.resolve(__dirname, '..', 'assets', 'references', 'command-reference.md');
384
+ const destRef = path.join(skillDir, 'references', 'command-reference.md');
385
+ if (fs.existsSync(srcRef)) {
386
+ fs.mkdirSync(path.dirname(destRef), { recursive: true });
387
+ fs.copyFileSync(srcRef, destRef);
388
+ console.log(` references/command-reference.md -> ${destRef}`);
389
+ }
390
+
391
+ // Cleanup: remove legacy REFERENCE.md from old location
392
+ const legacyRef = path.join(skillDir, 'REFERENCE.md');
393
+ if (fs.existsSync(legacyRef)) {
394
+ fs.unlinkSync(legacyRef);
395
+ console.log(' Removed legacy REFERENCE.md');
396
+ }
397
+
398
+ // 2. Re-download / re-copy binary (always overwrite)
399
+ const binaryName = osArch.os === 'windows' ? 'gitea-cli.exe' : 'gitea-cli';
400
+ const destBinary = path.join(scriptsDir, binaryName);
401
+
402
+ if (localDir) {
403
+ installFromLocal(localDir, scriptsDir, destBinary, osArch);
404
+ } else {
405
+ const token = process.env.GITEA_TOKEN || null;
406
+ await installFromRelease(giteaHost, token, scriptsDir, destBinary, osArch);
407
+ }
408
+
409
+ // 3. Version consistency check
410
+ checkVersionConsistency(destBinary);
411
+
412
+ console.log('\nDone! Configuration preserved.');
413
+ }
414
+
334
415
  // ── CLI ──────────────────────────────────────────────────────────────────────
335
416
 
336
417
  function parseArgs(argv) {
@@ -363,10 +444,12 @@ function printHelp() {
363
444
 
364
445
  Usage:
365
446
  npx gitea-cli-skill init [flags] # Install + configure
447
+ npx gitea-cli-skill update [flags] # Refresh binary + docs
366
448
  gitea-cli-skill add context [flags] # Update context only
367
449
 
368
450
  Commands:
369
451
  init Install skill (binary + SKILL.md) and optionally configure context
452
+ update Refresh binary and SKILL.md/references/ (keeps config)
370
453
  add context Add or update a Gitea API context (requires --token)
371
454
 
372
455
  Flags (init):
@@ -380,6 +463,12 @@ Flags (init):
380
463
  --default-repo <repo> Default repo for auto-config (optional)
381
464
  --force Overwrite existing binary
382
465
 
466
+ Flags (update):
467
+ --host <url> Gitea host URL (default: ${GITEA_HOST})
468
+ --local <dir> Update from local goreleaser dist directory (skip download)
469
+ --platform <name> Target AI platform (default: claude)
470
+ --target <path> Custom install directory (overrides --platform)
471
+
383
472
  Flags (add context):
384
473
  --name <name> Context name (default: "default")
385
474
  --host <url> Gitea host URL (required)
@@ -404,6 +493,12 @@ Examples:
404
493
  # Install only (public repo, no token needed)
405
494
  npx gitea-cli-skill init
406
495
 
496
+ # Update binary and docs after new release
497
+ npx gitea-cli-skill update
498
+
499
+ # Update from local build
500
+ npx gitea-cli-skill update --local ../dist
501
+
407
502
  # Update context later
408
503
  gitea-cli-skill add context --host https://gitea.example.com --token new-token
409
504
 
@@ -428,6 +523,13 @@ async function main() {
428
523
  process.exit(1);
429
524
  }
430
525
  await install(args);
526
+ } else if (args.command === 'update') {
527
+ if (args.platform && !PLATFORMS[args.platform] && !args.target) {
528
+ console.error(`Unknown platform: ${args.platform}`);
529
+ console.error(`Available: ${Object.keys(PLATFORMS).join(', ')}, or use --target for custom path.`);
530
+ process.exit(1);
531
+ }
532
+ await update(args);
431
533
  } else if (args.command === 'add' && args.subcommand === 'context') {
432
534
  await addContext(args);
433
535
  } else {