@oxprotocol/cli 0.1.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.
Files changed (104) hide show
  1. package/LICENSE +189 -0
  2. package/README.md +73 -0
  3. package/dist/cli.d.ts +15 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +109 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/create.d.ts +6 -0
  8. package/dist/commands/create.d.ts.map +1 -0
  9. package/dist/commands/create.js +212 -0
  10. package/dist/commands/create.js.map +1 -0
  11. package/dist/commands/dev.d.ts +2 -0
  12. package/dist/commands/dev.d.ts.map +1 -0
  13. package/dist/commands/dev.js +191 -0
  14. package/dist/commands/dev.js.map +1 -0
  15. package/dist/commands/doctor.d.ts +16 -0
  16. package/dist/commands/doctor.d.ts.map +1 -0
  17. package/dist/commands/doctor.js +197 -0
  18. package/dist/commands/doctor.js.map +1 -0
  19. package/dist/commands/install-url.d.ts +20 -0
  20. package/dist/commands/install-url.d.ts.map +1 -0
  21. package/dist/commands/install-url.js +236 -0
  22. package/dist/commands/install-url.js.map +1 -0
  23. package/dist/commands/install.d.ts +13 -0
  24. package/dist/commands/install.d.ts.map +1 -0
  25. package/dist/commands/install.js +411 -0
  26. package/dist/commands/install.js.map +1 -0
  27. package/dist/commands/keygen.d.ts +13 -0
  28. package/dist/commands/keygen.d.ts.map +1 -0
  29. package/dist/commands/keygen.js +40 -0
  30. package/dist/commands/keygen.js.map +1 -0
  31. package/dist/commands/login.d.ts +21 -0
  32. package/dist/commands/login.d.ts.map +1 -0
  33. package/dist/commands/login.js +224 -0
  34. package/dist/commands/login.js.map +1 -0
  35. package/dist/commands/logout.d.ts +17 -0
  36. package/dist/commands/logout.d.ts.map +1 -0
  37. package/dist/commands/logout.js +70 -0
  38. package/dist/commands/logout.js.map +1 -0
  39. package/dist/commands/pack.d.ts +12 -0
  40. package/dist/commands/pack.d.ts.map +1 -0
  41. package/dist/commands/pack.js +94 -0
  42. package/dist/commands/pack.js.map +1 -0
  43. package/dist/commands/protocol-register.d.ts +29 -0
  44. package/dist/commands/protocol-register.d.ts.map +1 -0
  45. package/dist/commands/protocol-register.js +231 -0
  46. package/dist/commands/protocol-register.js.map +1 -0
  47. package/dist/commands/publish.d.ts +17 -0
  48. package/dist/commands/publish.d.ts.map +1 -0
  49. package/dist/commands/publish.js +188 -0
  50. package/dist/commands/publish.js.map +1 -0
  51. package/dist/commands/token.d.ts +17 -0
  52. package/dist/commands/token.d.ts.map +1 -0
  53. package/dist/commands/token.js +110 -0
  54. package/dist/commands/token.js.map +1 -0
  55. package/dist/commands/whoami.d.ts +13 -0
  56. package/dist/commands/whoami.d.ts.map +1 -0
  57. package/dist/commands/whoami.js +77 -0
  58. package/dist/commands/whoami.js.map +1 -0
  59. package/dist/index.d.ts +26 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +22 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/lib/broadcast.d.ts +41 -0
  64. package/dist/lib/broadcast.d.ts.map +1 -0
  65. package/dist/lib/broadcast.js +45 -0
  66. package/dist/lib/broadcast.js.map +1 -0
  67. package/dist/lib/host-adapter.d.ts +72 -0
  68. package/dist/lib/host-adapter.d.ts.map +1 -0
  69. package/dist/lib/host-adapter.js +193 -0
  70. package/dist/lib/host-adapter.js.map +1 -0
  71. package/dist/lib/host-detect.d.ts +60 -0
  72. package/dist/lib/host-detect.d.ts.map +1 -0
  73. package/dist/lib/host-detect.js +479 -0
  74. package/dist/lib/host-detect.js.map +1 -0
  75. package/dist/lib/oxp-url.d.ts +34 -0
  76. package/dist/lib/oxp-url.d.ts.map +1 -0
  77. package/dist/lib/oxp-url.js +74 -0
  78. package/dist/lib/oxp-url.js.map +1 -0
  79. package/dist/lib/vsx-install.d.ts +41 -0
  80. package/dist/lib/vsx-install.d.ts.map +1 -0
  81. package/dist/lib/vsx-install.js +74 -0
  82. package/dist/lib/vsx-install.js.map +1 -0
  83. package/dist/util.d.ts +10 -0
  84. package/dist/util.d.ts.map +1 -0
  85. package/dist/util.js +64 -0
  86. package/dist/util.js.map +1 -0
  87. package/package.json +48 -0
  88. package/templates/hello-code/README.md +39 -0
  89. package/templates/hello-code/oxp.json +14 -0
  90. package/templates/hello-code/package.json +18 -0
  91. package/templates/hello-code/src/extension.ts +17 -0
  92. package/templates/hello-code/tsconfig.json +20 -0
  93. package/templates/hello-html/README.md +18 -0
  94. package/templates/hello-html/oxp.json +14 -0
  95. package/templates/hello-html/ui/index.html +43 -0
  96. package/templates/hello-rust/Cargo.toml +19 -0
  97. package/templates/hello-rust/README.md +50 -0
  98. package/templates/hello-rust/oxp.json +22 -0
  99. package/templates/hello-rust/src/lib.rs +111 -0
  100. package/templates/hello-rust/wit/deps/oxp-host/oxp-host.wit +136 -0
  101. package/templates/hello-rust/wit/extension.wit +71 -0
  102. package/templates/hello-tree/README.md +15 -0
  103. package/templates/hello-tree/oxp.json +14 -0
  104. package/templates/hello-tree/ui/tree.json +27 -0
@@ -0,0 +1,136 @@
1
+ // oxp:host@0.1.0
2
+ //
3
+ // Capability interfaces the OXP host provides to extension components.
4
+ // Every interface here is a *gated* import: an extension only resolves
5
+ // the interfaces named in its manifest's `permissions` list, and even
6
+ // then individual operations are filtered by the scope passed to the
7
+ // host capability broker.
8
+ //
9
+ // Stability: pinned. Breaking changes go to oxp:host@0.2.0 and require
10
+ // a coordinated runtime + manifest spec bump.
11
+
12
+ package oxp:host@0.1.0;
13
+
14
+ // ─────────────────────────────────────────────────────────────────────
15
+ // Common types
16
+ // ─────────────────────────────────────────────────────────────────────
17
+
18
+ interface types {
19
+ // Opaque, host-issued handle. Extensions never construct these.
20
+ type handle = u64;
21
+
22
+ record diagnostic {
23
+ code: string,
24
+ message: string,
25
+ }
26
+ }
27
+
28
+ // ─────────────────────────────────────────────────────────────────────
29
+ // log — always available, never gated
30
+ // ─────────────────────────────────────────────────────────────────────
31
+
32
+ interface log {
33
+ enum level { trace, debug, info, warn, error }
34
+ log: func(lvl: level, message: string);
35
+ }
36
+
37
+ // ─────────────────────────────────────────────────────────────────────
38
+ // storage — always available; namespaced per (publisher, slug)
39
+ // ─────────────────────────────────────────────────────────────────────
40
+
41
+ interface storage {
42
+ get: func(key: string) -> option<list<u8>>;
43
+ set: func(key: string, value: list<u8>);
44
+ delete: func(key: string);
45
+ keys: func() -> list<string>;
46
+ }
47
+
48
+ // ─────────────────────────────────────────────────────────────────────
49
+ // ui — always available; the host renders, the component owns state
50
+ // ─────────────────────────────────────────────────────────────────────
51
+
52
+ interface ui {
53
+ // Push a serialized oxp-ui-v1 tree (msgpack or JSON; host decides).
54
+ render: func(tree: list<u8>);
55
+
56
+ // Update a status-bar item this extension owns.
57
+ set-status: func(text: string, tooltip: option<string>);
58
+
59
+ // Show a toast notification. Returns the user's choice if buttons given.
60
+ notify: func(message: string, buttons: list<string>) -> option<string>;
61
+ }
62
+
63
+ // ─────────────────────────────────────────────────────────────────────
64
+ // fs — gated by manifest.permissions[fs.read | fs.write | fs.delete]
65
+ // paths are pre-filtered against permission scope by the host
66
+ // ─────────────────────────────────────────────────────────────────────
67
+
68
+ interface fs {
69
+ variant fs-error {
70
+ not-found,
71
+ forbidden(string), // path outside granted scope
72
+ io(string),
73
+ too-large(u64), // bytes
74
+ }
75
+
76
+ record file-stat {
77
+ size: u64,
78
+ is-dir: bool,
79
+ mtime-ms: u64,
80
+ }
81
+
82
+ read-file: func(path: string) -> result<list<u8>, fs-error>;
83
+ write-file: func(path: string, bytes: list<u8>) -> result<_, fs-error>;
84
+ delete: func(path: string) -> result<_, fs-error>;
85
+ stat: func(path: string) -> result<file-stat, fs-error>;
86
+ list-dir: func(path: string) -> result<list<string>, fs-error>;
87
+ }
88
+
89
+ // ─────────────────────────────────────────────────────────────────────
90
+ // net — gated by manifest.permissions[net.fetch]
91
+ // origins are pre-filtered against permission scope by the host
92
+ // ─────────────────────────────────────────────────────────────────────
93
+
94
+ interface net {
95
+ record http-request {
96
+ method: string,
97
+ url: string,
98
+ headers: list<tuple<string, string>>,
99
+ body: option<list<u8>>,
100
+ }
101
+
102
+ record http-response {
103
+ status: u16,
104
+ headers: list<tuple<string, string>>,
105
+ body: list<u8>,
106
+ }
107
+
108
+ variant net-error {
109
+ forbidden(string), // origin not in granted scope
110
+ timeout,
111
+ transport(string),
112
+ too-large(u64),
113
+ }
114
+
115
+ fetch: func(req: http-request) -> result<http-response, net-error>;
116
+ }
117
+
118
+ // ─────────────────────────────────────────────────────────────────────
119
+ // secrets — gated by manifest.permissions[secrets.read | secrets.write]
120
+ // keys are namespaced per (publisher, slug); host stores at-rest enc.
121
+ // ─────────────────────────────────────────────────────────────────────
122
+
123
+ interface secrets {
124
+ get: func(key: string) -> option<string>;
125
+ set: func(key: string, value: string);
126
+ delete: func(key: string);
127
+ }
128
+
129
+ // ─────────────────────────────────────────────────────────────────────
130
+ // commands — gated by manifest.permissions[commands.executeHost]
131
+ // ─────────────────────────────────────────────────────────────────────
132
+
133
+ interface commands {
134
+ // Run a host-registered command by id. Args are JSON-encoded.
135
+ execute: func(id: string, args-json: string) -> result<string, string>;
136
+ }
@@ -0,0 +1,71 @@
1
+ // oxp:extension@0.1.0
2
+ //
3
+ // Interfaces an OXP extension component must export and the world
4
+ // it targets. The host calls these functions; the component never
5
+ // drives the host loop directly.
6
+ //
7
+ // Stability: pinned. Breaking changes go to oxp:extension@0.2.0 and
8
+ // require a coordinated runtime + manifest spec bump.
9
+
10
+ package oxp:extension@0.1.0;
11
+
12
+ interface lifecycle {
13
+ record activate-ctx {
14
+ extension-id: string, // "@publisher/slug"
15
+ version: string, // semver
16
+ host: string, // "vscode" | "piye" | "cli" | …
17
+ host-version: string,
18
+ }
19
+
20
+ // Called once after install or reload, before any other export.
21
+ // Return err(reason) to abort activation.
22
+ activate: func(ctx: activate-ctx) -> result<_, string>;
23
+
24
+ // Called on uninstall, host shutdown, or eviction. Best effort —
25
+ // the host may kill the instance if this exceeds its fuel budget.
26
+ deactivate: func() -> result<_, string>;
27
+ }
28
+
29
+ interface ui-handler {
30
+ // Serialized oxp-ui-v1 event (msgpack or JSON; same encoding as render).
31
+ variant event-error {
32
+ unknown-target(string),
33
+ invalid-payload(string),
34
+ internal(string),
35
+ }
36
+
37
+ on-event: func(event: list<u8>) -> result<_, event-error>;
38
+ }
39
+
40
+ interface command-handler {
41
+ // Args + return are JSON-encoded for forward compatibility.
42
+ on-command: func(id: string, args-json: string) -> result<string, string>;
43
+ }
44
+
45
+ // ─────────────────────────────────────────────────────────────────────
46
+ // The single world OXP extensions target in spec v1.
47
+ //
48
+ // Imports listed here are the *maximum* a component may use. The
49
+ // concrete set actually linked at instantiate time is restricted by
50
+ // manifest.permissions; declaring an import here that is not granted
51
+ // will cause the component to be rejected at install with a clear
52
+ // "permission not granted" diagnostic — never a silent stub.
53
+ // ─────────────────────────────────────────────────────────────────────
54
+
55
+ world extension {
56
+ // always-on imports
57
+ import oxp:host/log@0.1.0;
58
+ import oxp:host/storage@0.1.0;
59
+ import oxp:host/ui@0.1.0;
60
+
61
+ // gated imports (unlocked by manifest.permissions)
62
+ import oxp:host/fs@0.1.0;
63
+ import oxp:host/net@0.1.0;
64
+ import oxp:host/secrets@0.1.0;
65
+ import oxp:host/commands@0.1.0;
66
+
67
+ // exports the host calls
68
+ export lifecycle;
69
+ export ui-handler;
70
+ export command-handler;
71
+ }
@@ -0,0 +1,15 @@
1
+ # __DISPLAY_NAME__
2
+
3
+ A V1 component-tree extension. The UI is a static `ui/tree.json` rendered by
4
+ the host through `@oxprotocol/ui/dom`. No HTML, no CSS, no JS — and on Piye-native
5
+ hosts, no DOM either.
6
+
7
+ ```sh
8
+ oxp dev # hot-reloads the tree on every save
9
+ oxp pack # produces a signed .tgz bundle
10
+ ```
11
+
12
+ Edit `ui/tree.json` to change the UI. The vocabulary is frozen at six nodes:
13
+ `box`, `stack`, `text`, `button`, `virtual-list`, `code`. Buttons emit a
14
+ `data-oxp-action` attribute that the host bridges to `host.dispatch(action)`
15
+ once the worker harness lands.
@@ -0,0 +1,14 @@
1
+ {
2
+ "specVersion": "1",
3
+ "id": "@__PUBLISHER__/__SLUG__",
4
+ "publisher": "__PUBLISHER__",
5
+ "version": "0.0.1",
6
+ "displayName": "__DISPLAY_NAME__",
7
+ "description": "OXP V1 component tree (Piye-native ready).",
8
+ "license": "MIT",
9
+ "categories": ["other"],
10
+ "engines": { "oxp": "^1.0.0" },
11
+ "main": { "ui": "ui/tree.json" },
12
+ "ui": { "components": "oxp-ui-v1", "preferredSurface": "panel" },
13
+ "permissions": []
14
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "kind": "stack",
3
+ "axis": "vertical",
4
+ "gap": 3,
5
+ "children": [
6
+ { "kind": "text", "value": "__DISPLAY_NAME__", "variant": "heading" },
7
+ {
8
+ "kind": "text",
9
+ "value": "Authored with the frozen V1 component vocabulary.",
10
+ "variant": "caption"
11
+ },
12
+ {
13
+ "kind": "stack",
14
+ "axis": "horizontal",
15
+ "gap": 2,
16
+ "children": [
17
+ { "kind": "button", "label": "Run", "action": "run", "variant": "primary" },
18
+ { "kind": "button", "label": "Cancel", "action": "cancel", "variant": "secondary" }
19
+ ]
20
+ },
21
+ {
22
+ "kind": "code",
23
+ "language": "json",
24
+ "value": "{ \"hello\": \"oxp-ui-v1\" }"
25
+ }
26
+ ]
27
+ }