@newlogic-digital/cli 1.5.0-next.2 → 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 +12 -1
- package/package.json +2 -1
- package/skills/newlogic-cli/SKILL.md +89 -0
- package/skills/newlogic-cli/agents/openai.yaml +6 -0
- package/skills/newlogic-cli/assets/favicon.svg +3 -0
- package/skills/newlogic-cli/assets/maskable.png +0 -0
- package/src/commands/skills/index.mjs +62 -0
- package/src/utils.mjs +3 -2
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
|
+
"version": "1.5.0-next.4",
|
|
4
4
|
"main": "index.mjs",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newlogic-cli": "index.mjs",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"index.js",
|
|
25
|
+
"skills",
|
|
25
26
|
"src"
|
|
26
27
|
],
|
|
27
28
|
"engines": {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: newlogic-cli
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# Newlogic CLI
|
|
7
|
+
|
|
8
|
+
## Quick Rules
|
|
9
|
+
|
|
10
|
+
- Run commands from the target project directory. `cms` and `blocks` operate on the current working tree.
|
|
11
|
+
- Prefer explicit flags to prompts. For automated runs, pass `-y` and any necessary options.
|
|
12
|
+
- Do not probe for `newlogic` in advance. Install it only after a real command fails because the binary is missing.
|
|
13
|
+
- Expect Node `>=22` and npm `>=10`.
|
|
14
|
+
- Use `newlogic` in user-facing examples.
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
### `init`
|
|
19
|
+
|
|
20
|
+
Use to scaffold a new project.
|
|
21
|
+
|
|
22
|
+
- `newlogic init`
|
|
23
|
+
- `newlogic init ui <directory>`
|
|
24
|
+
- `newlogic init cms <directory>`
|
|
25
|
+
|
|
26
|
+
Useful non-interactive options:
|
|
27
|
+
|
|
28
|
+
- `--branch=main|dev`
|
|
29
|
+
- `--clone=ssh|https`
|
|
30
|
+
- `--scope=default|blank` for `ui`
|
|
31
|
+
- `--variant=cms-web|cms-eshop` for `cms`
|
|
32
|
+
- `--git`, `--remote=<git-url>`, `--install`
|
|
33
|
+
- `--prepare`, `--dev`, `--migrations` for `cms`
|
|
34
|
+
- `-y` to accept defaults without prompts
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
newlogic init ui demo --branch=dev --clone=https --scope=blank --git --remote=git@github.com:org/demo.git --install -y
|
|
40
|
+
newlogic init cms demo --branch=dev --clone=https --variant=cms-web --install --prepare --dev --migrations -y
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### `cms`
|
|
44
|
+
|
|
45
|
+
Use inside a CMS project.
|
|
46
|
+
|
|
47
|
+
- `newlogic cms prepare`
|
|
48
|
+
- `newlogic cms prepare views`
|
|
49
|
+
- `newlogic cms prepare components`
|
|
50
|
+
- `newlogic cms new-component <name>`
|
|
51
|
+
|
|
52
|
+
Notes:
|
|
53
|
+
|
|
54
|
+
- `prepare` copies templates and components from a UI project into CMS structure.
|
|
55
|
+
- `new-component` creates PHP component scaffolding and clears `temp/cache` if present.
|
|
56
|
+
- Deprecated aliases such as `new-section` still exist in code, but prefer `new-component`.
|
|
57
|
+
|
|
58
|
+
### `blocks`
|
|
59
|
+
|
|
60
|
+
Use to manage installable blocks in a project root.
|
|
61
|
+
|
|
62
|
+
- `newlogic blocks list`
|
|
63
|
+
- `newlogic blocks add <name...>`
|
|
64
|
+
- `newlogic blocks remove <name...>`
|
|
65
|
+
- `newlogic blocks update`
|
|
66
|
+
|
|
67
|
+
Notes:
|
|
68
|
+
|
|
69
|
+
- `list` prints all installable blocks with short descriptions so the agent can discover valid names before making changes.
|
|
70
|
+
- `add` accepts kebab-case or PascalCase block names.
|
|
71
|
+
- Installed blocks are recorded in `newlogic.config.json`.
|
|
72
|
+
- `update` reinstalls all configured blocks from `newlogic.config.json`.
|
|
73
|
+
- `add` and `remove` may modify files and install npm or composer dependencies.
|
|
74
|
+
|
|
75
|
+
Recommended flow:
|
|
76
|
+
|
|
77
|
+
1. Run `newlogic blocks list` to discover what blocks exist.
|
|
78
|
+
2. Match the user request to one or more listed block names.
|
|
79
|
+
3. Run `newlogic blocks add <name...>` only after the names are confirmed by the list output.
|
|
80
|
+
4. Use `remove` only when the user wants to delete blocks that are already installed in the current project.
|
|
81
|
+
5. Use `update` when the goal is to reinstall everything already tracked in `newlogic.config.json`.
|
|
82
|
+
|
|
83
|
+
## Agent Workflow
|
|
84
|
+
|
|
85
|
+
1. Choose the command based on intent: scaffold with `init`, sync CMS artifacts with `cms`, manage reusable blocks with `blocks`.
|
|
86
|
+
2. Run it from the correct working directory.
|
|
87
|
+
3. If the command fails because `newlogic` is missing, install it with `npm i -g @newlogic-digital/cli` and retry.
|
|
88
|
+
4. Prefer explicit flags and `-y` for deterministic execution.
|
|
89
|
+
5. After mutation commands, inspect changed files and report side effects such as generated folders, dependency installs, or `newlogic.config.json` updates.
|
|
@@ -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>
|
|
Binary file
|
|
@@ -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
|
|
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 }
|