kiosapi 0.1.6 → 0.1.8
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/dist/agent/run.js +310 -16
- package/dist/agent/schemas.js +56 -4
- package/dist/agent/team.js +38 -1
- package/dist/agent/tools.js +186 -15
- package/dist/api.js +54 -18
- package/dist/commands.js +256 -11
- package/dist/config.js +61 -3
- package/dist/help.js +46 -28
- package/dist/index.js +18 -2
- package/dist/session.js +393 -55
- package/dist/ui.js +5 -0
- package/package.json +2 -5
package/dist/config.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
4
|
const DEFAULT_BASE_URL = 'https://api.kiosapi.id';
|
|
5
|
-
const DIR = join(homedir(), '.kiosapi');
|
|
5
|
+
export const DIR = join(homedir(), '.kiosapi');
|
|
6
6
|
export const CONFIG_PATH = join(DIR, 'config.json');
|
|
7
|
+
export const CHECKPOINT_PATH = join(DIR, 'checkpoint.json');
|
|
8
|
+
export const TIM_DIR = join(DIR, 'tim');
|
|
7
9
|
/** Read only the on-disk config (ignores env overrides) — used before writing. */
|
|
8
10
|
function readFile() {
|
|
9
11
|
if (!existsSync(CONFIG_PATH))
|
|
@@ -47,3 +49,59 @@ export function clearKey() {
|
|
|
47
49
|
export function fileConfig() {
|
|
48
50
|
return readFile();
|
|
49
51
|
}
|
|
52
|
+
/** Persist a team config to ~/.kiosapi/tim/<nama>.json. */
|
|
53
|
+
export function saveTeamConfig(config) {
|
|
54
|
+
mkdirSync(TIM_DIR, { recursive: true });
|
|
55
|
+
writeFileSync(join(TIM_DIR, `${config.nama}.json`), `${JSON.stringify(config, null, 2)}\n`);
|
|
56
|
+
}
|
|
57
|
+
/** Load a team config by name; null if not found or invalid. */
|
|
58
|
+
export function loadTeamConfig(nama) {
|
|
59
|
+
const p = join(TIM_DIR, `${nama}.json`);
|
|
60
|
+
if (!existsSync(p))
|
|
61
|
+
return null;
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(readFileSync(p, 'utf8'));
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const PROJECT_CONFIG_NAME = 'kiosapi.json';
|
|
70
|
+
/**
|
|
71
|
+
* Walk up from cwd looking for kiosapi.json. Returns the first one found, or null.
|
|
72
|
+
* Walking up lets a project root config apply to all sub-directories.
|
|
73
|
+
*/
|
|
74
|
+
export function loadProjectConfig() {
|
|
75
|
+
let dir = process.cwd();
|
|
76
|
+
while (true) {
|
|
77
|
+
const p = join(dir, PROJECT_CONFIG_NAME);
|
|
78
|
+
if (existsSync(p)) {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(readFileSync(p, 'utf8'));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const parent = dirname(dir);
|
|
87
|
+
if (parent === dir)
|
|
88
|
+
break; // filesystem root
|
|
89
|
+
dir = parent;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/** Write a kiosapi.json into the current directory. Returns the full path written. */
|
|
94
|
+
export function initProjectConfig(config) {
|
|
95
|
+
const p = join(process.cwd(), PROJECT_CONFIG_NAME);
|
|
96
|
+
writeFileSync(p, `${JSON.stringify(config, null, 2)}\n`);
|
|
97
|
+
return p;
|
|
98
|
+
}
|
|
99
|
+
/** List all saved team names. */
|
|
100
|
+
export function listTeamConfigs() {
|
|
101
|
+
if (!existsSync(TIM_DIR))
|
|
102
|
+
return [];
|
|
103
|
+
return readdirSync(TIM_DIR)
|
|
104
|
+
.filter((f) => f.endsWith('.json'))
|
|
105
|
+
.map((f) => f.slice(0, -5))
|
|
106
|
+
.sort();
|
|
107
|
+
}
|
package/dist/help.js
CHANGED
|
@@ -19,43 +19,61 @@ export function printVersion() {
|
|
|
19
19
|
console.log(`kiosapi ${VERSION}`);
|
|
20
20
|
}
|
|
21
21
|
export function printHelp() {
|
|
22
|
-
console.log(`${bold('kiosapi')} — CLI Kiosapi.id
|
|
22
|
+
console.log(`${bold('kiosapi')} v${VERSION} — CLI Kiosapi.id
|
|
23
23
|
|
|
24
24
|
${bold('Penggunaan:')} kiosapi [perintah] [opsi]
|
|
25
25
|
Tanpa perintah → sesi interaktif (ketik tugas; perintah meta diawali "/").
|
|
26
26
|
|
|
27
|
-
${bold('
|
|
28
|
-
masuk
|
|
29
|
-
keluar
|
|
30
|
-
periksa
|
|
31
|
-
perbarui
|
|
32
|
-
model [--cari q]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
${bold('Akun & setelan:')}
|
|
28
|
+
masuk Simpan API key (kios_live_…); tampilkan saldo
|
|
29
|
+
keluar Hapus API key tersimpan
|
|
30
|
+
periksa Cek konektivitas, key, versi, tim & checkpoint
|
|
31
|
+
perbarui Update CLI ke versi npm terbaru
|
|
32
|
+
model [--cari q] Daftar model (--tools = hanya yang ada 🔧)
|
|
33
|
+
setel <k> <v> Atur setelan (model | base-url)
|
|
34
|
+
saldo Lihat saldo & pengeluaran bulan ini
|
|
35
|
+
pakai [--hari N] Ringkasan pemakaian N hari terakhir
|
|
36
|
+
isi <jumlah> Buat tagihan top-up (min 10.000)
|
|
37
|
+
|
|
38
|
+
${bold('Chat & tanya:')}
|
|
39
|
+
tanya "…" Tanya sekali (streaming); dukung pipe stdin & @file
|
|
40
|
+
ngobrol Mode percakapan interaktif (REPL)
|
|
41
|
+
|
|
42
|
+
${bold('Agen (butuh model 🔧):')}
|
|
43
|
+
rencana "…" Telusuri kode & susun rencana (read-only)
|
|
44
|
+
edit "…" Lakukan perubahan kode (tulis/edit file, tampilkan diff)
|
|
45
|
+
buat "…" Agen otonom: bangun proyek (tulis + jalankan)
|
|
46
|
+
lanjut [instruksi] Lanjutkan sesi agen yang terputus dari checkpoint
|
|
47
|
+
init Buat kiosapi.json (config per-project: model, mode, otomatis)
|
|
48
|
+
${dim('Opsi: -m <model>, --otomatis (lewati konfirmasi). Mendukung pipe stdin.')}
|
|
49
|
+
|
|
50
|
+
${bold('Tim multi-agen:')}
|
|
51
|
+
tim "…" Jalankan tim bawaan (perencana → pengkode → peninjau)
|
|
52
|
+
tim --pakai <nama> "…" Jalankan tim kustom tersimpan
|
|
53
|
+
tim --buat <nama> Buat tim kustom baru (wizard interaktif)
|
|
54
|
+
tim --daftar Lihat semua tim tersimpan
|
|
55
|
+
sambung <tool> Pakai Kiosapi di agen lain (aider, opencode, cursor…)
|
|
47
56
|
|
|
48
57
|
${bold('Multimodal:')}
|
|
49
|
-
gambar "…"
|
|
50
|
-
video "…"
|
|
51
|
-
lihat <file> "…"
|
|
58
|
+
gambar "…" Buat gambar → simpan file (-o file, --rasio, --opsi)
|
|
59
|
+
video "…" Buat video (async) → simpan file (--detik N)
|
|
60
|
+
lihat <file> "…" Tanya model vision tentang sebuah gambar
|
|
61
|
+
|
|
62
|
+
${bold('Shell completion:')}
|
|
63
|
+
completion bash|zsh|fish|pwsh Output skrip completion (lalu source-kan)
|
|
52
64
|
|
|
53
65
|
${bold('Contoh:')}
|
|
54
66
|
kiosapi masuk
|
|
55
|
-
kiosapi
|
|
56
|
-
kiosapi tanya
|
|
57
|
-
|
|
67
|
+
kiosapi tanya @src/app.ts "jelaskan fungsi utama file ini"
|
|
68
|
+
cat error.log | kiosapi tanya "apa penyebabnya?"
|
|
69
|
+
kiosapi init
|
|
70
|
+
kiosapi buat "tambah endpoint POST /users"
|
|
71
|
+
npm test 2>&1 | kiosapi buat "perbaiki semua tes yang gagal"
|
|
72
|
+
kiosapi lanjut
|
|
73
|
+
kiosapi tim --buat fullstack-team
|
|
74
|
+
kiosapi tim --pakai fullstack-team "bikin halaman login"
|
|
75
|
+
kiosapi completion bash >> ~/.bashrc
|
|
58
76
|
|
|
59
|
-
${dim('
|
|
77
|
+
${dim('Sesi interaktif: /undo batalkan giliran terakhir · /ringkas padatkan riwayat · /model ganti model.')}
|
|
60
78
|
${dim('Env: KIOSAPI_API_KEY, KIOSAPI_BASE_URL, NO_COLOR.')}`);
|
|
61
79
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { cmdBuat, cmdEdit, cmdGambar, cmdIsi, cmdKeluar, cmdLihat, cmdMasuk, cmdModel, cmdNgobrol, cmdPakai, cmdPerbarui, cmdPeriksa, cmdRencana, cmdSaldo, cmdSambung, cmdSetel, cmdTanya, cmdTim, cmdVideo, } from './commands.js';
|
|
2
|
+
import { cmdBuat, cmdCompletion, cmdEdit, cmdGambar, cmdInit, cmdIsi, cmdKeluar, cmdLihat, cmdMasuk, cmdModel, cmdNgobrol, cmdPakai, cmdPerbarui, cmdPeriksa, cmdRencana, cmdSaldo, cmdSambung, cmdSetel, cmdTanya, cmdTim, cmdVideo, maybeNotifyUpdate, } from './commands.js';
|
|
3
3
|
import { printHelp, printVersion } from './help.js';
|
|
4
|
-
import { startSession } from './session.js';
|
|
4
|
+
import { resumeFromCheckpoint, startSession } from './session.js';
|
|
5
5
|
import { red } from './ui.js';
|
|
6
6
|
/** Indonesian command names with English aliases. */
|
|
7
7
|
const COMMANDS = {
|
|
@@ -41,6 +41,10 @@ const COMMANDS = {
|
|
|
41
41
|
video: cmdVideo,
|
|
42
42
|
lihat: cmdLihat,
|
|
43
43
|
vision: cmdLihat,
|
|
44
|
+
lanjut: resumeFromCheckpoint,
|
|
45
|
+
resume: resumeFromCheckpoint,
|
|
46
|
+
init: cmdInit,
|
|
47
|
+
completion: cmdCompletion,
|
|
44
48
|
};
|
|
45
49
|
async function main() {
|
|
46
50
|
const [cmd, ...rest] = process.argv.slice(2);
|
|
@@ -71,6 +75,18 @@ async function main() {
|
|
|
71
75
|
return;
|
|
72
76
|
}
|
|
73
77
|
await handler(rest);
|
|
78
|
+
// After every non-session command on a TTY, nudge if there's a newer version.
|
|
79
|
+
// Skip for `perbarui`/`update` itself (user just updated) and `keluar`/`logout` (no point).
|
|
80
|
+
const skipUpdateCheck = new Set([
|
|
81
|
+
'perbarui',
|
|
82
|
+
'update',
|
|
83
|
+
'keluar',
|
|
84
|
+
'logout',
|
|
85
|
+
'completion',
|
|
86
|
+
'versi',
|
|
87
|
+
]);
|
|
88
|
+
if (!skipUpdateCheck.has(cmd))
|
|
89
|
+
await maybeNotifyUpdate();
|
|
74
90
|
}
|
|
75
91
|
main().catch((err) => {
|
|
76
92
|
console.error(red(err instanceof Error ? err.message : String(err)));
|