happyskills 0.5.0 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-03-06
11
+
12
+ ### Added
13
+ - Add `--json --browser` combined flags to `login` command for single-command authentication — returns already-logged-in status or launches the browser flow and returns the result as JSON, eliminating the two-step check-then-login dance
14
+
15
+ ### Changed
16
+ - Change `login_device` expired-token handling from `process.exit()` to a thrown error so callers (including `--json` mode) can handle it gracefully
17
+
18
+ ## [0.6.0] - 2026-03-06
19
+
20
+ ### Added
21
+ - Add `--public` flag to `publish` command to explicitly publish a skill as publicly discoverable in the catalog
22
+
23
+ ### Changed
24
+ - Change `publish` default visibility from public to private — skills are now private by default; pass `--public` to make a skill visible in the catalog
25
+ - Change `convert` to no longer auto-publish to the registry after converting; the skill is registered locally and the user is prompted to run `happyskills publish <skill-name>` as a separate step
26
+
27
+ ### Fixed
28
+ - Fix `--version` flag collision where commands accepting `--version <value>` (e.g., `convert --version 1.0.0`) would incorrectly trigger the root `--version` output instead of passing the value to the command
29
+
10
30
  ## [0.5.0] - 2026-03-05
11
31
 
12
32
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happyskills",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Package manager for AI agent skills",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Nicolas Dao <nic@cloudlesslabs.com> (https://cloudlesslabs.com)",
package/src/api/push.js CHANGED
@@ -12,13 +12,13 @@ const estimate_payload_size = (files) => {
12
12
  return size
13
13
  }
14
14
 
15
- const smart_push = (owner, repo, { version, message, files }, on_progress) =>
15
+ const smart_push = (owner, repo, { version, message, files, visibility }, on_progress) =>
16
16
  catch_errors('Smart push failed', async () => {
17
17
  const payload_size = estimate_payload_size(files)
18
18
 
19
19
  if (payload_size < DIRECT_PUSH_THRESHOLD) {
20
20
  // Small payload — use direct push
21
- const [err, data] = await repos_api.push(owner, repo, { version, message, files })
21
+ const [err, data] = await repos_api.push(owner, repo, { version, message, files, visibility })
22
22
  if (err) throw e('Direct push failed', err)
23
23
  return data
24
24
  }
@@ -28,7 +28,7 @@ const smart_push = (owner, repo, { version, message, files }, on_progress) =>
28
28
 
29
29
  // Step 1: Initiate
30
30
  const [init_err, init_data] = await initiate_upload(owner, repo, {
31
- version, message, files: file_meta
31
+ version, message, files: file_meta, visibility
32
32
  })
33
33
  if (init_err) throw e('Upload initiation failed', init_err)
34
34
 
@@ -5,9 +5,7 @@ const { error: { catch_errors, wrap_errors: e } } = require('puffy-core')
5
5
  const { require_token } = require('../auth/token_store')
6
6
  const repos_api = require('../api/repos')
7
7
  const workspaces_api = require('../api/workspaces')
8
- const { smart_push } = require('../api/push')
9
8
  const { parse_frontmatter } = require('../utils/skill_scanner')
10
- const { collect_files } = require('../utils/file_collector')
11
9
  const { write_manifest } = require('../manifest/writer')
12
10
  const { read_lock } = require('../lock/reader')
13
11
  const { write_lock, update_lock_skills } = require('../lock/writer')
@@ -125,7 +123,7 @@ const run = (args) => catch_errors('Convert failed', async () => {
125
123
  console.error(` Description: ${description || '(none)'}`)
126
124
  console.error(` Keywords: ${keywords.length ? keywords.join(', ') : '(none)'}`)
127
125
  console.error('')
128
- const answer = await confirm('Publish this skill to the registry? [y/N] ')
126
+ const answer = await confirm('Convert this skill to a managed package? [y/N] ')
129
127
  if (answer !== 'y' && answer !== 'yes') {
130
128
  print_info('Aborted.')
131
129
  return process.exit(EXIT_CODES.SUCCESS)
@@ -138,21 +136,6 @@ const run = (args) => catch_errors('Convert failed', async () => {
138
136
  const [manifest_err] = await write_manifest(skill_dir, manifest)
139
137
  if (manifest_err) { pub_spinner.fail('Failed to write skill.json'); throw e('Failed to write skill.json', manifest_err) }
140
138
 
141
- pub_spinner.update('Packaging skill...')
142
- const [collect_err, skill_files] = await collect_files(skill_dir)
143
- if (collect_err) { pub_spinner.fail('Failed to collect files'); throw e('File collection failed', collect_err) }
144
-
145
- pub_spinner.update(`Publishing ${workspace.slug}/${skill_name}@${version}...`)
146
- const on_progress = (completed, total) => {
147
- pub_spinner.update(`Uploading files (${completed}/${total})...`)
148
- }
149
- const [push_err, push_data] = await smart_push(workspace.slug, skill_name, {
150
- version,
151
- message: `Release ${version}`,
152
- files: skill_files
153
- }, on_progress)
154
- if (push_err) { pub_spinner.fail('Publish failed'); throw e('Push failed', push_err) }
155
-
156
139
  pub_spinner.update('Updating lock file...')
157
140
  const lock_dir = lock_root(is_global, project_root)
158
141
  const [, lock_data] = await read_lock(lock_dir)
@@ -162,8 +145,8 @@ const run = (args) => catch_errors('Convert failed', async () => {
162
145
  const updates = {
163
146
  [full_name]: {
164
147
  version,
165
- ref: push_data?.ref || `refs/tags/v${version}`,
166
- commit: push_data?.commit || null,
148
+ ref: null,
149
+ commit: null,
167
150
  integrity: integrity || null,
168
151
  requested_by: ['__root__'],
169
152
  dependencies: {}
@@ -185,6 +168,9 @@ const run = (args) => catch_errors('Convert failed', async () => {
185
168
  } })
186
169
  return
187
170
  }
171
+
172
+ console.error('')
173
+ print_info(`Next step: enrich metadata, then run \`happyskills publish ${skill_name}\` to publish.`)
188
174
  }).then(([errors]) => { if (errors) { exit_with_error(errors); return } })
189
175
 
190
176
  module.exports = { run }
@@ -22,7 +22,8 @@ Options:
22
22
  Examples:
23
23
  happyskills login
24
24
  happyskills login --browser
25
- happyskills login --password`
25
+ happyskills login --password
26
+ happyskills login --json --browser Check status or authenticate (for automation)`
26
27
 
27
28
  const prompt = (question) => new Promise((resolve) => {
28
29
  const rl = readline.createInterface({ input: process.stdin, output: process.stderr })
@@ -120,8 +121,33 @@ const run = (args) => catch_errors('Login failed', async () => {
120
121
  const email = payload?.email || 'unknown'
121
122
  const username = payload?.['cognito:username'] || payload?.sub || 'unknown'
122
123
  print_json({ data: { status: 'already_logged_in', username, email } })
124
+ return
125
+ }
126
+
127
+ // Not logged in — check if browser flow requested
128
+ if (!args.flags.browser) {
129
+ print_json({ error: { code: 'INTERACTIVE_REQUIRED', message: 'Login requires browser interaction. Run `happyskills login --json --browser` to authenticate.', exit_code: EXIT_CODES.ERROR } })
130
+ process.exit(EXIT_CODES.ERROR)
131
+ return
132
+ }
133
+
134
+ // --json --browser: run browser flow, return JSON result
135
+ const [errors] = await run_browser_flow()
136
+ if (errors) {
137
+ print_json({ error: { code: 'AUTH_FAILED', message: errors[0]?.message || 'Browser login failed', exit_code: EXIT_CODES.ERROR } })
138
+ process.exit(EXIT_CODES.ERROR)
139
+ return
140
+ }
141
+
142
+ // Browser flow succeeded — read saved token
143
+ const [, new_token] = await load_token()
144
+ if (new_token) {
145
+ const payload = decode_jwt_payload(new_token.id_token)
146
+ const email = payload?.email || 'unknown'
147
+ const username = payload?.['cognito:username'] || payload?.sub || 'unknown'
148
+ print_json({ data: { status: 'logged_in', username, email } })
123
149
  } else {
124
- print_json({ error: { code: 'INTERACTIVE_REQUIRED', message: 'Login requires browser interaction. Run `happyskills login --browser` manually.', exit_code: EXIT_CODES.ERROR } })
150
+ print_json({ error: { code: 'AUTH_FAILED', message: 'Login flow completed but token could not be loaded', exit_code: EXIT_CODES.ERROR } })
125
151
  process.exit(EXIT_CODES.ERROR)
126
152
  }
127
153
  return
@@ -45,7 +45,7 @@ const run_browser_flow = () => catch_errors('Browser login failed', async () =>
45
45
  const api_err = token_err.find(err => err.error_code)
46
46
  if (api_err?.error_code === 'EXPIRED_TOKEN') {
47
47
  spinner.fail('Authorization expired. Please run `happyskills login` again.')
48
- process.exit(EXIT_CODES.ERROR)
48
+ throw new Error('Authorization expired. Please run `happyskills login` again.')
49
49
  }
50
50
  // Transient error — keep polling
51
51
  continue
@@ -24,6 +24,7 @@ Arguments:
24
24
  Options:
25
25
  --bump <type> Auto-bump version before publishing (patch, minor, major)
26
26
  --workspace <slug> Target workspace (overrides lock file owner)
27
+ --public Publish as public (default is private)
27
28
 
28
29
  Aliases: pub
29
30
 
@@ -120,10 +121,12 @@ const run = (args) => catch_errors('Publish failed', async () => {
120
121
  const on_progress = (completed, total) => {
121
122
  spinner.update(`Uploading files (${completed}/${total})...`)
122
123
  }
124
+ const visibility = args.flags.public ? 'public' : 'private'
123
125
  const [push_err] = await smart_push(workspace.slug, manifest.name, {
124
126
  version: manifest.version,
125
127
  message: `Release ${manifest.version}`,
126
- files: skill_files
128
+ files: skill_files,
129
+ visibility
127
130
  }, on_progress)
128
131
  if (push_err) { spinner.fail('Publish failed'); throw e('Push failed', push_err) }
129
132
 
package/src/index.js CHANGED
@@ -115,7 +115,7 @@ const run = (argv) => {
115
115
  set_json_mode()
116
116
  }
117
117
 
118
- if (args.flags.version) {
118
+ if (args.flags.version === true) {
119
119
  show_version()
120
120
  return process.exit(EXIT_CODES.SUCCESS)
121
121
  }
@@ -340,6 +340,32 @@ describe('CLI — --json: success responses use { data } envelope', () => {
340
340
  fs.rmSync(tmp_xdg, { recursive: true, force: true })
341
341
  }
342
342
  })
343
+
344
+ it('login --json --browser with stored credentials returns already_logged_in', () => {
345
+ const tmp_xdg = make_tmp()
346
+ try {
347
+ const creds_dir = path.join(tmp_xdg, 'happyskills')
348
+ fs.mkdirSync(creds_dir, { recursive: true })
349
+ const payload = { email: 'test@example.com', 'cognito:username': 'testuser', sub: 'test-sub-123' }
350
+ const fake_jwt = `eyJhbGciOiJSUzI1NiJ9.${Buffer.from(JSON.stringify(payload)).toString('base64url')}.fakesig`
351
+ fs.writeFileSync(path.join(creds_dir, 'credentials.json'), JSON.stringify({
352
+ id_token: fake_jwt,
353
+ access_token: 'fake-access',
354
+ refresh_token: 'fake-refresh',
355
+ expires_in: 3600,
356
+ stored_at: new Date().toISOString()
357
+ }, null, '\t'))
358
+ const { stdout, code } = run(['login', '--json', '--browser'], { XDG_CONFIG_HOME: tmp_xdg })
359
+ assert.strictEqual(code, 0)
360
+ const out = parse_json_output(stdout, 'login --json --browser with credentials')
361
+ assert.ok('data' in out)
362
+ assert.strictEqual(out.data.status, 'already_logged_in')
363
+ assert.strictEqual(out.data.username, 'testuser')
364
+ assert.strictEqual(out.data.email, 'test@example.com')
365
+ } finally {
366
+ fs.rmSync(tmp_xdg, { recursive: true, force: true })
367
+ }
368
+ })
343
369
  })
344
370
 
345
371
  // ─── --json flag: existing commands use { data } envelope ─────────────────────