@newlogic-digital/cli 1.5.0-next.3 → 1.5.0-next.4

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/index.mjs CHANGED
@@ -3,10 +3,11 @@
3
3
  import init from './src/commands/init/index.mjs'
4
4
  import cms from './src/commands/cms/index.mjs'
5
5
  import blocks from './src/commands/blocks/index.mjs'
6
+ import skills from './src/commands/skills/index.mjs'
6
7
  import { styleText } from 'node:util'
7
8
  import { version, name } from './src/utils.mjs'
8
9
 
9
- const knownCommands = ['init', 'cms', 'blocks']
10
+ const knownCommands = ['init', 'cms', 'blocks', 'skills']
10
11
 
11
12
  function normalizeOptionName(name) {
12
13
  return name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
@@ -158,6 +159,9 @@ if (!command) {
158
159
  ${styleText('green', 'newlogic blocks remove')} ${styleText('yellow', 'about-accordion')}
159
160
  ${styleText('green', 'newlogic blocks remove')} ${styleText('yellow', 'header-nav-left hero-floating-text')}
160
161
  ${styleText('green', 'newlogic blocks update')}
162
+
163
+ -- skills --
164
+ ${styleText('green', 'newlogic skills install')} - Installs the bundled ${styleText('yellow', 'newlogic-cli')} skill via ${styleText('blue', 'npx skills add')}
161
165
  `)
162
166
 
163
167
  process.exit(0)
@@ -187,6 +191,13 @@ if (command === 'blocks') {
187
191
  await blocks(action, names)
188
192
  }
189
193
 
194
+ if (command === 'skills') {
195
+ const { positionals } = parseCommandArgs(rawArgs.slice(1))
196
+ const action = positionals[0]
197
+
198
+ await skills(action)
199
+ }
200
+
190
201
  if (command && !knownCommands.includes(command)) {
191
202
  printUnknownCommand(command)
192
203
  process.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlogic-digital/cli",
3
- "version": "1.5.0-next.3",
3
+ "version": "1.5.0-next.4",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "newlogic-cli": "index.mjs",
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: newlogic
2
+ name: newlogic-cli
3
3
  description: Use the installed Newlogic CLI when Codex needs to run `newlogic`, scaffold `@newlogic-digital/ui` or `@newlogic-digital/cms` projects, prepare CMS templates and components, or manage installable blocks through `newlogic.config.json`. Trigger this skill for tasks involving the commands `init`, `cms`, or `blocks`, especially when an agent should run the CLI safely and non-interactively.
4
4
  ---
5
5
 
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "Newlogic CLI"
3
+ short_description: "Use installed Newlogic CLI for init, cms, and blocks."
4
+ icon_small: "./assets/favicon.svg"
5
+ icon_large: "./assets/maskable.png"
6
+ default_prompt: "Use $newlogic-cli to run Newlogic init, cms, or blocks commands safely and non-interactively."
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
2
+ <path fill="#000" d="M89,0,62.68,26.36,36.32,0H0V120H31L57.32,93.64,83.68,120H120V0Zm0,8.53V52.72l-22.1-22.1Zm6,58.75V6H114V109.7L10.3,6H33.82ZM31,111.47V67.28l22.1,22.1Zm-6-58.75V114H6V10.29L109.7,114H86.18Z"/>
3
+ </svg>
@@ -0,0 +1,62 @@
1
+ import childProcess from 'node:child_process'
2
+ import fs from 'node:fs'
3
+ import { styleText } from 'node:util'
4
+ import { packageRoot, resolveInside } from '../../utils.mjs'
5
+
6
+ function label(color, text) {
7
+ return styleText([color, 'bold'], text)
8
+ }
9
+
10
+ function printSkillsUsage() {
11
+ console.log([
12
+ styleText(['blue', 'bold'], 'newlogic skills'),
13
+ '',
14
+ styleText(['white', 'bold'], 'Usage:'),
15
+ '',
16
+ ` ${styleText('green', 'newlogic skills install')} - Installs the bundled ${styleText('yellow', 'newlogic-cli')} skill`,
17
+ '',
18
+ styleText(['white', 'bold'], 'Notes:'),
19
+ '',
20
+ ` ${styleText('dim', 'Resolves the installed CLI location automatically and runs:')}`,
21
+ ` ${styleText('cyan', 'npx skills add <resolved-path>/skills/newlogic-cli')}`,
22
+ ].join('\n'))
23
+ }
24
+
25
+ function getBundledSkillPath(skillName = 'newlogic-cli') {
26
+ return resolveInside(packageRoot, 'skills', skillName)
27
+ }
28
+
29
+ function installBundledSkill(skillName = 'newlogic-cli', options = {}) {
30
+ const { execFileSync = childProcess.execFileSync } = options
31
+ const skillPath = getBundledSkillPath(skillName)
32
+
33
+ if (!fs.existsSync(skillPath)) {
34
+ throw new Error(`Bundled skill "${skillName}" not found at ${skillPath}`)
35
+ }
36
+
37
+ execFileSync('npx', ['skills', 'add', skillPath], { stdio: 'inherit' })
38
+
39
+ return skillPath
40
+ }
41
+
42
+ export { getBundledSkillPath, installBundledSkill }
43
+
44
+ export default async function skills(action) {
45
+ if (!action || action === 'help' || action === '--help') {
46
+ printSkillsUsage()
47
+ return
48
+ }
49
+
50
+ try {
51
+ if (action === 'install') {
52
+ installBundledSkill()
53
+ return
54
+ }
55
+
56
+ throw new Error(`Unknown skills action "${action}"`)
57
+ }
58
+ catch (error) {
59
+ console.log(`${label('red', 'error')} ${error.message}`)
60
+ process.exit(1)
61
+ }
62
+ }
package/src/utils.mjs CHANGED
@@ -3,7 +3,8 @@ import fs from 'fs'
3
3
  import path from 'path'
4
4
  import { fileURLToPath } from 'url'
5
5
 
6
- const { version, name } = JSON.parse(fs.readFileSync(path.resolve(path.dirname((fileURLToPath(import.meta.url))), '../package.json')).toString())
6
+ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
7
+ const { version, name } = JSON.parse(fs.readFileSync(path.resolve(packageRoot, 'package.json')).toString())
7
8
 
8
9
  const execSync = (cmd) => {
9
10
  try {
@@ -45,4 +46,4 @@ function resolveInside(rootDir, ...segments) {
45
46
  return nextPath
46
47
  }
47
48
 
48
- export { execSync, stripIndent, resolveInside, version, name }
49
+ export { execSync, stripIndent, resolveInside, version, name, packageRoot }
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "Newlogic CLI"
3
- short_description: "Use the local Newlogic CLI safely and non-interactively."
4
- default_prompt: "Use this skill when you need to inspect or run the Newlogic CLI in this repository."