@artblocks/abx-cli 0.1.0-alpha.0 → 0.1.0-alpha.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/dist/flags.d.ts CHANGED
@@ -12,6 +12,12 @@
12
12
  export type Flags = Record<string, string | undefined>;
13
13
  /** Flags where every occurrence counts (values comma-join, in argv order). */
14
14
  export declare const REPEATABLE_FLAGS: ReadonlySet<string>;
15
+ /**
16
+ * Flags valid on ANY command (handled centrally in main, not by a command handler), so
17
+ * {@link unknownFlags} never flags them as unrecognized regardless of the per-command allowlist.
18
+ * `no-update-check` opts out of the startup update nudge (see update-check.ts).
19
+ */
20
+ export declare const GLOBAL_FLAGS: ReadonlySet<string>;
15
21
  export declare function parseFlags(args: string[]): Flags;
16
22
  /**
17
23
  * The flag keys in `flags` that are NOT in `allowed` — for a non-fatal "unrecognized flag"
@@ -1 +1 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEvD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAA8B,CAAC;AAEhF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAchD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAG9E"}
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEvD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAA8B,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAAgC,CAAC;AAE9E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAchD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAG9E"}
package/dist/flags.js CHANGED
@@ -1,5 +1,11 @@
1
1
  /** Flags where every occurrence counts (values comma-join, in argv order). */
2
2
  export const REPEATABLE_FLAGS = new Set(['dep', 'schema']);
3
+ /**
4
+ * Flags valid on ANY command (handled centrally in main, not by a command handler), so
5
+ * {@link unknownFlags} never flags them as unrecognized regardless of the per-command allowlist.
6
+ * `no-update-check` opts out of the startup update nudge (see update-check.ts).
7
+ */
8
+ export const GLOBAL_FLAGS = new Set(['no-update-check']);
3
9
  export function parseFlags(args) {
4
10
  const out = {};
5
11
  const set = (k, v) => {
@@ -29,6 +35,6 @@ export function parseFlags(args) {
29
35
  */
30
36
  export function unknownFlags(flags, allowed) {
31
37
  const ok = new Set(allowed);
32
- return Object.keys(flags).filter((k) => !ok.has(k));
38
+ return Object.keys(flags).filter((k) => !ok.has(k) && !GLOBAL_FLAGS.has(k));
33
39
  }
34
40
  //# sourceMappingURL=flags.js.map
package/dist/flags.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS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IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;YAC7E,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY,EAAE,OAAyB;IAClE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
package/dist/main.js CHANGED
@@ -54,6 +54,7 @@ import { DEP_RESOLUTION, deploySeedSource, deploySeriesCodeFactory, prepareCodeS
54
54
  import { checkRegistryDeps, dependencySetupCalls, parseDepFlag, resolveDepRegistryPointer } from './deps.js';
55
55
  import { composeParamsKeys, expectedChainComplete, hasOnChainUriLane, onchainUriSetupCalls, onChainUriReport } from './onchain-uri.js';
56
56
  import { parseFlags, unknownFlags } from './flags.js';
57
+ import { checkForCliUpdate, compareVersions, installedSkillVersions, readCliVersion, SKILL_VERSION_MARKER } from './update-check.js';
57
58
  import { analyzeScript, recommendLane } from './inspect.js';
58
59
  import { parseSchemaSpecs, describeSchema } from './schema.js';
59
60
  import { parseSeriesTraits, looksPerTokenAttributes, parseSeriesTraitsById } from './series-traits.js';
@@ -110,10 +111,49 @@ const step = (s) => console.log(`\n${p(`[${++stepN}]`)} ${bold(s)}`);
110
111
  const ok = (s) => console.log(` ${g('✓')} ${s}`);
111
112
  const info = (s) => console.log(` ${dim(s)}`);
112
113
  const warn = (s) => console.log(` ${c.orange}⚠${c.reset} ${s}`);
114
+ /**
115
+ * Notify-only update nudge. Prints an upgrade one-liner to STDERR (never stdout — an agent may be
116
+ * parsing that) when a newer @artblocks/abx-cli is published, plus a nudge when a locally-installed
117
+ * skill has drifted behind the running CLI. Fully suppressed by CI / ABX_NO_UPDATE_CHECK /
118
+ * --no-update-check, and wrapped so it can NEVER break a command (all failures are swallowed).
119
+ */
120
+ async function maybeNotifyUpdate(flags) {
121
+ try {
122
+ if (flags['no-update-check'] !== undefined || process.env.ABX_NO_UPDATE_CHECK || process.env.CI)
123
+ return;
124
+ const current = readCliVersion();
125
+ // Skill drift (cheap, offline): the skill and CLI are co-versioned, but a separately-installed
126
+ // skill copy doesn't move when the CLI upgrades. Nudge a reinstall when the CLI is ahead.
127
+ for (const v of installedSkillVersions()) {
128
+ if (compareVersions(current, v) > 0) {
129
+ console.error(` ${c.orange}⚠${c.reset} installed abx skill is v${v} but the CLI is v${current} — refresh it: ${g('abx skill install')}`);
130
+ break;
131
+ }
132
+ }
133
+ const latest = await checkForCliUpdate(current);
134
+ if (latest) {
135
+ console.error(`\n ${c.orange}⚠${c.reset} update available: ${bold('abx')} ${dim(current)} → ${g(latest)}\n` +
136
+ ` upgrade: ${g('npm i -g @artblocks/abx-cli@latest')} ${dim('· or invoke:')} ${g('npx abx@latest <command>')}\n` +
137
+ ` release notes: https://github.com/ArtBlocks/abx/releases ${dim('· silence: ABX_NO_UPDATE_CHECK=1')}\n`);
138
+ }
139
+ }
140
+ catch {
141
+ /* an update check must never break a command */
142
+ }
143
+ }
113
144
  async function main() {
114
145
  loadDotEnv();
115
146
  const [cmd, ...rest] = process.argv.slice(2);
116
147
  const flags = parseFlags(rest);
148
+ // `version` / --version / -v is a crisp query — print and exit, no update nag around it.
149
+ if (cmd === 'version' || cmd === '--version' || cmd === '-v') {
150
+ console.log(readCliVersion());
151
+ return;
152
+ }
153
+ // Notify-only "you're behind" nudge (cached, opt-out, stderr — see update-check.ts). Awaited so
154
+ // the notice lands before command output, but it hits the network at most once a day and never
155
+ // throws, so it can't break or meaningfully slow a command. Skipped for the pure help path below.
156
+ await maybeNotifyUpdate(flags);
117
157
  // SAFETY: --help / -h on ANY command is read-only — print usage, never execute.
118
158
  // (A write command must never deploy/mint/spend just because someone asked for help.)
119
159
  if (cmd && cmd !== 'help' && (flags.help !== undefined || rest.includes('-h'))) {
@@ -4980,8 +5020,10 @@ function help() {
4980
5020
  ${g('abx status')} list indexed projects + node info
4981
5021
  ${g('abx doctor')} check environment (key, RPC, balance, factory, storage)
4982
5022
  ${g('abx skill install')} install the abx agent skill into your agent [--global] [--target <dir>] · ${g('abx skill path')} prints the bundled skill
5023
+ ${g('abx version')} print the installed CLI version
4983
5024
 
4984
5025
  ${dim('Run')} ${g('abx <command> --help')} ${dim('for per-command usage. --help / -h never executes — it only prints usage.')}
5026
+ ${dim('abx checks npm for a newer release (once a day, notify-only). Silence with')} ${g('ABX_NO_UPDATE_CHECK=1')} ${dim('or')} ${g('--no-update-check')}${dim('.')}
4985
5027
  `);
4986
5028
  }
4987
5029
  /** Validate an explicit --salt (a 32-byte hex). Undefined when absent. */
@@ -5081,6 +5123,14 @@ async function cmdSkill(rest, flags) {
5081
5123
  const dest = joinPath(destParent, 'abx-self-host');
5082
5124
  mkdirSync(destParent, { recursive: true });
5083
5125
  cpSync(src, dest, { recursive: true });
5126
+ // Stamp the CLI version so a later run can notice the skill has drifted behind an upgraded CLI
5127
+ // (the two are co-versioned). Best-effort — a missing marker just means "no drift nudge".
5128
+ try {
5129
+ writeFileSync(joinPath(dest, SKILL_VERSION_MARKER), readCliVersion());
5130
+ }
5131
+ catch {
5132
+ /* non-fatal */
5133
+ }
5084
5134
  ok(`installed the abx skill → ${dest}`);
5085
5135
  info('restart your agent (Claude Code / Cursor) so it loads the skill, then ask it to launch an NFT with abx.');
5086
5136
  info('cross-agent alternative (git-based): npx skills add ArtBlocks/abx');