agent-package-manager 0.5.0 → 0.5.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/cli-contract.yaml CHANGED
@@ -337,6 +337,45 @@ commandSets:
337
337
  sideEffects:
338
338
  - git_fetch
339
339
 
340
+ # ── list ───────────────────────────────────────────
341
+ list:
342
+ summary: List installed packages and their status.
343
+ description: >-
344
+ Shows all installed packages with their current version,
345
+ registry, and whether a newer version is available.
346
+ When the registry is unreachable, only local information
347
+ is displayed with a warning.
348
+ usage:
349
+ - agent-pkg list
350
+ - agent-pkg list --json
351
+
352
+ options:
353
+ - name: json
354
+ description: Output in machine-readable JSON format.
355
+ schema:
356
+ type: boolean
357
+ default: false
358
+
359
+ exits:
360
+ "0":
361
+ description: List displayed successfully.
362
+ stdout:
363
+ format: json
364
+ schema:
365
+ $ref: "#/components/schemas/ListResult"
366
+
367
+ "1":
368
+ description: >-
369
+ List failed — config or lock file missing.
370
+ stderr:
371
+ format: text
372
+
373
+ x-agent:
374
+ riskLevel: none
375
+ requiresConfirmation: false
376
+ idempotent: true
377
+ sideEffects: []
378
+
340
379
  # ── check ──────────────────────────────────────────
341
380
  check:
342
381
  summary: Run full verification pipeline for CI.
@@ -572,6 +611,38 @@ components:
572
611
  type: string
573
612
  description: Human-readable detail.
574
613
 
614
+ ListResult:
615
+ type: object
616
+ required: [packages]
617
+ properties:
618
+ packages:
619
+ type: array
620
+ items:
621
+ $ref: "#/components/schemas/ListPackage"
622
+
623
+ ListPackage:
624
+ type: object
625
+ required: [name, version, registry]
626
+ properties:
627
+ name:
628
+ type: string
629
+ description: Package name.
630
+ version:
631
+ type: string
632
+ description: Currently installed version.
633
+ registry:
634
+ type: string
635
+ description: Registry identifier.
636
+ latestVersion:
637
+ type: string
638
+ description: Latest version available in the registry.
639
+ outdated:
640
+ type: boolean
641
+ description: Whether a newer version is available.
642
+ installedTo:
643
+ type: string
644
+ description: Installation directory path.
645
+
575
646
  PublishResult:
576
647
  type: object
577
648
  required: [package, version]
package/dist/cli/index.js CHANGED
@@ -25,6 +25,9 @@ function createProgram(handlers2, version) {
25
25
  program2.command("diff").description("Show semantic diff between current and target package versions.").argument("<package>", "Package name, or name@version to compare against a specific version.").option("--format <format>", "Output format.", "text").action(async (packageArg, opts, cmd) => {
26
26
  await handlers2.diff(packageArg, opts, cmd.optsWithGlobals());
27
27
  });
28
+ program2.command("list").description("List installed packages and their status.").option("--json", "Output in machine-readable JSON format.", false).action(async (opts, cmd) => {
29
+ await handlers2.list(opts, cmd.optsWithGlobals());
30
+ });
28
31
  program2.command("check").description("Run full verification pipeline for CI.").action(async (opts, cmd) => {
29
32
  await handlers2.check({}, cmd.optsWithGlobals());
30
33
  });
@@ -5182,6 +5185,63 @@ function promptConfirm(message) {
5182
5185
  });
5183
5186
  }
5184
5187
 
5188
+ // src/lib/commands/list.ts
5189
+ async function runList(input, projectDir) {
5190
+ const config = await readProjectConfig(projectDir);
5191
+ const lock = await readLockFile(projectDir);
5192
+ const packages = [];
5193
+ for (const [name, pkg] of Object.entries(config.packages)) {
5194
+ const lockEntry = lock.packages[name];
5195
+ const registryName = pkg.registry || "default";
5196
+ const registry = config.registries[registryName];
5197
+ const entry = {
5198
+ name,
5199
+ version: pkg.version,
5200
+ registry: registryName,
5201
+ installedTo: lockEntry?.installedTo
5202
+ };
5203
+ if (registry) {
5204
+ try {
5205
+ const repoDir = await ensureCloned(registry.owner, registry.repo);
5206
+ const manifest = await readManifestFromRepo(repoDir);
5207
+ const versions = listVersionsFromManifest(manifest, name);
5208
+ if (versions.length > 0) {
5209
+ const sorted = versions.map((v) => ({ raw: v, parts: parseSemver2(v) })).filter((v) => v.parts !== null).sort((a, b) => compareSemver2(a.parts, b.parts));
5210
+ const latest = sorted[sorted.length - 1].raw;
5211
+ entry.latestVersion = latest;
5212
+ entry.outdated = latest !== pkg.version;
5213
+ }
5214
+ } catch (e) {
5215
+ log.warn(`${name}: could not fetch registry (${e.message})`);
5216
+ }
5217
+ }
5218
+ packages.push(entry);
5219
+ }
5220
+ if (input.json) {
5221
+ console.log(JSON.stringify({ packages }, null, 2));
5222
+ return;
5223
+ }
5224
+ if (packages.length === 0) {
5225
+ log.info("No packages installed.");
5226
+ return;
5227
+ }
5228
+ for (const pkg of packages) {
5229
+ const latest = pkg.latestVersion ? ` (latest: ${pkg.latestVersion})` : "";
5230
+ const badge = pkg.outdated ? " [outdated]" : "";
5231
+ console.log(`${pkg.name}@${pkg.version}${latest}${badge}`);
5232
+ }
5233
+ }
5234
+ function parseSemver2(v) {
5235
+ const m = v.match(/^(\d+)\.(\d+)\.(\d+)/);
5236
+ if (!m) return null;
5237
+ return { major: +m[1], minor: +m[2], patch: +m[3] };
5238
+ }
5239
+ function compareSemver2(a, b) {
5240
+ if (a.major !== b.major) return a.major - b.major;
5241
+ if (a.minor !== b.minor) return a.minor - b.minor;
5242
+ return a.patch - b.patch;
5243
+ }
5244
+
5185
5245
  // src/lib/commands/check.ts
5186
5246
  import { existsSync as existsSync8 } from "fs";
5187
5247
  import { readFile as readFile6 } from "fs/promises";
@@ -5588,6 +5648,10 @@ var handlers = {
5588
5648
  format: opts.format
5589
5649
  }, cwd).catch(handleError);
5590
5650
  },
5651
+ list: async (opts, globals) => {
5652
+ setupGlobals(globals);
5653
+ await runList({ json: opts.json }, cwd).catch(handleError);
5654
+ },
5591
5655
  check: async (_opts, globals) => {
5592
5656
  setupGlobals(globals);
5593
5657
  await runCheck(cwd).catch(handleError);