@steerable/steer 0.3.28 → 0.3.30
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 +1 -1
- package/dist/products/steer/active.js +3 -1
- package/dist/products/steer/foreign-import/deps.js +1 -0
- package/dist/products/steer/foreign-import/experts.js +62 -0
- package/dist/products/steer/foreign-import/ledger.js +68 -0
- package/dist/products/steer/foreign-import/scan.js +657 -0
- package/dist/products/steer/foreign-import/skills.js +206 -0
- package/dist/products/steer/foreign-import/sources.js +127 -0
- package/dist/products/steer/foreign-import/tasks.js +187 -0
- package/dist/products/steer/foreign-import/types.js +12 -0
- package/dist/products/steer/foreign-import-routes.js +87 -0
- package/dist/products/steer/locales/shell.zh.json +12 -3
- package/dist/products/steer/locales/zh.json +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @steerable/steer
|
|
2
2
|
|
|
3
|
-
Official command-line interface and terminal TUI (`steer`) for [Steer Agent](https://steeragent.app) (v0.3.
|
|
3
|
+
Official command-line interface and terminal TUI (`steer`) for [Steer Agent](https://steeragent.app) (v0.3.30).
|
|
4
4
|
|
|
5
5
|
Runs directly on macOS, Linux (`x64` / `arm64`), and Windows — including headless SSH servers — and automatically pulls the portable Python sidecar runtime for your platform. When installed alongside the Steer desktop app, `steer` shares the same local `~/.steer` workspace history, skills, and model configuration.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Steer 产品组装根:无场景包——纯 shell 产品。
|
|
3
|
-
* Markdown
|
|
3
|
+
* Markdown、文件预览、本轮变更、浏览器、电脑操作、权限申请、按需读技能和从其他智能体导入是本产品自己的路由和工具。
|
|
4
4
|
* PPT / Word 文档预览来自私有包 @deeppath/doc-preview,作为右侧标签。
|
|
5
5
|
*
|
|
6
6
|
* 本模块必须是产品入口(./main.ts / ./server.ts)的第一个 import:
|
|
@@ -29,6 +29,7 @@ import { registerSteerMarkdownPreview } from './markdown-preview.js';
|
|
|
29
29
|
import { registerSteerPermissions } from './permissions.js';
|
|
30
30
|
import { registerSteerSkillRead } from './skill-read.js';
|
|
31
31
|
import { registerSteerTurnChanges } from './turn-changes.js';
|
|
32
|
+
import { registerSteerForeignImport } from './foreign-import-routes.js';
|
|
32
33
|
/** 读同目录的 product.json(src 与 dist 同相对位置;构建期由 copy-skills.mjs 拷入 dist)。 */
|
|
33
34
|
function readProductJson() {
|
|
34
35
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -91,3 +92,4 @@ registerSteerBrowser();
|
|
|
91
92
|
registerSteerComputer();
|
|
92
93
|
registerSteerPermissions();
|
|
93
94
|
registerSteerSkillRead();
|
|
95
|
+
registerSteerForeignImport();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 读取 agents 目录下一层的角色 Markdown。不读取 tools 字段。
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { EXCLUDED_PATH_SEGMENTS } from './sources.js';
|
|
7
|
+
function note(probe, filePath) {
|
|
8
|
+
probe.observe?.(filePath);
|
|
9
|
+
}
|
|
10
|
+
function unquote(value) {
|
|
11
|
+
return value.trim().replace(/^["']|["']$/g, '');
|
|
12
|
+
}
|
|
13
|
+
/** 只取 name、description 和正文。tools 留在 frontmatter 里,不返回。 */
|
|
14
|
+
export function parseExpertMarkdown(markdown, filename) {
|
|
15
|
+
const fallback = path.basename(filename, path.extname(filename));
|
|
16
|
+
if (!markdown.startsWith('---')) {
|
|
17
|
+
return { name: fallback, description: null, body: markdown.trim() };
|
|
18
|
+
}
|
|
19
|
+
const rest = markdown.slice(3).replace(/^\r?\n/, '');
|
|
20
|
+
const end = rest.search(/\r?\n---\s*(?:\r?\n|$)/);
|
|
21
|
+
if (end === -1)
|
|
22
|
+
return { name: fallback, description: null, body: markdown.trim() };
|
|
23
|
+
const front = rest.slice(0, end);
|
|
24
|
+
const body = rest.slice(end).replace(/^\r?\n---\s*\r?\n?/, '').trim();
|
|
25
|
+
const nameMatch = front.match(/^name:\s*(.*)$/m);
|
|
26
|
+
const descriptionMatch = front.match(/^description:\s*(.*)$/m);
|
|
27
|
+
const name = nameMatch?.[1]?.trim() ? unquote(nameMatch[1]) : fallback;
|
|
28
|
+
const description = descriptionMatch?.[1]?.trim() ? unquote(descriptionMatch[1]) : null;
|
|
29
|
+
return { name, description, body };
|
|
30
|
+
}
|
|
31
|
+
/** 只看 agents 目录的直接子文件,不进入子目录。 */
|
|
32
|
+
export function discoverExpertFiles(agentsDir, probe) {
|
|
33
|
+
note(probe, agentsDir);
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = fs.readdirSync(agentsDir, { withFileTypes: true });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const found = [];
|
|
42
|
+
for (const ent of entries) {
|
|
43
|
+
if (EXCLUDED_PATH_SEGMENTS.has(ent.name))
|
|
44
|
+
continue;
|
|
45
|
+
if (ent.isSymbolicLink() || !ent.isFile() || !ent.name.endsWith('.md'))
|
|
46
|
+
continue;
|
|
47
|
+
const file = path.join(agentsDir, ent.name);
|
|
48
|
+
note(probe, file);
|
|
49
|
+
try {
|
|
50
|
+
const real = fs.realpathSync(file);
|
|
51
|
+
note(probe, real);
|
|
52
|
+
const st = fs.lstatSync(file);
|
|
53
|
+
if (!st.isFile() || st.isSymbolicLink())
|
|
54
|
+
continue;
|
|
55
|
+
found.push({ file, real, mtime: st.mtime });
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// 文件在列出之后不可读:跳过这一项。
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return found;
|
|
62
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 导入账本:记下已经复制进 Steer 的 id,避免下次扫描再导一次。
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileLockPath } from '@steerable/agent-shell/storage/process-locks';
|
|
7
|
+
import { acquireWriteLease } from '@steerable/agent-shell/storage/write-lease';
|
|
8
|
+
function ledgerPath(userDataDir) {
|
|
9
|
+
return path.join(userDataDir, 'foreign-agent-imports.json');
|
|
10
|
+
}
|
|
11
|
+
function emptyLedger() {
|
|
12
|
+
return { version: 1, items: [] };
|
|
13
|
+
}
|
|
14
|
+
function parseLedger(raw) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
if (!parsed || typeof parsed !== 'object')
|
|
18
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
19
|
+
const rec = parsed;
|
|
20
|
+
if (rec.version !== 1 || !Array.isArray(rec.items)) {
|
|
21
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
22
|
+
}
|
|
23
|
+
const items = [];
|
|
24
|
+
for (const item of rec.items) {
|
|
25
|
+
if (!item || typeof item !== 'object')
|
|
26
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
27
|
+
const row = item;
|
|
28
|
+
if (row.kind !== 'task' && row.kind !== 'skill' && row.kind !== 'expert') {
|
|
29
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
30
|
+
}
|
|
31
|
+
if (typeof row.id !== 'string' || typeof row.targetId !== 'string' || typeof row.sourcePath !== 'string') {
|
|
32
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
33
|
+
}
|
|
34
|
+
items.push({
|
|
35
|
+
id: row.id,
|
|
36
|
+
kind: row.kind,
|
|
37
|
+
targetId: row.targetId,
|
|
38
|
+
sourcePath: row.sourcePath,
|
|
39
|
+
importedAt: typeof row.importedAt === 'string' ? row.importedAt : new Date(0).toISOString(),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return { ledger: { version: 1, items } };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return { ledger: emptyLedger(), warning: 'unreadable' };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** 读账本。文件不存在是空账本;损坏时视为空并带 unreadable。 */
|
|
49
|
+
export function readLedger(userDataDir) {
|
|
50
|
+
const file = ledgerPath(userDataDir);
|
|
51
|
+
if (!fs.existsSync(file))
|
|
52
|
+
return { ledger: emptyLedger() };
|
|
53
|
+
return parseLedger(fs.readFileSync(file, 'utf8'));
|
|
54
|
+
}
|
|
55
|
+
/** 在 foreign-agent-imports 写租约里替换账本。 */
|
|
56
|
+
export function updateLedger(userDataDir, mutate) {
|
|
57
|
+
const lock = acquireWriteLease(fileLockPath(userDataDir, 'foreign-agent-imports'), 5000);
|
|
58
|
+
try {
|
|
59
|
+
const current = readLedger(userDataDir);
|
|
60
|
+
const next = { version: 1, items: mutate(current.ledger.items) };
|
|
61
|
+
fs.mkdirSync(userDataDir, { recursive: true });
|
|
62
|
+
fs.writeFileSync(ledgerPath(userDataDir), `${JSON.stringify(next, null, 2)}\n`);
|
|
63
|
+
return current.warning ? { warning: current.warning } : {};
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
lock.release();
|
|
67
|
+
}
|
|
68
|
+
}
|