skillmkt 0.4.17 → 0.4.19
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/client/bin/skillmkt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// skillmkt — local-first agent skill manager
|
|
3
3
|
import { makeCtx, withState } from '../lib/ctx.js';
|
|
4
|
-
import { hubExists } from '../lib/hub.js';
|
|
4
|
+
import { hubExists, isInitialized } from '../lib/hub.js';
|
|
5
5
|
import { L } from '../lib/i18n.js';
|
|
6
6
|
|
|
7
7
|
const COMMANDS = {
|
|
@@ -42,7 +42,7 @@ const HELP_ZH = `skillmkt — 本地优先的 agent skill 管理器
|
|
|
42
42
|
裸跑 = 仪表盘。文档: docs/CLI.md`;
|
|
43
43
|
|
|
44
44
|
async function bareRun(ctx) {
|
|
45
|
-
if (!hubExists(ctx.hub)) {
|
|
45
|
+
if (!hubExists(ctx.hub) || !isInitialized(ctx.hub)) {
|
|
46
46
|
if (!ctx.tty) {
|
|
47
47
|
console.error(L("请先运行 'skillmkt init' 完成初始化", "run 'skillmkt init' to get started"));
|
|
48
48
|
process.exit(1);
|
package/client/commands/init.js
CHANGED
|
@@ -96,7 +96,6 @@ export async function run(ctx) {
|
|
|
96
96
|
const ks = await choose(L('这个服务需要访问密钥,怎么提供?', 'This service needs an access key — how should it be provided?'), [
|
|
97
97
|
{ label: L('现在粘贴进来(只输一次,自动加密保存)', 'Paste it now (entered once, saved encrypted)'), v: 'paste' },
|
|
98
98
|
{ label: L('从环境变量 SKILLMKT_API_KEY 读', 'Read env var SKILLMKT_API_KEY'), v: 'env:SKILLMKT_API_KEY' },
|
|
99
|
-
{ label: L('不需要密钥', 'No key needed'), v: null },
|
|
100
99
|
{ label: L('退出向导', 'Quit wizard'), v: 'quit' },
|
|
101
100
|
]);
|
|
102
101
|
if (ks.v === 'quit') {
|
|
@@ -164,6 +163,7 @@ export async function run(ctx) {
|
|
|
164
163
|
// harness 默认目标 = installed 态
|
|
165
164
|
const installed = ctx.harnesses.filter((h) => h.state === 'installed' && !h.detectOnly).map((h) => h.id);
|
|
166
165
|
raw.default_targets = [...new Set([...(raw.default_targets || []), ...installed])];
|
|
166
|
+
raw.initialized = true; // 完成标记——裸跑据此判断要不要自动进向导
|
|
167
167
|
writeConfig(ctx.hub, raw);
|
|
168
168
|
|
|
169
169
|
ok(`init done — default_targets: ${raw.default_targets.join(', ') || L('(无 installed harness,装好后 targets add)', '(no installed agent — use targets add later)')}`);
|
package/client/commands/serve.js
CHANGED
|
@@ -6,7 +6,7 @@ import crypto from 'node:crypto';
|
|
|
6
6
|
import { daemonFile, readDaemon } from '../lib/daemon.js';
|
|
7
7
|
import { loadConflicts } from '../lib/conflicts.js';
|
|
8
8
|
import { loadDecisions, decide } from '../lib/decide.js';
|
|
9
|
-
import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock, ensureHub } from '../lib/hub.js';
|
|
9
|
+
import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock, ensureHub, isInitialized } from '../lib/hub.js';
|
|
10
10
|
import { readUpstream } from '../lib/state.js';
|
|
11
11
|
import { readYAML } from '../../pipeline/lib/util.js';
|
|
12
12
|
import { detectHarnesses } from '../lib/scanner.js';
|
|
@@ -34,7 +34,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
34
34
|
const state = () => ({
|
|
35
35
|
hub: ctx.hub,
|
|
36
36
|
lang: (() => readConfig(ctx.hub)._raw?.ui?.lang ?? detectLang())(),
|
|
37
|
-
initialized: (
|
|
37
|
+
initialized: isInitialized(ctx.hub),
|
|
38
38
|
library: readLibrary(ctx.hub), lock: readLock(ctx.hub),
|
|
39
39
|
upstream: readUpstream(ctx.hub), conflicts: loadConflicts(ctx.hub),
|
|
40
40
|
decisions: loadDecisions(ctx.hub), harnesses,
|
package/client/lib/dashboard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// dashboard.js — 裸跑数据汇聚 + 渲染(尊重 ui.enabled)
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { readYAMLFile } from './hub.js';
|
|
4
|
+
import { readYAMLFile, isInitialized } from './hub.js';
|
|
5
5
|
import { scanAll } from './scanner.js';
|
|
6
6
|
import { treeHash } from './package.js';
|
|
7
7
|
import { dashboard } from './render.js';
|
|
@@ -26,7 +26,7 @@ export async function renderDashboard(ctx) {
|
|
|
26
26
|
const conflicts = listYAML(path.join(hub, 'conflicts'));
|
|
27
27
|
|
|
28
28
|
// llm 解析链有 env/.env 兜底——非 config 来源时标注,免得用户困惑
|
|
29
|
-
const configFile =
|
|
29
|
+
const configFile = isInitialized(ctx.hub);
|
|
30
30
|
dashboard({ hub, library, scan: { rows, harnesses, managedHash }, upstream, conflicts, llm, llmVia: llm?.via, configFile, project });
|
|
31
31
|
return 0;
|
|
32
32
|
}
|
package/client/lib/hub.js
CHANGED
|
@@ -21,6 +21,13 @@ export function hubExists(hub) {
|
|
|
21
21
|
return fs.existsSync(path.join(hub, 'library.yml'));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// "真正初始化过":config.yml 里有完成标记,或含实质配置(web 保存路径只有后者可判)
|
|
25
|
+
export function isInitialized(hub) {
|
|
26
|
+
const raw = readConfig(hub)._raw;
|
|
27
|
+
if (!raw) return false;
|
|
28
|
+
return !!(raw.initialized || raw.llm?.base_url || raw.default_targets?.length);
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
export function ensureHub(hub) {
|
|
25
32
|
for (const d of SUBDIRS) fs.mkdirSync(path.join(hub, d), { recursive: true });
|
|
26
33
|
if (!fs.existsSync(F(hub, 'library.yml'))) writeYAMLFile(F(hub, 'library.yml'), { version: 1, skills: {} }); // 让 hubExists 对"只初始化没装过"的 hub 也成立
|