opencode-manager 0.3.1 → 0.4.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.
- package/PROJECT-SUMMARY.md +104 -24
- package/README.md +335 -7
- package/bun.lock +17 -1
- package/manage_opencode_projects.py +71 -66
- package/package.json +6 -3
- package/src/bin/opencode-manager.ts +133 -3
- package/src/cli/backup.ts +324 -0
- package/src/cli/commands/chat.ts +322 -0
- package/src/cli/commands/projects.ts +222 -0
- package/src/cli/commands/sessions.ts +495 -0
- package/src/cli/commands/tokens.ts +168 -0
- package/src/cli/commands/tui.ts +36 -0
- package/src/cli/errors.ts +259 -0
- package/src/cli/formatters/json.ts +184 -0
- package/src/cli/formatters/ndjson.ts +71 -0
- package/src/cli/formatters/table.ts +837 -0
- package/src/cli/index.ts +169 -0
- package/src/cli/output.ts +661 -0
- package/src/cli/resolvers.ts +249 -0
- package/src/lib/clipboard.ts +37 -0
- package/src/lib/opencode-data.ts +380 -1
- package/src/lib/search.ts +170 -0
- package/src/{opencode-tui.tsx → tui/app.tsx} +739 -105
- package/src/tui/args.ts +92 -0
- package/src/tui/index.tsx +46 -0
package/src/tui/args.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI argument parsing module.
|
|
3
|
+
*
|
|
4
|
+
* Exports `parseArgs()` for parsing command-line arguments
|
|
5
|
+
* and `TUIOptions` type for TUI configuration.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { resolve } from "node:path"
|
|
9
|
+
import { DEFAULT_ROOT } from "../lib/opencode-data"
|
|
10
|
+
|
|
11
|
+
export interface TUIOptions {
|
|
12
|
+
root: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Print TUI usage/help text to console.
|
|
17
|
+
*/
|
|
18
|
+
export function printUsage(): void {
|
|
19
|
+
console.log(`OpenCode Metadata TUI
|
|
20
|
+
Usage: bun run tui [-- --root /path/to/storage]
|
|
21
|
+
|
|
22
|
+
Key bindings:
|
|
23
|
+
Tab / 1 / 2 Switch between projects and sessions
|
|
24
|
+
/ Start search (active tab)
|
|
25
|
+
X Clear search
|
|
26
|
+
? / H Toggle help
|
|
27
|
+
R Reload (and refresh token cache)
|
|
28
|
+
Q Quit the application
|
|
29
|
+
|
|
30
|
+
Projects view:
|
|
31
|
+
Space Toggle selection
|
|
32
|
+
A Select all (visible)
|
|
33
|
+
M Toggle missing-only filter
|
|
34
|
+
D Delete selected (with confirmation)
|
|
35
|
+
Enter Jump to Sessions for project
|
|
36
|
+
Esc Clear selection
|
|
37
|
+
|
|
38
|
+
Sessions view:
|
|
39
|
+
Space Toggle selection
|
|
40
|
+
A Select all (visible)
|
|
41
|
+
S Toggle sort (updated/created)
|
|
42
|
+
V View chat history for selected session
|
|
43
|
+
F Search across all chat content in sessions
|
|
44
|
+
Shift+R Rename session
|
|
45
|
+
M Move selected sessions to project
|
|
46
|
+
P Copy selected sessions to project
|
|
47
|
+
Y Copy session ID to clipboard
|
|
48
|
+
C Clear project filter
|
|
49
|
+
D Delete selected (with confirmation)
|
|
50
|
+
Enter Show details
|
|
51
|
+
Esc Clear selection
|
|
52
|
+
|
|
53
|
+
Chat search (when open):
|
|
54
|
+
Type Enter search query
|
|
55
|
+
Enter Search / open selected result
|
|
56
|
+
Up/Down Navigate results
|
|
57
|
+
Esc Close search
|
|
58
|
+
|
|
59
|
+
Chat viewer (when open):
|
|
60
|
+
Esc Close viewer
|
|
61
|
+
Up/Down Navigate messages
|
|
62
|
+
PgUp/PgDn Jump 10 messages
|
|
63
|
+
Home/End Jump to first/last message
|
|
64
|
+
Y Copy message content to clipboard
|
|
65
|
+
`)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parse command-line arguments for TUI options.
|
|
70
|
+
*/
|
|
71
|
+
export function parseArgs(argv: string[] = process.argv.slice(2)): TUIOptions {
|
|
72
|
+
let root = DEFAULT_ROOT
|
|
73
|
+
|
|
74
|
+
for (let idx = 0; idx < argv.length; idx += 1) {
|
|
75
|
+
const token = argv[idx]
|
|
76
|
+
if (token === "--root" && argv[idx + 1]) {
|
|
77
|
+
root = resolve(argv[idx + 1])
|
|
78
|
+
idx += 1
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
if (token === "--help" || token === "-h") {
|
|
82
|
+
printUsage()
|
|
83
|
+
process.exit(0)
|
|
84
|
+
}
|
|
85
|
+
if (token === "--version" || token === "-V") {
|
|
86
|
+
console.log("0.4.0")
|
|
87
|
+
process.exit(0)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { root }
|
|
92
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI entrypoint module.
|
|
3
|
+
*
|
|
4
|
+
* Exports `launchTUI(args)` for starting the OpenCode Metadata TUI.
|
|
5
|
+
* This module serves as the public interface for launching the TUI,
|
|
6
|
+
* allowing both direct execution and programmatic invocation from CLI.
|
|
7
|
+
*
|
|
8
|
+
* Imports the App component from `./app.tsx` for rendering.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createRoot } from "@opentui/react"
|
|
12
|
+
import { createCliRenderer } from "@opentui/core"
|
|
13
|
+
|
|
14
|
+
import { App } from "./app"
|
|
15
|
+
import { DEFAULT_ROOT } from "../lib/opencode-data"
|
|
16
|
+
import { parseArgs, printUsage, type TUIOptions } from "./args"
|
|
17
|
+
|
|
18
|
+
// Re-export args module for external consumers
|
|
19
|
+
export { parseArgs, printUsage, type TUIOptions }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Launch the TUI with the given options.
|
|
23
|
+
* This is the main entrypoint for starting the TUI.
|
|
24
|
+
*/
|
|
25
|
+
export async function launchTUI(options?: Partial<TUIOptions>): Promise<void> {
|
|
26
|
+
const root = options?.root ?? DEFAULT_ROOT
|
|
27
|
+
const renderer = await createCliRenderer()
|
|
28
|
+
createRoot(renderer).render(<App root={root} />)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Bootstrap the TUI from command-line arguments.
|
|
33
|
+
* Parses args and launches the TUI.
|
|
34
|
+
*
|
|
35
|
+
* @param argv - Optional argument array (defaults to process.argv.slice(2))
|
|
36
|
+
*/
|
|
37
|
+
export async function bootstrap(argv?: string[]): Promise<void> {
|
|
38
|
+
const options = parseArgs(argv)
|
|
39
|
+
await launchTUI(options)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Auto-bootstrap when run directly
|
|
43
|
+
bootstrap().catch((error) => {
|
|
44
|
+
console.error(error)
|
|
45
|
+
process.exit(1)
|
|
46
|
+
})
|