@openturtle/cli 0.3.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.
@@ -0,0 +1,69 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { initProjectStore, upsertEvent } from '../core/store.js';
5
+ export function candidateHistoryPaths(target, homeDir = os.homedir()) {
6
+ if (target === 'qoder') {
7
+ return [
8
+ path.join(homeDir, '.qoder', 'logs', 'runs'),
9
+ path.join(homeDir, '.qoder', 'projects'),
10
+ path.join(homeDir, '.qoderwork', 'projects'),
11
+ ];
12
+ }
13
+ if (target === 'kiro') {
14
+ return [path.join(homeDir, '.kiro', 'sessions', 'cli')];
15
+ }
16
+ if (target === 'codex')
17
+ return [path.join(homeDir, '.codex', 'sessions')];
18
+ if (target === 'claude')
19
+ return [path.join(homeDir, '.claude', 'projects')];
20
+ return [];
21
+ }
22
+ export function importHistory(target, workspace = process.cwd()) {
23
+ const store = initProjectStore(workspace);
24
+ const paths = candidateHistoryPaths(target);
25
+ let imported = 0;
26
+ for (const filePath of paths.flatMap((item) => walkFiles(item))) {
27
+ const stat = safeStat(filePath);
28
+ if (!stat || stat.size <= 0)
29
+ continue;
30
+ const dedupeKey = `${target}:agent.session_imported:${filePath}:${stat.mtimeMs}`;
31
+ const result = upsertEvent(store, {
32
+ type: 'agent.session_imported',
33
+ source: target,
34
+ workspacePath: workspace,
35
+ summary: `Imported ${path.basename(filePath)}`,
36
+ rawJson: { filePath, size: stat.size, mtimeMs: stat.mtimeMs },
37
+ occurredAt: new Date(stat.mtimeMs).toISOString(),
38
+ dedupeKey,
39
+ });
40
+ if (result.inserted)
41
+ imported += 1;
42
+ }
43
+ return { imported, paths };
44
+ }
45
+ function walkFiles(root) {
46
+ let entries;
47
+ try {
48
+ entries = fs.readdirSync(root, { withFileTypes: true });
49
+ }
50
+ catch {
51
+ return [];
52
+ }
53
+ return entries.flatMap((entry) => {
54
+ const entryPath = path.join(root, entry.name);
55
+ if (entry.isDirectory())
56
+ return walkFiles(entryPath);
57
+ if (entry.isFile() && /\.(jsonl|json|log)$/i.test(entry.name))
58
+ return [entryPath];
59
+ return [];
60
+ });
61
+ }
62
+ function safeStat(filePath) {
63
+ try {
64
+ return fs.statSync(filePath);
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@openturtle/cli",
3
+ "version": "0.3.0",
4
+ "description": "OpenTurtle collaboration, knowledge, meeting, and agent CLI",
5
+ "keywords": [
6
+ "openturtle",
7
+ "collaboration",
8
+ "knowledge",
9
+ "meeting",
10
+ "cli"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/aka-danielZhang/openturtle-os.git",
15
+ "directory": "packages/frontend/apps/cli"
16
+ },
17
+ "homepage": "https://github.com/aka-danielZhang/openturtle-os/tree/master/packages/frontend/apps/cli",
18
+ "bugs": "https://github.com/aka-danielZhang/openturtle-os/issues",
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=22.5.0"
22
+ },
23
+ "bin": {
24
+ "ot": "dist/index.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "prepublishOnly": "pnpm run test && pnpm run build",
37
+ "test": "tsx --test test/*.test.ts",
38
+ "dev": "tsx src/index.ts"
39
+ },
40
+ "dependencies": {
41
+ "commander": "^14.0.2"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^24.12.0",
45
+ "tsx": "^4.19.0",
46
+ "typescript": "~5.9.3"
47
+ }
48
+ }