@opencode-manager/ocm-cli 0.1.0 → 0.1.1
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/README.md +74 -0
- package/dist/ocm.js +48 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# ocm-cli
|
|
2
|
+
|
|
3
|
+
OpenCode Manager CLI and plugin package.
|
|
4
|
+
|
|
5
|
+
`ocm` lets a local OpenCode TUI attach to repos hosted by OpenCode Manager. It
|
|
6
|
+
can also mirror a local git repo up to Manager or pull a Manager repo back down
|
|
7
|
+
to the local working tree.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -g @opencode-manager/ocm-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package exposes the `ocm` binary and an OpenCode plugin entrypoint. Global
|
|
16
|
+
installs link the binary through the package manager. Local workspace installs
|
|
17
|
+
also create a best-effort `~/.local/bin/ocm` symlink.
|
|
18
|
+
|
|
19
|
+
## Login
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
ocm login <manager-url> [token]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The token is stored in macOS Keychain under the `opencode-manager` service. CLI
|
|
26
|
+
state is stored at `~/.config/opencode-manager/state.json`.
|
|
27
|
+
|
|
28
|
+
If `[token]` is omitted, `ocm login` reads it from hidden TTY input or stdin.
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ocm
|
|
34
|
+
ocm status
|
|
35
|
+
ocm list
|
|
36
|
+
ocm use <repoId|name>
|
|
37
|
+
ocm push [--force] [--create] [--yes]
|
|
38
|
+
ocm pull [--force]
|
|
39
|
+
ocm logout
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Running `ocm` with no command tries to match the current git repo's `origin`
|
|
43
|
+
against ready Manager repos. If one repo matches, it attaches OpenCode to that
|
|
44
|
+
Manager repo. If no repo matches, it falls back to the last selected repo, then
|
|
45
|
+
to local `opencode`.
|
|
46
|
+
|
|
47
|
+
`ocm use <repoId|name>` selects a Manager repo, remembers it as the last repo,
|
|
48
|
+
and attaches OpenCode to it.
|
|
49
|
+
|
|
50
|
+
`ocm push` uploads the current git repo to the matching Manager repo. Use
|
|
51
|
+
`--create` to create a Manager repo when no origin match exists, and `--yes` to
|
|
52
|
+
confirm creation in non-interactive shells.
|
|
53
|
+
|
|
54
|
+
`ocm pull` replaces the current working tree with the matching Manager repo. It
|
|
55
|
+
refuses to overwrite uncommitted local changes unless `--force` is passed.
|
|
56
|
+
|
|
57
|
+
## OpenCode plugin
|
|
58
|
+
|
|
59
|
+
The package default export is an OpenCode plugin entrypoint. Importing the
|
|
60
|
+
plugin performs a best-effort local `ocm` symlink install and then returns an
|
|
61
|
+
empty plugin object.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import ocm from '@opencode-manager/ocm-cli'
|
|
65
|
+
|
|
66
|
+
export default [ocm]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
- `opencode` available on `PATH`
|
|
72
|
+
- `git` and `tar` available on `PATH`
|
|
73
|
+
- macOS `security` CLI for Keychain-backed token storage
|
|
74
|
+
- An OpenCode Manager URL and bearer token
|
package/dist/ocm.js
CHANGED
|
@@ -344,8 +344,49 @@ function toTarget(last) {
|
|
|
344
344
|
directory: last.directory
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
+
// package.json
|
|
348
|
+
var package_default = {
|
|
349
|
+
name: "@opencode-manager/ocm-cli",
|
|
350
|
+
version: "0.1.1",
|
|
351
|
+
description: "OpenCode Manager CLI: attach a local OpenCode TUI to a Manager-hosted repo.",
|
|
352
|
+
license: "MIT",
|
|
353
|
+
repository: {
|
|
354
|
+
type: "git",
|
|
355
|
+
url: "https://github.com/chriswritescode-dev/opencode-manager.git",
|
|
356
|
+
directory: "ocm-cli"
|
|
357
|
+
},
|
|
358
|
+
type: "module",
|
|
359
|
+
main: "./dist/plugin.js",
|
|
360
|
+
exports: {
|
|
361
|
+
".": {
|
|
362
|
+
import: "./dist/plugin.js"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
bin: {
|
|
366
|
+
ocm: "./dist/ocm.js"
|
|
367
|
+
},
|
|
368
|
+
files: [
|
|
369
|
+
"dist",
|
|
370
|
+
"README.md"
|
|
371
|
+
],
|
|
372
|
+
scripts: {
|
|
373
|
+
build: "bun scripts/build.ts",
|
|
374
|
+
postinstall: "node scripts/postinstall.mjs || true",
|
|
375
|
+
typecheck: "tsc --noEmit",
|
|
376
|
+
test: "bun scripts/build.ts && vitest run",
|
|
377
|
+
"test:watch": "vitest",
|
|
378
|
+
prepublishOnly: "bun scripts/build.ts"
|
|
379
|
+
},
|
|
380
|
+
dependencies: {},
|
|
381
|
+
devDependencies: {
|
|
382
|
+
"@types/node": "^22.0.0",
|
|
383
|
+
typescript: "^5.5.0",
|
|
384
|
+
vitest: "^3.1.0"
|
|
385
|
+
}
|
|
386
|
+
};
|
|
347
387
|
|
|
348
388
|
// bin/ocm.ts
|
|
389
|
+
var VERSION = package_default.version;
|
|
349
390
|
var USAGE = `ocm - OpenCode Manager workspace launcher
|
|
350
391
|
|
|
351
392
|
Usage:
|
|
@@ -359,6 +400,7 @@ Usage:
|
|
|
359
400
|
ocm use <repoId|name> Attach to a specific repo and remember it as last
|
|
360
401
|
ocm push [--force] [--create] [--yes] Mirror $PWD to the matching Manager repo (or create one)
|
|
361
402
|
ocm pull [--force] Mirror the matching Manager repo over $PWD
|
|
403
|
+
ocm --version Show the installed ocm version
|
|
362
404
|
ocm --help Show this help
|
|
363
405
|
`;
|
|
364
406
|
function die(msg, code = 1) {
|
|
@@ -478,9 +520,11 @@ async function cmdLogout() {
|
|
|
478
520
|
async function cmdStatus() {
|
|
479
521
|
const state = readState();
|
|
480
522
|
if (!state) {
|
|
523
|
+
info(`version: ${VERSION}`);
|
|
481
524
|
info("no state. run: ocm login <url>");
|
|
482
525
|
return;
|
|
483
526
|
}
|
|
527
|
+
info(`version: ${VERSION}`);
|
|
484
528
|
info(`manager url: ${state.managerUrl}`);
|
|
485
529
|
info(`token in kc: ${getToken(state.managerUrl) ? "yes" : "no"}`);
|
|
486
530
|
if (state.lastRepoId !== undefined) {
|
|
@@ -672,6 +716,10 @@ async function main() {
|
|
|
672
716
|
process.stdout.write(USAGE);
|
|
673
717
|
return;
|
|
674
718
|
}
|
|
719
|
+
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
720
|
+
info(VERSION);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
675
723
|
try {
|
|
676
724
|
switch (cmd) {
|
|
677
725
|
case undefined:
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencode-manager/ocm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenCode Manager CLI: attach a local OpenCode TUI to a Manager-hosted repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "
|
|
8
|
+
"url": "https://github.com/chriswritescode-dev/opencode-manager.git",
|
|
9
9
|
"directory": "ocm-cli"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"ocm": "dist/ocm.js"
|
|
19
|
+
"ocm": "./dist/ocm.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|