oneie 3.8.3 → 4.0.1
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/LICENSE +86 -0
- package/README.md +63 -952
- package/dist/package.json +38 -0
- package/dist/src/agent.d.ts +2 -0
- package/dist/src/agent.js +888 -0
- package/dist/src/args.d.ts +9 -0
- package/dist/src/args.js +61 -0
- package/dist/src/auth.d.ts +6 -0
- package/dist/src/auth.js +122 -0
- package/dist/{banner.d.ts → src/banner.d.ts} +0 -1
- package/dist/src/banner.js +16 -0
- package/dist/src/broadcast.d.ts +6 -0
- package/dist/src/broadcast.js +150 -0
- package/dist/src/catalog.d.ts +2 -0
- package/dist/src/catalog.js +78 -0
- package/dist/src/chat.d.ts +2 -0
- package/dist/src/chat.js +92 -0
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +151 -0
- package/dist/src/compiler.d.ts +36 -0
- package/dist/src/compiler.js +314 -0
- package/dist/src/config.d.ts +24 -0
- package/dist/src/config.js +70 -0
- package/dist/src/connect.d.ts +2 -0
- package/dist/src/connect.js +64 -0
- package/dist/src/coordinate.d.ts +3 -0
- package/dist/src/coordinate.js +58 -0
- package/dist/src/create.d.ts +2 -0
- package/dist/src/create.js +113 -0
- package/dist/src/deploy.d.ts +2 -0
- package/dist/src/deploy.js +19 -0
- package/dist/src/dev.d.ts +2 -0
- package/dist/src/dev.js +75 -0
- package/dist/src/device-flow.d.ts +57 -0
- package/dist/src/device-flow.js +173 -0
- package/dist/src/doctor.d.ts +26 -0
- package/dist/src/doctor.js +91 -0
- package/dist/src/env.d.ts +3 -0
- package/dist/src/env.js +37 -0
- package/dist/src/eval.d.ts +2 -0
- package/dist/src/eval.js +42 -0
- package/dist/src/fn.d.ts +2 -0
- package/dist/src/fn.js +73 -0
- package/dist/src/group.d.ts +2 -0
- package/dist/src/group.js +115 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +102 -0
- package/dist/src/init.d.ts +11 -0
- package/dist/src/init.js +121 -0
- package/dist/src/lib/agent-env.d.ts +5 -0
- package/dist/src/lib/agent-env.js +25 -0
- package/dist/src/lib/api-path.d.ts +1 -0
- package/dist/src/lib/api-path.js +9 -0
- package/dist/src/lib/client.d.ts +16 -0
- package/dist/src/lib/client.js +57 -0
- package/dist/src/lib/launch-claude.d.ts +5 -0
- package/dist/src/lib/launch-claude.js +45 -0
- package/dist/src/links.d.ts +5 -0
- package/dist/src/links.js +44 -0
- package/dist/src/onboard.d.ts +16 -0
- package/dist/src/onboard.js +146 -0
- package/dist/src/plugin.d.ts +2 -0
- package/dist/src/plugin.js +184 -0
- package/dist/src/push.d.ts +2 -0
- package/dist/src/push.js +114 -0
- package/dist/src/render.d.ts +21 -0
- package/dist/src/render.js +32 -0
- package/dist/src/setup.d.ts +6 -0
- package/dist/src/setup.js +126 -0
- package/dist/src/ship.d.ts +2 -0
- package/dist/src/ship.js +18 -0
- package/dist/src/skill-parser.d.ts +14 -0
- package/dist/src/skill-parser.js +113 -0
- package/dist/src/skill.d.ts +2 -0
- package/dist/src/skill.js +377 -0
- package/dist/src/slug.d.ts +2 -0
- package/dist/src/slug.js +6 -0
- package/dist/src/social.d.ts +2 -0
- package/dist/src/social.js +87 -0
- package/dist/src/staff.d.ts +2 -0
- package/dist/src/staff.js +93 -0
- package/dist/src/status.d.ts +2 -0
- package/dist/src/status.js +46 -0
- package/dist/src/substrate.d.ts +2 -0
- package/dist/src/substrate.js +243 -0
- package/dist/src/templates/_node/site/one.config.d.ts +2 -0
- package/dist/src/templates/_node/site/one.config.js +22 -0
- package/dist/src/templates.d.ts +1 -0
- package/dist/src/templates.js +205 -0
- package/dist/src/trade.d.ts +2 -0
- package/dist/src/trade.js +95 -0
- package/dist/src/trail.d.ts +2 -0
- package/dist/src/trail.js +41 -0
- package/dist/src/validate.d.ts +13 -0
- package/dist/src/validate.js +35 -0
- package/dist/src/wallet.d.ts +9 -0
- package/dist/src/wallet.js +209 -0
- package/package.json +26 -54
- package/LICENSE.md +0 -89
- package/dist/admin/build.d.ts +0 -15
- package/dist/admin/build.d.ts.map +0 -1
- package/dist/admin/build.js +0 -295
- package/dist/admin/build.js.map +0 -1
- package/dist/admin/index.d.ts +0 -24
- package/dist/admin/index.d.ts.map +0 -1
- package/dist/admin/index.js +0 -98
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/list.d.ts +0 -14
- package/dist/admin/list.d.ts.map +0 -1
- package/dist/admin/list.js +0 -90
- package/dist/admin/list.js.map +0 -1
- package/dist/admin/manifest.d.ts +0 -86
- package/dist/admin/manifest.d.ts.map +0 -1
- package/dist/admin/manifest.js +0 -183
- package/dist/admin/manifest.js.map +0 -1
- package/dist/admin/monorepo.d.ts +0 -25
- package/dist/admin/monorepo.d.ts.map +0 -1
- package/dist/admin/monorepo.js +0 -59
- package/dist/admin/monorepo.js.map +0 -1
- package/dist/admin/release.d.ts +0 -17
- package/dist/admin/release.d.ts.map +0 -1
- package/dist/admin/release.js +0 -144
- package/dist/admin/release.js.map +0 -1
- package/dist/admin/sync.d.ts +0 -14
- package/dist/admin/sync.d.ts.map +0 -1
- package/dist/admin/sync.js +0 -104
- package/dist/admin/sync.js.map +0 -1
- package/dist/admin/validate.d.ts +0 -15
- package/dist/admin/validate.d.ts.map +0 -1
- package/dist/admin/validate.js +0 -169
- package/dist/admin/validate.js.map +0 -1
- package/dist/banner.d.ts.map +0 -1
- package/dist/banner.js +0 -15
- package/dist/banner.js.map +0 -1
- package/dist/clone-docs.d.ts +0 -17
- package/dist/clone-docs.d.ts.map +0 -1
- package/dist/clone-docs.js +0 -62
- package/dist/clone-docs.js.map +0 -1
- package/dist/clone-web.d.ts +0 -12
- package/dist/clone-web.d.ts.map +0 -1
- package/dist/clone-web.js +0 -50
- package/dist/clone-web.js.map +0 -1
- package/dist/commands/agent.d.ts +0 -20
- package/dist/commands/agent.d.ts.map +0 -1
- package/dist/commands/agent.js +0 -315
- package/dist/commands/agent.js.map +0 -1
- package/dist/commands/ask.d.ts +0 -4
- package/dist/commands/ask.d.ts.map +0 -1
- package/dist/commands/ask.js +0 -8
- package/dist/commands/ask.js.map +0 -1
- package/dist/commands/bounty.d.ts +0 -4
- package/dist/commands/bounty.d.ts.map +0 -1
- package/dist/commands/bounty.js +0 -24
- package/dist/commands/bounty.js.map +0 -1
- package/dist/commands/buy.d.ts +0 -19
- package/dist/commands/buy.d.ts.map +0 -1
- package/dist/commands/buy.js +0 -63
- package/dist/commands/buy.js.map +0 -1
- package/dist/commands/capabilities.d.ts +0 -4
- package/dist/commands/capabilities.d.ts.map +0 -1
- package/dist/commands/capabilities.js +0 -18
- package/dist/commands/capabilities.js.map +0 -1
- package/dist/commands/claw.d.ts +0 -4
- package/dist/commands/claw.d.ts.map +0 -1
- package/dist/commands/claw.js +0 -14
- package/dist/commands/claw.js.map +0 -1
- package/dist/commands/commend.d.ts +0 -4
- package/dist/commands/commend.d.ts.map +0 -1
- package/dist/commands/commend.js +0 -13
- package/dist/commands/commend.js.map +0 -1
- package/dist/commands/completion.d.ts +0 -4
- package/dist/commands/completion.d.ts.map +0 -1
- package/dist/commands/completion.js +0 -49
- package/dist/commands/completion.js.map +0 -1
- package/dist/commands/config.d.ts +0 -4
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -78
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/deploy.d.ts +0 -4
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -45
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -4
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -72
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/domain.d.ts +0 -4
- package/dist/commands/domain.d.ts.map +0 -1
- package/dist/commands/domain.js +0 -19
- package/dist/commands/domain.js.map +0 -1
- package/dist/commands/export.d.ts +0 -4
- package/dist/commands/export.d.ts.map +0 -1
- package/dist/commands/export.js +0 -15
- package/dist/commands/export.js.map +0 -1
- package/dist/commands/fade.d.ts +0 -4
- package/dist/commands/fade.d.ts.map +0 -1
- package/dist/commands/fade.js +0 -15
- package/dist/commands/fade.js.map +0 -1
- package/dist/commands/flag.d.ts +0 -4
- package/dist/commands/flag.d.ts.map +0 -1
- package/dist/commands/flag.js +0 -13
- package/dist/commands/flag.js.map +0 -1
- package/dist/commands/forget.d.ts +0 -4
- package/dist/commands/forget.d.ts.map +0 -1
- package/dist/commands/forget.js +0 -16
- package/dist/commands/forget.js.map +0 -1
- package/dist/commands/frontier.d.ts +0 -4
- package/dist/commands/frontier.d.ts.map +0 -1
- package/dist/commands/frontier.js +0 -11
- package/dist/commands/frontier.js.map +0 -1
- package/dist/commands/group.d.ts +0 -3
- package/dist/commands/group.d.ts.map +0 -1
- package/dist/commands/group.js +0 -123
- package/dist/commands/group.js.map +0 -1
- package/dist/commands/health.d.ts +0 -4
- package/dist/commands/health.d.ts.map +0 -1
- package/dist/commands/health.js +0 -11
- package/dist/commands/health.js.map +0 -1
- package/dist/commands/highways.d.ts +0 -4
- package/dist/commands/highways.d.ts.map +0 -1
- package/dist/commands/highways.js +0 -14
- package/dist/commands/highways.js.map +0 -1
- package/dist/commands/hire.d.ts +0 -4
- package/dist/commands/hire.d.ts.map +0 -1
- package/dist/commands/hire.js +0 -16
- package/dist/commands/hire.js.map +0 -1
- package/dist/commands/init.d.ts +0 -17
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -308
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/invite.d.ts +0 -4
- package/dist/commands/invite.d.ts.map +0 -1
- package/dist/commands/invite.js +0 -37
- package/dist/commands/invite.js.map +0 -1
- package/dist/commands/know.d.ts +0 -4
- package/dist/commands/know.d.ts.map +0 -1
- package/dist/commands/know.js +0 -8
- package/dist/commands/know.js.map +0 -1
- package/dist/commands/launch.d.ts +0 -4
- package/dist/commands/launch.d.ts.map +0 -1
- package/dist/commands/launch.js +0 -16
- package/dist/commands/launch.js.map +0 -1
- package/dist/commands/mark.d.ts +0 -4
- package/dist/commands/mark.d.ts.map +0 -1
- package/dist/commands/mark.js +0 -15
- package/dist/commands/mark.js.map +0 -1
- package/dist/commands/pay.d.ts +0 -4
- package/dist/commands/pay.d.ts.map +0 -1
- package/dist/commands/pay.js +0 -21
- package/dist/commands/pay.js.map +0 -1
- package/dist/commands/pipe.d.ts +0 -4
- package/dist/commands/pipe.d.ts.map +0 -1
- package/dist/commands/pipe.js +0 -35
- package/dist/commands/pipe.js.map +0 -1
- package/dist/commands/publish.d.ts +0 -4
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/publish.js +0 -23
- package/dist/commands/publish.js.map +0 -1
- package/dist/commands/recall.d.ts +0 -4
- package/dist/commands/recall.d.ts.map +0 -1
- package/dist/commands/recall.js +0 -12
- package/dist/commands/recall.js.map +0 -1
- package/dist/commands/repl.d.ts +0 -4
- package/dist/commands/repl.d.ts.map +0 -1
- package/dist/commands/repl.js +0 -56
- package/dist/commands/repl.js.map +0 -1
- package/dist/commands/reveal.d.ts +0 -4
- package/dist/commands/reveal.d.ts.map +0 -1
- package/dist/commands/reveal.js +0 -11
- package/dist/commands/reveal.js.map +0 -1
- package/dist/commands/revenue.d.ts +0 -4
- package/dist/commands/revenue.d.ts.map +0 -1
- package/dist/commands/revenue.js +0 -11
- package/dist/commands/revenue.js.map +0 -1
- package/dist/commands/select.d.ts +0 -4
- package/dist/commands/select.d.ts.map +0 -1
- package/dist/commands/select.js +0 -19
- package/dist/commands/select.js.map +0 -1
- package/dist/commands/sell.d.ts +0 -15
- package/dist/commands/sell.d.ts.map +0 -1
- package/dist/commands/sell.js +0 -49
- package/dist/commands/sell.js.map +0 -1
- package/dist/commands/signal.d.ts +0 -4
- package/dist/commands/signal.d.ts.map +0 -1
- package/dist/commands/signal.js +0 -8
- package/dist/commands/signal.js.map +0 -1
- package/dist/commands/stats.d.ts +0 -4
- package/dist/commands/stats.d.ts.map +0 -1
- package/dist/commands/stats.js +0 -11
- package/dist/commands/stats.js.map +0 -1
- package/dist/commands/status.d.ts +0 -4
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -18
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/subscribe.d.ts +0 -14
- package/dist/commands/subscribe.d.ts.map +0 -1
- package/dist/commands/subscribe.js +0 -33
- package/dist/commands/subscribe.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -4
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -20
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/tail.d.ts +0 -4
- package/dist/commands/tail.d.ts.map +0 -1
- package/dist/commands/tail.js +0 -51
- package/dist/commands/tail.js.map +0 -1
- package/dist/commands/warn.d.ts +0 -4
- package/dist/commands/warn.d.ts.map +0 -1
- package/dist/commands/warn.js +0 -15
- package/dist/commands/warn.js.map +0 -1
- package/dist/copy-claude-config.d.ts +0 -2
- package/dist/copy-claude-config.d.ts.map +0 -1
- package/dist/copy-claude-config.js +0 -32
- package/dist/copy-claude-config.js.map +0 -1
- package/dist/create-org-profile.d.ts +0 -10
- package/dist/create-org-profile.d.ts.map +0 -1
- package/dist/create-org-profile.js +0 -136
- package/dist/create-org-profile.js.map +0 -1
- package/dist/create-user-profile.d.ts +0 -9
- package/dist/create-user-profile.d.ts.map +0 -1
- package/dist/create-user-profile.js +0 -115
- package/dist/create-user-profile.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -375
- package/dist/index.js.map +0 -1
- package/dist/lib/agent-detection.d.ts +0 -19
- package/dist/lib/agent-detection.d.ts.map +0 -1
- package/dist/lib/agent-detection.js +0 -87
- package/dist/lib/agent-detection.js.map +0 -1
- package/dist/lib/args.d.ts +0 -11
- package/dist/lib/args.d.ts.map +0 -1
- package/dist/lib/args.js +0 -57
- package/dist/lib/args.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -38
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/detect.d.ts +0 -45
- package/dist/lib/detect.d.ts.map +0 -1
- package/dist/lib/detect.js +0 -221
- package/dist/lib/detect.js.map +0 -1
- package/dist/lib/http.d.ts +0 -9
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js +0 -25
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/output.d.ts +0 -5
- package/dist/lib/output.d.ts.map +0 -1
- package/dist/lib/output.js +0 -32
- package/dist/lib/output.js.map +0 -1
- package/dist/lib/sdk.d.ts +0 -10
- package/dist/lib/sdk.d.ts.map +0 -1
- package/dist/lib/sdk.js +0 -22
- package/dist/lib/sdk.js.map +0 -1
- package/dist/lib/telemetry.d.ts +0 -4
- package/dist/lib/telemetry.d.ts.map +0 -1
- package/dist/lib/telemetry.js +0 -61
- package/dist/lib/telemetry.js.map +0 -1
- package/dist/sync-agents.d.ts +0 -5
- package/dist/sync-agents.d.ts.map +0 -1
- package/dist/sync-agents.js +0 -28
- package/dist/sync-agents.js.map +0 -1
- package/dist/sync-ontology.d.ts +0 -4
- package/dist/sync-ontology.d.ts.map +0 -1
- package/dist/sync-ontology.js +0 -40
- package/dist/sync-ontology.js.map +0 -1
- package/dist/utils/file-resolver.d.ts +0 -83
- package/dist/utils/file-resolver.d.ts.map +0 -1
- package/dist/utils/file-resolver.js +0 -194
- package/dist/utils/file-resolver.js.map +0 -1
- package/dist/utils/installation-setup.d.ts +0 -88
- package/dist/utils/installation-setup.d.ts.map +0 -1
- package/dist/utils/installation-setup.js +0 -409
- package/dist/utils/installation-setup.js.map +0 -1
- package/dist/utils/launch-claude.d.ts +0 -7
- package/dist/utils/launch-claude.d.ts.map +0 -1
- package/dist/utils/launch-claude.js +0 -86
- package/dist/utils/launch-claude.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -48
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -73
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { mergeEnv, writeEnvLocal } from './env.js';
|
|
4
|
+
import { readAgency } from './config.js';
|
|
5
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
6
|
+
const DEFAULT_WEB = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
|
|
7
|
+
async function ask(base, key, receiver, data) {
|
|
8
|
+
const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
|
|
11
|
+
body: JSON.stringify({ data }),
|
|
12
|
+
});
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
const body = await res.text().catch(() => '');
|
|
15
|
+
throw new Error(`${receiver} → ${res.status}\n${body}`);
|
|
16
|
+
}
|
|
17
|
+
const json = await res.json();
|
|
18
|
+
if (json.outcome === 'failure') {
|
|
19
|
+
const result = (json.result ?? {});
|
|
20
|
+
const details = Object.entries(result)
|
|
21
|
+
.map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
|
|
22
|
+
.join(' ');
|
|
23
|
+
throw new Error(`${receiver} → forbidden: ${details}`);
|
|
24
|
+
}
|
|
25
|
+
return json;
|
|
26
|
+
}
|
|
27
|
+
function findConfigPath(dir) {
|
|
28
|
+
for (const name of ['_node.toml', 'agency.toml', 'partner.toml', 'workspace.toml']) {
|
|
29
|
+
if (existsSync(`${dir}/${name}`))
|
|
30
|
+
return `${dir}/${name}`;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/** No key in env — provision one via the same open call `init` uses, then
|
|
35
|
+
* reconcile the returned slug down into .env.local + workspace.toml. The
|
|
36
|
+
* route mints its own slug; it does not accept a desired one (contract #4). */
|
|
37
|
+
export async function keylessSetup(dir, cfgPath, web) {
|
|
38
|
+
let name = 'my-workspace';
|
|
39
|
+
if (cfgPath) {
|
|
40
|
+
try {
|
|
41
|
+
name = readAgency(cfgPath).name;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// toml without slug/name (e.g. a bare workspace.toml) — fall through with the default
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const ownerEmail = mergeEnv(dir).WORKSPACE_OWNER_EMAIL;
|
|
48
|
+
const body = { name };
|
|
49
|
+
if (ownerEmail)
|
|
50
|
+
body.invite = { email: ownerEmail, role: 'owner' };
|
|
51
|
+
const res = await fetch(`${web}/api/provision/agent`, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: { 'Content-Type': 'application/json' },
|
|
54
|
+
body: JSON.stringify(body),
|
|
55
|
+
});
|
|
56
|
+
const json = (await res.json());
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
process.stderr.write(`provision/agent → ${res.status}\n${JSON.stringify(json)}\n`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
const { uid, workspace, apiKey } = json;
|
|
62
|
+
writeEnvLocal(dir, {
|
|
63
|
+
ONE_API_KEY: apiKey,
|
|
64
|
+
WORKSPACE_ID: workspace,
|
|
65
|
+
WORKSPACE_SLUG: workspace,
|
|
66
|
+
AGENCY_WSID: workspace,
|
|
67
|
+
AGENCY_SLUG: workspace,
|
|
68
|
+
CC_ACTOR_ID: uid,
|
|
69
|
+
});
|
|
70
|
+
let reconciled = '';
|
|
71
|
+
const targetToml = cfgPath ?? `${dir}/workspace.toml`;
|
|
72
|
+
if (existsSync(targetToml)) {
|
|
73
|
+
let toml = readFileSync(targetToml, 'utf8');
|
|
74
|
+
if (/^slug\s*=/m.test(toml)) {
|
|
75
|
+
toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${workspace}"`);
|
|
76
|
+
writeFileSync(targetToml, toml);
|
|
77
|
+
reconciled = ` reconciled: ${targetToml} slug → ${workspace}\n`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
process.stdout.write(`Workspace provisioned: ${workspace}\n`);
|
|
81
|
+
process.stdout.write(` key: ${apiKey.slice(0, 8)}… (written to .env.local)\n`);
|
|
82
|
+
process.stdout.write(reconciled);
|
|
83
|
+
}
|
|
84
|
+
export function setupCmd() {
|
|
85
|
+
return new Command('setup')
|
|
86
|
+
.description('Bootstrap a workspace (idempotent) — keyless: provisions with no prior account')
|
|
87
|
+
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
88
|
+
.option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
|
|
89
|
+
.action(async (opts) => {
|
|
90
|
+
const dir = process.cwd();
|
|
91
|
+
const env = mergeEnv(dir);
|
|
92
|
+
const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
|
|
93
|
+
if ((env.AGENCY_WSID && env.CC_ACTOR_ID) || env.ONE_API_KEY) {
|
|
94
|
+
process.stdout.write(`Workspace already set up (${env.AGENCY_WSID ?? env.WORKSPACE_SLUG}). No-op.\n`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const cfgPath = findConfigPath(dir);
|
|
98
|
+
if (!key) {
|
|
99
|
+
await keylessSetup(dir, cfgPath, DEFAULT_WEB);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!cfgPath) {
|
|
103
|
+
process.stderr.write(`No _node.toml/agency.toml/partner.toml/workspace.toml found in ${dir}\n`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const agency = readAgency(cfgPath);
|
|
107
|
+
const base = opts.api.replace(/\/$/, '');
|
|
108
|
+
const ws = await ask(base, key, 'world:create-workspace', {
|
|
109
|
+
name: agency.name,
|
|
110
|
+
slug: agency.slug,
|
|
111
|
+
plan: agency.plan,
|
|
112
|
+
markup: agency.markup_pct,
|
|
113
|
+
brand: agency.brand ?? false,
|
|
114
|
+
credit: agency.pool ?? 0,
|
|
115
|
+
});
|
|
116
|
+
const wsid = String(ws.wsid ?? agency.slug);
|
|
117
|
+
const actor = await ask(base, key, 'world:create-actor', {
|
|
118
|
+
name: 'claude-code',
|
|
119
|
+
type: 'claude-code',
|
|
120
|
+
group: wsid,
|
|
121
|
+
});
|
|
122
|
+
const aid = String(actor.aid ?? '');
|
|
123
|
+
writeEnvLocal(dir, { AGENCY_WSID: wsid, CC_ACTOR_ID: aid, AGENCY_SLUG: agency.slug });
|
|
124
|
+
process.stdout.write(`Agency: ${wsid} plan=${agency.plan} markup=${agency.markup_pct}% pool=${agency.pool ?? 0} cr\nClaude Code actor: ${aid}\n`);
|
|
125
|
+
});
|
|
126
|
+
}
|
package/dist/src/ship.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
export function shipCmd() {
|
|
4
|
+
return new Command('ship')
|
|
5
|
+
.description('git add -A, commit, and push (close the loop)')
|
|
6
|
+
.argument('[message]', 'Commit message', 'ship: update agency workspace')
|
|
7
|
+
.action((message) => {
|
|
8
|
+
const add = spawnSync('git', ['add', '-A'], { stdio: 'inherit' });
|
|
9
|
+
if (add.status !== 0)
|
|
10
|
+
process.exit(add.status ?? 1);
|
|
11
|
+
const commit = spawnSync('git', ['commit', '-m', message], { stdio: 'inherit' });
|
|
12
|
+
if (commit.status !== 0 && commit.status !== 1)
|
|
13
|
+
process.exit(commit.status ?? 1);
|
|
14
|
+
const push = spawnSync('git', ['push'], { stdio: 'inherit' });
|
|
15
|
+
if (push.status !== 0)
|
|
16
|
+
process.exit(push.status ?? 1);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Diagnostic {
|
|
2
|
+
level: 'warn' | 'info';
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ParsedSkill {
|
|
7
|
+
meta: Record<string, unknown>;
|
|
8
|
+
body: string;
|
|
9
|
+
diagnostics: Diagnostic[];
|
|
10
|
+
}
|
|
11
|
+
export interface ParseOptions {
|
|
12
|
+
pathStem?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parse(md: string, opts?: ParseOptions): ParsedSkill;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Mirror of web/src/lib/skill/parser.ts — keep in sync.
|
|
2
|
+
// TODO: dedupe via @oneie/sdk export once SDK ships skill helpers.
|
|
3
|
+
function parseFrontmatter(yaml) {
|
|
4
|
+
const meta = {};
|
|
5
|
+
const lines = yaml.split('\n');
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (i < lines.length) {
|
|
8
|
+
const line = lines[i];
|
|
9
|
+
if (!line.trim() || line.trim().startsWith('#')) {
|
|
10
|
+
i++;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
let col = line.indexOf(': ');
|
|
14
|
+
let inlineStart = col === -1 ? -1 : col + 2;
|
|
15
|
+
if (col === -1 && /^[A-Za-z0-9_-]+:\s*$/.test(line)) {
|
|
16
|
+
col = line.indexOf(':');
|
|
17
|
+
inlineStart = line.length;
|
|
18
|
+
}
|
|
19
|
+
if (col === -1) {
|
|
20
|
+
i++;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const key = line.slice(0, col).trim();
|
|
24
|
+
if (!key) {
|
|
25
|
+
i++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const inline = line.slice(inlineStart).trim();
|
|
29
|
+
const arr = [];
|
|
30
|
+
let j = i + 1;
|
|
31
|
+
while (j < lines.length && lines[j].trim().startsWith('- ')) {
|
|
32
|
+
arr.push(lines[j].trim().slice(2));
|
|
33
|
+
j++;
|
|
34
|
+
}
|
|
35
|
+
if (arr.length > 0) {
|
|
36
|
+
meta[key] = arr;
|
|
37
|
+
i = j;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
meta[key] = inline === '' ? true : inline;
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return meta;
|
|
45
|
+
}
|
|
46
|
+
const FENCE = /^---\s*$/m;
|
|
47
|
+
function firstParagraph(body) {
|
|
48
|
+
const trimmed = body.trim();
|
|
49
|
+
if (!trimmed)
|
|
50
|
+
return undefined;
|
|
51
|
+
for (const chunk of trimmed.split(/\n\s*\n/)) {
|
|
52
|
+
const para = chunk.split('\n').filter(l => !l.startsWith('#')).join(' ').trim();
|
|
53
|
+
if (para)
|
|
54
|
+
return para;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
export function parse(md, opts = {}) {
|
|
59
|
+
const diagnostics = [];
|
|
60
|
+
const parts = md.split(FENCE);
|
|
61
|
+
let meta = {};
|
|
62
|
+
let body;
|
|
63
|
+
if (parts.length < 3) {
|
|
64
|
+
body = md.trim();
|
|
65
|
+
if (opts.pathStem) {
|
|
66
|
+
meta.name = opts.pathStem;
|
|
67
|
+
diagnostics.push({ level: 'warn', code: 'no-frontmatter', message: `No frontmatter; deriving name='${opts.pathStem}' from path` });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
diagnostics.push({ level: 'warn', code: 'no-frontmatter', message: 'No frontmatter and no pathStem provided' });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const yaml = parts[1];
|
|
75
|
+
body = parts.slice(2).join('---').trim();
|
|
76
|
+
try {
|
|
77
|
+
meta = parseFrontmatter(yaml);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
const cleaned = yaml.split('\n').filter(l => !l.match(/^[^:#][^:]*:[^:]*:[^:]*/)).join('\n');
|
|
81
|
+
meta = parseFrontmatter(cleaned);
|
|
82
|
+
diagnostics.push({ level: 'warn', code: 'lenient-yaml', message: 'Frontmatter required lenient retry (unquoted colons)' });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!meta.name && opts.pathStem) {
|
|
86
|
+
meta.name = opts.pathStem;
|
|
87
|
+
diagnostics.push({ level: 'warn', code: 'missing-name', message: `Missing name; using path stem '${opts.pathStem}'` });
|
|
88
|
+
}
|
|
89
|
+
if (opts.pathStem && meta.name && meta.name !== opts.pathStem) {
|
|
90
|
+
diagnostics.push({ level: 'warn', code: 'name-mismatch', message: `name='${String(meta.name)}' does not match path stem '${opts.pathStem}'` });
|
|
91
|
+
}
|
|
92
|
+
if (typeof meta.name === 'string' && meta.name.length > 64) {
|
|
93
|
+
diagnostics.push({ level: 'warn', code: 'name-too-long', message: `name length ${meta.name.length} exceeds 64 chars` });
|
|
94
|
+
}
|
|
95
|
+
if (!meta.description) {
|
|
96
|
+
const para = firstParagraph(body);
|
|
97
|
+
if (para) {
|
|
98
|
+
meta.description = para;
|
|
99
|
+
diagnostics.push({ level: 'info', code: 'description-from-body', message: 'Derived description from first body paragraph' });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const triggersStr = typeof meta.triggers === 'string'
|
|
103
|
+
? meta.triggers
|
|
104
|
+
: Array.isArray(meta.triggers)
|
|
105
|
+
? meta.triggers.map(String).join(', ')
|
|
106
|
+
: '';
|
|
107
|
+
if (triggersStr) {
|
|
108
|
+
const base = typeof meta.description === 'string' ? meta.description : '';
|
|
109
|
+
meta.description = base ? `${base} Triggers: ${triggersStr}` : `Triggers: ${triggersStr}`;
|
|
110
|
+
diagnostics.push({ level: 'info', code: 'triggers-merged', message: "'triggers' field merged into description" });
|
|
111
|
+
}
|
|
112
|
+
return { meta, body, diagnostics };
|
|
113
|
+
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { resolve, basename, join } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { parse as parseSkill } from './skill-parser.js';
|
|
6
|
+
export function skillCmd() {
|
|
7
|
+
const cmd = new Command('skill').description('Skill management');
|
|
8
|
+
cmd.command('new <name>')
|
|
9
|
+
.description('Scaffold a new skill from template (includes 3 example evals)')
|
|
10
|
+
.action((name) => {
|
|
11
|
+
const body = [
|
|
12
|
+
'---',
|
|
13
|
+
`name: ${name}`,
|
|
14
|
+
`title: ${name}`,
|
|
15
|
+
'summary: ',
|
|
16
|
+
'description: Use when ',
|
|
17
|
+
'tags: []',
|
|
18
|
+
'price: 0.02',
|
|
19
|
+
'evals:',
|
|
20
|
+
' - prompt: Replace with a representative request your skill should handle.',
|
|
21
|
+
' assertions:',
|
|
22
|
+
' - Produces the expected outcome',
|
|
23
|
+
' - Tone matches the skill description',
|
|
24
|
+
' - prompt: Edge case — replace with a tricky input.',
|
|
25
|
+
' assertions:',
|
|
26
|
+
' - Handles the edge case correctly',
|
|
27
|
+
' - Does not invent facts',
|
|
28
|
+
' - prompt: Negative case — input the skill should refuse or redirect.',
|
|
29
|
+
' assertions:',
|
|
30
|
+
' - Declines or redirects politely',
|
|
31
|
+
' - Suggests the right next step',
|
|
32
|
+
'---',
|
|
33
|
+
'',
|
|
34
|
+
`# ${name}`,
|
|
35
|
+
'',
|
|
36
|
+
'Skill behavior here.',
|
|
37
|
+
'',
|
|
38
|
+
].join('\n');
|
|
39
|
+
mkdirSync('skills', { recursive: true });
|
|
40
|
+
const path = `skills/${name}.md`;
|
|
41
|
+
writeFileSync(path, body);
|
|
42
|
+
out(cmd, { ok: true, path, lines: body.split('\n').length });
|
|
43
|
+
});
|
|
44
|
+
cmd.command('emit <path>')
|
|
45
|
+
.description('Emit agentskills.io directory format from flat skill.md')
|
|
46
|
+
.option('--out <dir>', 'Output directory', './')
|
|
47
|
+
.action((path, opts) => {
|
|
48
|
+
if (!existsSync(path)) {
|
|
49
|
+
out(cmd, { ok: false, error: `not found: ${path}` });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const name = basename(path, '.md');
|
|
53
|
+
const outDir = resolve(opts.out, name);
|
|
54
|
+
mkdirSync(outDir, { recursive: true });
|
|
55
|
+
const content = readFileSync(path, 'utf8');
|
|
56
|
+
writeFileSync(resolve(outDir, 'SKILL.md'), content);
|
|
57
|
+
out(cmd, { ok: true, source: path, emitted: outDir, files: ['SKILL.md'] });
|
|
58
|
+
});
|
|
59
|
+
cmd.command('publish <path>')
|
|
60
|
+
.description('Publish skill to agentskills.io directory')
|
|
61
|
+
.action((path) => {
|
|
62
|
+
if (!existsSync(path)) {
|
|
63
|
+
out(cmd, { ok: false, error: `not found: ${path}` });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
out(cmd, { ok: false, reason: 'agentskills.io API key required — set AGENTSKILLS_API_KEY' });
|
|
67
|
+
});
|
|
68
|
+
cmd.command('refresh <slug> [refs...]')
|
|
69
|
+
.description('Re-fetch remote imported skills for a slug')
|
|
70
|
+
.action((slug, refs) => {
|
|
71
|
+
out(cmd, { ok: true, slug, refreshed: 0, failed: 0, total: refs.length });
|
|
72
|
+
});
|
|
73
|
+
cmd.command('import <ref>')
|
|
74
|
+
.description('Import a skill from URL, npm, or github shorthand')
|
|
75
|
+
.option('--slug <slug>', 'Owner slug', process.env.ONEIE_SLUG ?? 'local')
|
|
76
|
+
.option('--price <usd>', 'Price USD', '0.02')
|
|
77
|
+
.option('--name <name>', 'Override skill name')
|
|
78
|
+
.option('--yes', 'Skip approval prompt (CI-friendly)')
|
|
79
|
+
.action(async (ref, opts) => {
|
|
80
|
+
const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
|
|
81
|
+
const token = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
|
|
82
|
+
if (!token) {
|
|
83
|
+
out(cmd, { ok: false, error: 'not authenticated — run `oneie auth login`' });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const baseUrl = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
|
|
87
|
+
try {
|
|
88
|
+
const res = await fetch(`${baseUrl}/api/skill/import`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
91
|
+
body: JSON.stringify({ ref, slug: opts.slug, price: Number(opts.price), name: opts.name }),
|
|
92
|
+
});
|
|
93
|
+
const data = await res.json().catch(() => ({}));
|
|
94
|
+
if (!res.ok) {
|
|
95
|
+
out(cmd, { ok: false, status: res.status, ...data });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const sealed = data?.skill?.sealed === true;
|
|
99
|
+
out(cmd, {
|
|
100
|
+
ok: true,
|
|
101
|
+
ref,
|
|
102
|
+
slug: opts.slug,
|
|
103
|
+
name: data?.skill?.name,
|
|
104
|
+
price: data?.skill?.price,
|
|
105
|
+
tier: sealed ? 'sealed (run-only)' : 'open',
|
|
106
|
+
sealed,
|
|
107
|
+
key: data?.key,
|
|
108
|
+
diagnostics: data?.diagnostics ?? [],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
out(cmd, { ok: false, error: err.message, hint: 'try `oneie skill validate <path>` for offline validation' });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
cmd.command('fork <name>')
|
|
116
|
+
.description('Copy an open skill into a workspace (refuses sealed — invoke-only)')
|
|
117
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
118
|
+
.option('--api <url>', 'API base URL', 'https://one.ie')
|
|
119
|
+
.action(async (name, opts) => {
|
|
120
|
+
const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
|
|
121
|
+
const key = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
|
|
122
|
+
if (!key) {
|
|
123
|
+
out(cmd, { ok: false, error: 'no API key — run `oneie auth login`' });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const token = `${opts.slug}:${key}`;
|
|
127
|
+
try {
|
|
128
|
+
const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/skills/workspace?slug=${encodeURIComponent(opts.slug)}`, {
|
|
129
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
130
|
+
});
|
|
131
|
+
const data = await res.json();
|
|
132
|
+
if (!res.ok) {
|
|
133
|
+
out(cmd, { ok: false, status: res.status, error: data.error ?? 'fork failed' });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const skill = (data.skills ?? []).find((s) => s.name === name);
|
|
137
|
+
if (!skill) {
|
|
138
|
+
out(cmd, { ok: false, error: `not found: ${name}` });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (skill.sealed) {
|
|
142
|
+
out(cmd, { ok: false, error: 'sealed skills are invoke-only' });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
out(cmd, { ok: true, forked: name, slug: opts.slug, tier: 'open' });
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
out(cmd, { ok: false, error: err.message });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
cmd.command('list')
|
|
152
|
+
.description('List skills imported into a workspace')
|
|
153
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
154
|
+
.option('--api <url>', 'API base URL', 'https://one.ie')
|
|
155
|
+
.action(async (opts) => {
|
|
156
|
+
const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
|
|
157
|
+
const key = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
|
|
158
|
+
if (!key) {
|
|
159
|
+
out(cmd, { ok: false, error: 'no API key — run `oneie auth login`' });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const token = `${opts.slug}:${key}`;
|
|
163
|
+
try {
|
|
164
|
+
const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/skills/workspace?slug=${encodeURIComponent(opts.slug)}`, {
|
|
165
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
166
|
+
});
|
|
167
|
+
const data = await res.json();
|
|
168
|
+
if (!res.ok) {
|
|
169
|
+
out(cmd, { ok: false, status: res.status, error: data.error ?? 'list failed' });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
out(cmd, { ok: true, ...data });
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
out(cmd, { ok: false, error: err.message });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
cmd.command('unimport <name>')
|
|
179
|
+
.description('Remove an imported skill from a workspace')
|
|
180
|
+
.requiredOption('--slug <slug>', 'Workspace slug')
|
|
181
|
+
.option('--api <url>', 'API base URL', 'https://one.ie')
|
|
182
|
+
.action(async (name, opts) => {
|
|
183
|
+
const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
|
|
184
|
+
const key = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
|
|
185
|
+
if (!key) {
|
|
186
|
+
out(cmd, { ok: false, error: 'no API key — run `oneie auth login`' });
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const token = `${opts.slug}:${key}`;
|
|
190
|
+
try {
|
|
191
|
+
const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/skill/${encodeURIComponent(name)}?slug=${encodeURIComponent(opts.slug)}`, {
|
|
192
|
+
method: 'DELETE',
|
|
193
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
194
|
+
});
|
|
195
|
+
const data = await res.json();
|
|
196
|
+
if (!res.ok) {
|
|
197
|
+
out(cmd, { ok: false, status: res.status, error: data.error ?? 'unimport failed' });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
out(cmd, { ok: true, ...data });
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
out(cmd, { ok: false, error: err.message });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
cmd.command('validate <path>')
|
|
207
|
+
.description('Validate a skill file or directory; reports diagnostics')
|
|
208
|
+
.action((path) => {
|
|
209
|
+
if (!existsSync(path)) {
|
|
210
|
+
out(cmd, { ok: false, error: `not found: ${path}` });
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const targets = [];
|
|
214
|
+
const walk = (dir, depth) => {
|
|
215
|
+
if (depth > 4)
|
|
216
|
+
return;
|
|
217
|
+
const skillMd = join(dir, 'SKILL.md');
|
|
218
|
+
if (existsSync(skillMd) && statSync(skillMd).isFile()) {
|
|
219
|
+
targets.push({ file: skillMd, stem: basename(dir) });
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
for (const entry of readdirSync(dir)) {
|
|
223
|
+
if (entry.startsWith('.') || entry === 'node_modules')
|
|
224
|
+
continue;
|
|
225
|
+
const full = join(dir, entry);
|
|
226
|
+
const sub = statSync(full);
|
|
227
|
+
if (sub.isFile() && entry.endsWith('.md') && entry !== 'SKILL.md') {
|
|
228
|
+
targets.push({ file: full, stem: basename(entry, '.md') });
|
|
229
|
+
}
|
|
230
|
+
else if (sub.isDirectory()) {
|
|
231
|
+
walk(full, depth + 1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const st = statSync(path);
|
|
236
|
+
if (st.isDirectory()) {
|
|
237
|
+
walk(path, 0);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const stem = path.endsWith('/SKILL.md')
|
|
241
|
+
? basename(resolve(path, '..'))
|
|
242
|
+
: basename(path, '.md');
|
|
243
|
+
targets.push({ file: path, stem });
|
|
244
|
+
}
|
|
245
|
+
const results = targets.map(t => {
|
|
246
|
+
const text = readFileSync(t.file, 'utf8');
|
|
247
|
+
const parsed = parseSkill(text, { pathStem: t.stem });
|
|
248
|
+
const warns = parsed.diagnostics.filter((d) => d.level === 'warn');
|
|
249
|
+
return {
|
|
250
|
+
file: t.file,
|
|
251
|
+
name: parsed.meta.name ?? null,
|
|
252
|
+
ok: typeof parsed.meta.name === 'string' && !!parsed.meta.description,
|
|
253
|
+
diagnostics: parsed.diagnostics,
|
|
254
|
+
warnCount: warns.length,
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
const okCount = results.filter(r => r.ok).length;
|
|
258
|
+
out(cmd, { ok: okCount === results.length, total: results.length, passed: okCount, results });
|
|
259
|
+
});
|
|
260
|
+
cmd.command('eval <path>')
|
|
261
|
+
.description('Run skill evals from frontmatter evals[] via POST /api/eval')
|
|
262
|
+
.option('--slug <slug>', 'Workspace slug', process.env.ONEIE_SLUG ?? 'local')
|
|
263
|
+
.option('--api <url>', 'API base URL', process.env.ONEIE_BASE_URL ?? 'https://one.ie')
|
|
264
|
+
.option('--iteration <n>', 'Iteration number', '1')
|
|
265
|
+
.action(async (path, opts) => {
|
|
266
|
+
if (!existsSync(path)) {
|
|
267
|
+
out(cmd, { ok: false, error: `not found: ${path}` });
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
|
|
271
|
+
const token = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
|
|
272
|
+
if (!token) {
|
|
273
|
+
out(cmd, { ok: false, error: 'not authenticated — run `oneie auth login`' });
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const content = readFileSync(path, 'utf8');
|
|
277
|
+
const parsed = parseSkill(content, { pathStem: basename(path, '.md') });
|
|
278
|
+
const skillName = typeof parsed.meta.name === 'string' ? parsed.meta.name : basename(path, '.md');
|
|
279
|
+
const evals = extractEvals(content);
|
|
280
|
+
if (!evals.length) {
|
|
281
|
+
out(cmd, { ok: false, error: 'no evals found in frontmatter — add an evals: block (see `oneie skill new`)' });
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/eval`, {
|
|
286
|
+
method: 'POST',
|
|
287
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${opts.slug}:${token}` },
|
|
288
|
+
body: JSON.stringify({ slug: opts.slug, skillPath: skillName, iteration: Number(opts.iteration), draftContent: content, draftEvals: evals }),
|
|
289
|
+
});
|
|
290
|
+
const data = await res.json().catch(() => ({}));
|
|
291
|
+
if (!res.ok) {
|
|
292
|
+
out(cmd, { ok: false, status: res.status, error: data?.error ?? 'eval failed' });
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const b = data?.benchmark;
|
|
296
|
+
const m = data?.mastery;
|
|
297
|
+
out(cmd, {
|
|
298
|
+
ok: true,
|
|
299
|
+
skill: skillName,
|
|
300
|
+
cases: evals.length,
|
|
301
|
+
pass_rate: b?.with_skill?.pass_rate,
|
|
302
|
+
delta_pass: b?.delta?.pass_rate,
|
|
303
|
+
mastery_level: m?.level,
|
|
304
|
+
mastery_prob: m?.prob,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
out(cmd, { ok: false, error: err.message });
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return cmd;
|
|
312
|
+
}
|
|
313
|
+
// Mirrors one.ie/web/src/lib/eval/evals-source.ts and packages/mcp/src/tools/lifecycle.ts
|
|
314
|
+
function extractEvals(content) {
|
|
315
|
+
const fm = content.match(/^---\n([\s\S]*?)\n---/)?.[1];
|
|
316
|
+
if (!fm)
|
|
317
|
+
return [];
|
|
318
|
+
const lines = fm.split('\n');
|
|
319
|
+
const startIdx = lines.findIndex(l => /^evals:\s*$/.test(l));
|
|
320
|
+
if (startIdx < 0)
|
|
321
|
+
return [];
|
|
322
|
+
const unquote = (s) => s.replace(/^["']|["']$/g, '');
|
|
323
|
+
const cases = [];
|
|
324
|
+
let cur = null;
|
|
325
|
+
let inAssertions = false;
|
|
326
|
+
for (let i = startIdx + 1; i < lines.length; i++) {
|
|
327
|
+
const line = lines[i];
|
|
328
|
+
if (/^[A-Za-z_][\w-]*:/.test(line))
|
|
329
|
+
break;
|
|
330
|
+
const promptMatch = line.match(/^\s+-\s+prompt:\s*(.+?)\s*$/);
|
|
331
|
+
if (promptMatch) {
|
|
332
|
+
if (cur)
|
|
333
|
+
cases.push(cur);
|
|
334
|
+
cur = { id: `case-${cases.length + 1}`, prompt: unquote(promptMatch[1]), expected: '', assertions: [] };
|
|
335
|
+
inAssertions = false;
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (!cur)
|
|
339
|
+
continue;
|
|
340
|
+
const idMatch = line.match(/^\s+id:\s*(.+?)\s*$/);
|
|
341
|
+
if (idMatch) {
|
|
342
|
+
cur.id = unquote(idMatch[1]);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
const expectedMatch = line.match(/^\s+expected:\s*(.+?)\s*$/);
|
|
346
|
+
if (expectedMatch) {
|
|
347
|
+
cur.expected = unquote(expectedMatch[1]);
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (/^\s+assertions:\s*$/.test(line)) {
|
|
351
|
+
inAssertions = true;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const itemMatch = line.match(/^\s+-\s+(.+?)\s*$/);
|
|
355
|
+
if (itemMatch && inAssertions)
|
|
356
|
+
cur.assertions.push(unquote(itemMatch[1]));
|
|
357
|
+
}
|
|
358
|
+
if (cur)
|
|
359
|
+
cases.push(cur);
|
|
360
|
+
return cases.filter(c => c.prompt && c.assertions.length > 0);
|
|
361
|
+
}
|
|
362
|
+
function out(cmd, data) {
|
|
363
|
+
const isJson = cmd.parent?.opts().json;
|
|
364
|
+
if (isJson) {
|
|
365
|
+
process.stdout.write(JSON.stringify(data) + '\n');
|
|
366
|
+
}
|
|
367
|
+
else if (data.ok) {
|
|
368
|
+
const pairs = Object.entries(data)
|
|
369
|
+
.filter(([k]) => k !== 'ok')
|
|
370
|
+
.map(([k, v]) => `${k}=${JSON.stringify(v)}`)
|
|
371
|
+
.join(' ');
|
|
372
|
+
console.log('✓', pairs);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
console.error('✗', String(data.error ?? data.reason ?? JSON.stringify(data)));
|
|
376
|
+
}
|
|
377
|
+
}
|
package/dist/src/slug.js
ADDED