mythik-cli 0.1.1 → 0.1.2

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 +168 -40
  2. package/dist/cli.js +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # mythik-cli
2
2
 
3
- Command-line tooling for Mythik specs.
3
+ The AI-first surface to Mythik. The `mythik` command and its
4
+ programmatic sibling (`mythik-cli/api`) are how an AI agent — or a
5
+ human — reads, validates, patches, versions, and promotes Mythik
6
+ specs.
7
+
8
+ > See [the framework README on GitHub](https://github.com/mldixdev/mythik#readme)
9
+ > for the full Mythik architecture and design philosophy. This file
10
+ > documents what `mythik-cli` gives you and how to use it.
11
+
12
+ ---
13
+
14
+ ## What Mythik is, briefly
15
+
16
+ Mythik is an **AI-first, spec-driven framework**. Every UI screen and
17
+ API endpoint lives as a JSON spec in a database — not a `.tsx` file
18
+ in a repo. Apps grow by adding rows, not files. The framework
19
+ validates every change atomically, versions everything automatically,
20
+ and promotes between environments (`dev`, `staging`, `production`) by
21
+ atomic pointer move. Your favorite AI agent drives the full workflow
22
+ through this CLI — no GUI in the loop.
4
23
 
5
24
  ## Install
6
25
 
@@ -14,58 +33,167 @@ The package exposes the `mythik` binary:
14
33
  npx mythik --help
15
34
  ```
16
35
 
17
- ## Common Commands
18
-
19
- ```bash
20
- npx mythik docs path
21
- npx mythik docs copy ./mythik-docs
22
- npx mythik manifest home
23
- npx mythik elements home root,submit-button
24
- npx mythik validate home
25
- npx mythik patch home --from-file patch.json
26
- npx mythik push home --from-file home.json
27
- npx mythik pull home
28
- npx mythik lint --from-file home.json
29
- npx mythik contract --app app-demo --api api-demo
36
+ ## The canonical workflow
37
+
38
+ The Mythik loop is four steps, all served by this package:
39
+
40
+ ```
41
+ ┌──────────────────────────────────────────────────┐
42
+ │ │
43
+ ▼ │
44
+ manifest ──▶ elements ──▶ patch ──▶ observe
45
+ (read (read just (RFC 6902 (the
46
+ structure) what you diff; next
47
+ need) atomic manifest)
48
+ validation
49
+ on push)
50
+ ```
51
+
52
+ Each step is one command:
53
+
54
+ ```bash
55
+ # 1. Read structure
56
+ $ npx mythik manifest task-manager
57
+
58
+ # 2. Read just the elements you need (use --toon for token-efficient output)
59
+ $ npx mythik elements task-manager task-row,new-task-form --json
60
+
61
+ # 3. Apply a patch (validates atomically; rejected if it breaks the contract)
62
+ $ npx mythik patch task-manager --from-file add-due-date.json --author claude
63
+ ✓ Patch applied. v3 → v4. 4 elements modified.
64
+
65
+ # 4. Observe — read the new structure
66
+ $ npx mythik manifest task-manager
67
+ ```
68
+
69
+ When `patch` fails (the candidate breaks the contract), the gate
70
+ returns structured diagnostics: rule IDs, paths, suggestion text. The
71
+ agent reads the error, refines the patch, and retries. No half-baked
72
+ write ever lands.
73
+
74
+ ## Moving across environments
75
+
76
+ `dev`, `staging`, `production` are not deploy targets — they are
77
+ pointers to specific versions of a spec. Move them with `envs`;
78
+ promote across them atomically with `promote`:
79
+
80
+ ```bash
81
+ # Move the dev pointer to the new version
82
+ $ npx mythik envs task-manager --set dev=4 --author claude
83
+
84
+ # Promote dev → production (validates atomically; rejected if inconsistent)
85
+ $ npx mythik promote task-manager --from dev --to production --confirm --author mldix
86
+ ✓ Validated against contract.
87
+ ✓ Cross-screen consistency check passed.
88
+ ✓ Pointer moved: production v3 → v4.
89
+
90
+ # List current environment pointers
91
+ $ npx mythik envs task-manager --json
92
+ ```
93
+
94
+ ## Read-only previews
95
+
96
+ For drafts and audits *outside* the canonical loop:
97
+
98
+ ```bash
99
+ # Validate a stored spec (read-only check; no write)
100
+ $ npx mythik validate task-manager
101
+
102
+ # Lint a local file (draft not yet pushed) or a directory
103
+ $ npx mythik lint --from-file draft.json
104
+ $ npx mythik lint --from-dir ./specs
105
+
106
+ # Cross-validate a frontend spec against an ApiSpec (catches drift before deploy)
107
+ $ npx mythik contract --app app-demo --api api-demo
108
+ ```
109
+
110
+ All three run the same validators that `patch` and `promote` enforce
111
+ atomically — useful when constructing complex multi-step changes
112
+ locally before committing to a push.
113
+
114
+ ## History and rollback
115
+
116
+ ```bash
117
+ # Show version history with structural diffs
118
+ $ npx mythik history task-manager
119
+
120
+ # Compare two versions or two environments
121
+ $ npx mythik diff task-manager 3 4
122
+ $ npx mythik diff task-manager dev production
123
+
124
+ # Always-forward rollback (creates a new version with old content)
125
+ $ npx mythik rollback task-manager --to 3 --author mldix
30
126
  ```
31
-
32
- Use `--json` for machine-readable output and `--toon` where supported for token-efficient agent workflows.
33
-
34
- ## AI Documentation
35
-
36
- `mythik` bundles the AI documentation corpus inside the core package. Use:
37
-
38
- ```bash
39
- npx mythik docs path
40
- ```
41
-
42
- Point the AI agent at the printed directory before asking it to create or modify Mythik specs. To copy the docs into a
43
- project-local folder:
44
-
45
- ```bash
46
- npx mythik docs copy ./mythik-docs
47
- ```
127
+
128
+ Rollback never rewrites history. The new version `v5` will hold the
129
+ content of `v3`. `v4` stays in the history with its own author and
130
+ timestamp.
131
+
132
+ ## Output formats
133
+
134
+ | Flag | When to use |
135
+ |---|---|
136
+ | `--json` | Machine-readable output for scripts and IDE integrations |
137
+ | `--toon` (where supported) | Token-efficient agent reads — same shape, fewer tokens, useful for paginating large manifests or element catalogs |
48
138
 
49
139
  ## Programmatic API
50
140
 
51
- Use `mythik-cli/api` when a script, IDE integration, or AI agent should avoid shell quoting issues:
141
+ When a script, IDE integration, or AI agent should avoid shell
142
+ quoting, use `mythik-cli/api`:
52
143
 
53
144
  ```ts
54
- import { runPatch, runPush, runLint } from 'mythik-cli/api';
145
+ import { runPatch, runValidate, runPromote } from 'mythik-cli/api';
55
146
 
56
- await runPatch({
57
- screen: 'home',
58
- fromFile: 'patch.json',
147
+ const result = await runPatch({
148
+ screen: 'task-manager',
149
+ fromFile: 'add-due-date.json',
150
+ author: 'claude',
59
151
  json: true,
60
152
  });
153
+
154
+ if (!result.ok) {
155
+ console.error(result.diagnostics);
156
+ }
61
157
  ```
62
158
 
63
- The programmatic API uses the same implementation path as the CLI.
159
+ The programmatic API uses the same implementation path as the binary —
160
+ nothing is special-cased. Whatever the CLI does, the API does
161
+ identically.
64
162
 
65
- ## License
163
+ ## Bundled AI documentation
66
164
 
67
- Apache-2.0.
165
+ The `mythik` package (peer dependency) ships canonical AI docs at
166
+ `node_modules/mythik/docs/`. Locate or copy them:
167
+
168
+ ```bash
169
+ $ npx mythik docs path
170
+ /your-project/node_modules/mythik/docs
171
+
172
+ $ npx mythik docs copy ./mythik-docs
173
+ ```
174
+
175
+ Point your AI agent at the printed path before asking it to author or
176
+ modify specs. Inside that directory:
177
+
178
+ - `consumer/ai-context.md` — spec-generation primer (rules and traps)
179
+ - `consumer/ai-context-primitives.md` — every primitive's props
180
+ - `consumer/reference-doc.md` — full rule catalog
181
+ - `wiki/compiled/` — atomic per-concept articles (one page per action,
182
+ primitive, rule, expression) optimized for AI lookup
183
+ - `llms.txt` — index for AI tools that read it
184
+
185
+ ## Related packages
186
+
187
+ - [`mythik`](https://github.com/mldixdev/mythik/tree/main/packages/core#readme) — the runtime this CLI manipulates
188
+ - [`mythik-react`](https://github.com/mldixdev/mythik/tree/main/packages/react#readme) — render the specs as a React app
189
+ - [`mythik-server`](https://github.com/mldixdev/mythik/tree/main/packages/server#readme) — declarative REST server from an `ApiSpec`
68
190
 
69
191
  ## Status
70
192
 
71
- v0.1.1 public release. The binary name is `mythik`; the npm package name is `mythik-cli`.
193
+ `v0.1.2` public release. The binary name is `mythik`; the npm package
194
+ name is `mythik-cli`. APIs are documented for real-world feedback as
195
+ the framework evolves.
196
+
197
+ ## License
198
+
199
+ Apache-2.0.
package/dist/cli.js CHANGED
@@ -26,7 +26,7 @@ const program = new Command();
26
26
  program
27
27
  .name('mythik')
28
28
  .description('Mythik CLI — manage specs via SpecEngine')
29
- .version('0.1.1');
29
+ .version('0.1.2');
30
30
  program
31
31
  .command('manifest <screen>')
32
32
  .description('Show structural tree of a screen spec')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythik-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Command-line and programmatic tooling for validating, linting, pushing, patching, and versioning Mythik specs.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "@inquirer/prompts": "^7.0.0",
47
47
  "@toon-format/toon": "^2.1.0",
48
48
  "commander": "^13.0.0",
49
- "mythik": "0.1.1"
49
+ "mythik": "0.1.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "^25.5.2"