octwin-cli 0.1.1 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +105 -37
  2. package/dist/index.js +50 -1
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -1,65 +1,133 @@
1
1
  # octwin-cli
2
2
 
3
- The **Octwin** external-pack developer CLI, by **CEQUENS**. Scaffold a pure-YAML
4
- pack in your own repo, validate it offline, and deploy it to a running Octwin
5
- platform to test on your own tenant — no platform checkout, no build step.
3
+ > The **Octwin** external-pack developer CLI — scaffold, validate, deploy, and manage pure-YAML packs on your own tenant. By **CEQUENS**.
6
4
 
7
- The package is `octwin-cli`; the command it installs is `octwin`.
5
+ [![npm version](https://img.shields.io/npm/v/octwin-cli.svg)](https://www.npmjs.com/package/octwin-cli)
6
+ [![license](https://img.shields.io/npm/l/octwin-cli.svg)](https://www.npmjs.com/package/octwin-cli)
7
+ [![node](https://img.shields.io/node/v/octwin-cli.svg)](https://nodejs.org)
8
+
9
+ Octwin is a pack-pluggable conversational-agent platform for WhatsApp and web. A **pack** is a
10
+ self-contained bot domain — its agent, conversation flows, prompts, and data model — declared
11
+ entirely in YAML. `octwin-cli` lets you build a **pure-YAML pack** in your own repo and deploy it
12
+ to a running Octwin platform to test live on your own tenant: no platform checkout, no build step,
13
+ and nothing untrusted to run (a pure-YAML pack is declarative data, so the platform can safely run
14
+ it alongside other tenants).
15
+
16
+ > The npm package is **`octwin-cli`**; the command it installs is **`octwin`**.
17
+
18
+ ## Requirements
19
+
20
+ - **Node.js ≥ 20**
21
+ - Access to an **Octwin platform** (its base URL), a **tenant** (your workspace) on it, and a
22
+ **deploy token** (generated in the Octwin console — see [Authentication](#authentication)).
8
23
 
9
24
  ## Install
10
25
 
11
26
  ```bash
12
- # zero-install (recommended)
13
- npx octwin-cli <command>
27
+ # zero-install — always the latest version
28
+ npx octwin-cli@latest <command>
14
29
 
15
- # or install the command globally
16
- npm i -g octwin-cli
30
+ # or install the `octwin` command globally
31
+ npm install -g octwin-cli
17
32
  octwin <command>
18
33
  ```
19
34
 
20
- ## The loop
35
+ ## Quick start
21
36
 
22
37
  ```bash
23
- # 1. Scaffold a standalone pure-YAML pack (yours)
38
+ # 1. Scaffold a standalone pure-YAML pack (this is your repo)
24
39
  octwin init ./my-pack --id my-pack --description "My business bot"
25
- cd ./my-pack && git init && git add -A && git commit -m "init pack"
40
+ cd ./my-pack
41
+ git init && git add -A && git commit -m "init pack"
26
42
 
27
- # 2. Author: edit manifest.yaml, flows/tools/main.flow.yaml (+ locale),
28
- # prompts/identity.md. Everything is pure YAML/SQL — no TypeScript.
43
+ # 2. Author it — edit manifest.yaml, flows/tools/main.flow.yaml (+ its locale),
44
+ # and prompts/identity.md. Everything is pure YAML.
29
45
 
30
- # 3. Validate locally (same structural gate the server runs)
46
+ # 3. Point it at your platform: edit pack.json, then log in with a deploy token
47
+ # (Octwin console → your workspace → API tokens → Generate)
48
+ octwin login --url https://your-octwin.example.com --token oct_…
49
+
50
+ # 4. Validate → deploy → confirm it's live
31
51
  octwin validate
52
+ octwin deploy --seed # --seed also loads any demo data the pack declares
53
+ octwin status # "✓ live and current" once it's warm
32
54
 
33
- # 4. Log in with a DEPLOY TOKEN from the console (Workspace API tokens →
34
- # Generate), then deploy. Point pack.json at your platform + tenant first.
35
- octwin login --url https://platform.example.com --token oct_…
36
- octwin whoami --tenant my-tenant
37
- octwin deploy --tenant my-tenant --project main # add --seed to seed demo data
55
+ # 5. Chat with it on your tenant (web widget / console test page). Edit and
56
+ # `octwin deploy` again a redeploy hot-loads with no restart.
57
+ ```
38
58
 
39
- # 5. Confirm it landed — which version is live?
40
- octwin status --tenant my-tenant --project main
59
+ ## Commands
60
+
61
+ | Command | What it does |
62
+ | --- | --- |
63
+ | `octwin init <dir>` | Scaffold a new pure-YAML pack into `<dir>` (writes a starter `manifest.yaml`, flow, prompt, and `pack.json`). Options: `--id`, `--description`, `--display-name`. |
64
+ | `octwin validate` | Check the pack locally (structure + pure-YAML rules). The platform re-validates the full manifest/flow schema on deploy. |
65
+ | `octwin login` | Save a deploy token for a platform URL (stored in `~/.octwin/credentials.json`). `--url`, `--token`. |
66
+ | `octwin whoami` | Verify the saved/passed token is valid for a tenant. `--url`, `--tenant`. |
67
+ | `octwin deploy` | Upload + install the pack onto your tenant's project. `--seed` also runs the pack's demo seed. |
68
+ | `octwin status` | Report what the platform has live for this pack — installed vs. loaded version, and its flows. |
69
+ | `octwin platform-kb pull` | Pull the platform's capability reference (built-ins, primitives, render intents, flow-DSL — as markdown + JSON) into `.octwin/platform-kb/`, for the **`octwin-pack`** Claude Code authoring plugin to consult. |
70
+ | `octwin test` | Validate locally and print how to try the pack on your tenant. |
71
+ | `octwin help` | Show usage. |
72
+
73
+ Every command that talks to the platform accepts `--dir <path>` (the pack directory; defaults to
74
+ the current directory) plus the target overrides `--url` / `--tenant` / `--project` / `--token`.
75
+
76
+ ## Configuration
77
+
78
+ The deploy target has four settings. Three live in a committed **`pack.json`** at the root of your
79
+ pack; the **token is a secret** and is kept out of `pack.json` (set it with `octwin login`).
80
+
81
+ ```jsonc
82
+ // pack.json — created by `octwin init`
83
+ {
84
+ "platform_url": "https://your-octwin.example.com", // your Octwin platform
85
+ "tenant": "my-tenant-slug", // your workspace (required)
86
+ "project": "main" // defaults to "main"
87
+ }
88
+ ```
41
89
 
42
- # 6. Chat on your tenant (web widget / console test page). Edit → deploy again:
43
- # a redeploy hot-loads with no restart; re-run `octwin status` to confirm.
90
+ ```bash
91
+ octwin login --url https://your-octwin.example.com --token oct_… # saves the token once
44
92
  ```
45
93
 
46
- ## Auththe deploy token
94
+ Each setting resolves in this order **flag environment variable → `pack.json` → default**:
95
+
96
+ | Setting | Flag | Env var | `pack.json` key |
97
+ | --- | --- | --- | --- |
98
+ | Platform URL | `--url` | `PACK_PLATFORM_URL` | `platform_url` |
99
+ | Tenant slug | `--tenant` | `PACK_TENANT` | `tenant` |
100
+ | Project slug | `--project` | `PACK_PROJECT` | `project` (default `main`) |
101
+ | Deploy token | `--token` | `PACK_TOKEN` | — *(use `octwin login`)* |
47
102
 
48
- You authenticate with a tenant-scoped **deploy token** (`oct_…`), not a password
49
- and not an operator token. It is least-privilege (scope `pack:deploy`) and
50
- revocable in the console. Add the **`media:generate`** scope to let a `--seed`
51
- deploy AI-generate seed images (a demo field `photo: 'generate:<prompt>'`).
103
+ For **CI**, skip `pack.json`/`login` entirely and pass `PACK_PLATFORM_URL`, `PACK_TENANT`,
104
+ `PACK_PROJECT`, and `PACK_TOKEN` as environment variables.
52
105
 
53
- ## Config resolution (deploy/status)
106
+ ## Authentication
54
107
 
55
- `flags` > `pack.json` (in the pack dir) > env (`PACK_PLATFORM_URL`, `PACK_TENANT`,
56
- `PACK_PROJECT`, `PACK_TOKEN`) > saved login (`~/.octwin/credentials.json`).
108
+ You authenticate with a tenant-scoped **deploy token** (prefixed `oct_…`) not a password and not
109
+ an operator token. Generate it in the Octwin console (**your workspace → API tokens → Generate**).
110
+ It is **least-privilege** (scope `pack:deploy`): it can deploy packs to your tenant but cannot
111
+ manage members, billing, or other tenants, and it is revocable at any time.
112
+
113
+ Add the optional **`media:generate`** scope to let a `--seed` deploy AI-generate seed images
114
+ (for a demo record field like `photo: "generate:<prompt>"`); without it, such fields are seeded as
115
+ text only.
57
116
 
58
117
  ## What a pack may contain
59
118
 
60
- Pure declarative data only YAML + SQL (`.yaml`/`.yml`/`.md`/`.sql`/`.json`).
61
- No `.ts`/`.js`, no `routes/`, no `db/client.*`, no `*.primitives.*`. This is what
62
- makes an external pack safe to run on the shared platform; the server enforces it
63
- on deploy. Persist domain records with the platform's first-class **XRM** /
64
- **catalog** / **casework** modules (declared in `xrm.yaml` / `cases.yaml`) no
65
- pack database required.
119
+ A pack is **pure declarative data**`.yaml` / `.yml` / `.md` / `.sql` / `.json` only. Executable
120
+ code (`.ts`/`.js`), HTTP routes, DB clients, and custom primitives are **not** allowed (this is what
121
+ makes an external pack safe to run on a shared platform; the server enforces it on deploy). For
122
+ domain records, use Octwin's first-class storage modules — **XRM** (records with stage pipelines),
123
+ **catalog** (products), or **casework** (tickets) declared in `xrm.yaml` / `cases.yaml`, so a pack
124
+ needs **no database of its own**.
125
+
126
+ ## Links
127
+
128
+ - **npm:** <https://www.npmjs.com/package/octwin-cli>
129
+ - **Command help:** `octwin help`
130
+
131
+ ## License
132
+
133
+ [MIT](./LICENSE) © CEQUENS
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@
13
13
  * octwin whoami [--url <url>] [--tenant <slug>]
14
14
  * octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
15
15
  * octwin status [--dir .] # did my deploy land? which version is live?
16
+ * octwin platform-kb [pull] [--dir .] # pull the platform capability reference for the authoring skill
16
17
  * octwin test [--dir .] # local validate + how to chat on your tenant
17
18
  *
18
19
  * Config resolution (deploy): flags > pack.json (in the pack dir) > env
@@ -142,7 +143,7 @@ function cmdInit(flags) {
142
143
  tenant: 'your-tenant-slug',
143
144
  project: 'main',
144
145
  }, null, 2) + '\n', 'utf8');
145
- writeFileSync(join(dir, '.gitignore'), 'node_modules/\n.pack-bundles/\n', 'utf8');
146
+ writeFileSync(join(dir, '.gitignore'), 'node_modules/\n.pack-bundles/\n.octwin/\n', 'utf8');
146
147
  if (!existsSync(join(dir, 'README.md'))) {
147
148
  writeFileSync(join(dir, 'README.md'), `# ${id}\n\nA pure-YAML pack for the Octwin platform.\n\n- Edit \`manifest.yaml\`, \`flows/tools/main.flow.yaml\`, \`prompts/identity.md\`\n- \`octwin validate\` — check it locally\n- \`octwin deploy\` — deploy + install onto your tenant\n`, 'utf8');
148
149
  }
@@ -284,6 +285,49 @@ async function cmdStatus(flags) {
284
285
  console.log(` (local manifest is ${localVersion}; deployed is ${json.installed_version} — \`octwin deploy\` to push local edits.)`);
285
286
  }
286
287
  }
288
+ async function cmdPlatformKb(flags) {
289
+ const packDir = resolve(flags.dir ?? '.');
290
+ const { url, tenant, token } = resolveTarget(flags, packDir);
291
+ const res = await fetch(`${url}/api/admin/tenants/${tenant}/octwin-platform-kb`, {
292
+ headers: { authorization: `Bearer ${token}` },
293
+ });
294
+ const text = await res.text();
295
+ if (!res.ok) {
296
+ let j;
297
+ try {
298
+ j = JSON.parse(text);
299
+ }
300
+ catch {
301
+ j = text;
302
+ }
303
+ console.error(`✗ platform-kb pull failed (HTTP ${res.status})`);
304
+ console.error(typeof j === 'string' ? j : JSON.stringify(j, null, 2));
305
+ process.exit(1);
306
+ }
307
+ const bundle = JSON.parse(text);
308
+ // Write the reference into <packDir>/.octwin/platform-kb/ — markdown docs (the
309
+ // skill reads these first) + JSON catalogs (precise field schemas). Gitignored.
310
+ const outDir = join(packDir, '.octwin', 'platform-kb');
311
+ mkdirSync(outDir, { recursive: true });
312
+ let mdCount = 0;
313
+ let jsonCount = 0;
314
+ for (const [key, val] of Object.entries(bundle.docs ?? {})) {
315
+ if (val == null)
316
+ continue;
317
+ writeFileSync(join(outDir, `${key}.md`), val, 'utf8');
318
+ mdCount++;
319
+ }
320
+ for (const [key, val] of Object.entries(bundle.sources ?? {})) {
321
+ if (val == null)
322
+ continue;
323
+ writeFileSync(join(outDir, `${key}.json`), JSON.stringify(val, null, 2) + '\n', 'utf8');
324
+ jsonCount++;
325
+ }
326
+ writeFileSync(join(outDir, 'index.json'), JSON.stringify({ version: bundle.version, generated_at: bundle.generated_at, index: bundle.index }, null, 2) + '\n', 'utf8');
327
+ console.log(`✓ Pulled the Octwin platform KB → ${outDir}`);
328
+ console.log(` ${mdCount} markdown docs + ${jsonCount} JSON catalogs (reference version ${bundle.version ?? '?'})`);
329
+ console.log(' The octwin-pack authoring skill reads these as the source of truth for what the platform supports.');
330
+ }
287
331
  function cmdTest(flags) {
288
332
  const packDir = resolve(flags.dir ?? '.');
289
333
  const { id, version } = localValidate(packDir);
@@ -300,9 +344,11 @@ function help() {
300
344
  octwin whoami [--url <url>] [--tenant <slug>] # verify the token works
301
345
  octwin deploy [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>] [--seed]
302
346
  octwin status [--dir .] [--url <url>] [--tenant <slug>] [--project <slug>] [--token <t>]
347
+ octwin platform-kb [pull] [--dir .] [--url <url>] [--tenant <slug>] [--token <t>]
303
348
  octwin test [--dir .]
304
349
 
305
350
  Get a deploy token: console → your workspace → Settings → API tokens → Generate.
351
+ octwin platform-kb pull → writes the platform capability reference into .octwin/platform-kb/ (for the octwin-pack skill).
306
352
  Config (deploy): flags > pack.json > env (PACK_PLATFORM_URL/PACK_TENANT/PACK_PROJECT/PACK_TOKEN) > saved login.`);
307
353
  }
308
354
  async function main() {
@@ -327,6 +373,9 @@ async function main() {
327
373
  case 'status':
328
374
  await cmdStatus(flags);
329
375
  break;
376
+ case 'platform-kb':
377
+ await cmdPlatformKb(flags);
378
+ break;
330
379
  case 'test':
331
380
  cmdTest(flags);
332
381
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octwin-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Octwin external-pack developer CLI (by CEQUENS) — scaffold, validate, deploy, and check pure-YAML packs on your tenant.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,6 +29,8 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "keywords": ["octwin", "cequens", "cli", "whatsapp", "chatbot", "pack"],
32
+ "keywords": ["octwin", "cequens", "cli", "whatsapp", "chatbot", "pack", "conversational-ai", "yaml"],
33
+ "author": "CEQUENS",
34
+ "homepage": "https://www.npmjs.com/package/octwin-cli",
33
35
  "license": "MIT"
34
36
  }