@oneie/cli 0.2.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,252 @@
1
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://one.ie';
2
+ function apiKey() {
3
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
4
+ }
5
+ function base(opts) {
6
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
7
+ }
8
+ function headers() {
9
+ const h = { 'Content-Type': 'application/json' };
10
+ const k = apiKey();
11
+ if (k)
12
+ h['Authorization'] = `Bearer ${k}`;
13
+ return h;
14
+ }
15
+ async function api(url, init) {
16
+ const res = await fetch(url, { headers: headers(), ...init });
17
+ if (!res.ok) {
18
+ const body = await res.text().catch(() => '');
19
+ process.stderr.write(`${init?.method ?? 'GET'} ${url} → ${res.status}\n${body}\n`);
20
+ process.exit(1);
21
+ }
22
+ const ct = res.headers.get('content-type') ?? '';
23
+ return ct.includes('json') ? res.json() : res.text();
24
+ }
25
+ function out(data) {
26
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
27
+ }
28
+ function parseJson(raw, flag) {
29
+ try {
30
+ return JSON.parse(raw);
31
+ }
32
+ catch {
33
+ process.stderr.write(`error: ${flag} must be valid JSON\n`);
34
+ process.exit(1);
35
+ }
36
+ }
37
+ async function readStdin() {
38
+ return new Promise((resolve) => {
39
+ let buf = '';
40
+ process.stdin.setEncoding('utf8');
41
+ process.stdin.on('data', (chunk) => { buf += chunk; });
42
+ process.stdin.on('end', () => resolve(buf.trim()));
43
+ });
44
+ }
45
+ export function substrateCommands(program) {
46
+ program
47
+ .command('signal <receiver>')
48
+ .description('Fire-and-forget signal to any receiver')
49
+ .option('--data <json>', 'Signal data as JSON. Use "-" to read from stdin.')
50
+ .option('--api <url>', 'API base URL', DEFAULT_API)
51
+ .action(async (receiver, opts) => {
52
+ let data;
53
+ if (opts.data === '-')
54
+ data = parseJson(await readStdin(), '--data');
55
+ else if (opts.data)
56
+ data = parseJson(opts.data, '--data');
57
+ out(await api(`${base(opts)}/api/signal/${encodeURIComponent(receiver)}`, {
58
+ method: 'POST',
59
+ body: JSON.stringify({ data }),
60
+ }));
61
+ });
62
+ program
63
+ .command('ask <receiver>')
64
+ .description('Signal + wait for outcome (result | timeout | dissolved | failure)')
65
+ .option('--data <json>', 'Signal data as JSON. Use "-" to read from stdin.')
66
+ .option('--timeout <ms>', 'Timeout in milliseconds', '10000')
67
+ .option('--api <url>', 'API base URL', DEFAULT_API)
68
+ .action(async (receiver, opts) => {
69
+ let data;
70
+ if (opts.data === '-')
71
+ data = parseJson(await readStdin(), '--data');
72
+ else if (opts.data)
73
+ data = parseJson(opts.data, '--data');
74
+ out(await api(`${base(opts)}/api/ask/${encodeURIComponent(receiver)}`, {
75
+ method: 'POST',
76
+ body: JSON.stringify({ data, timeoutMs: Number(opts.timeout) }),
77
+ }));
78
+ });
79
+ program
80
+ .command('mark <edge>')
81
+ .description('Strengthen a path. Edge format: source>target')
82
+ .option('--strength <n>', 'Strength value', '1')
83
+ .option('--api <url>', 'API base URL', DEFAULT_API)
84
+ .action(async (edge, opts) => {
85
+ out(await api(`${base(opts)}/api/mark/${encodeURIComponent(edge)}`, {
86
+ method: 'POST',
87
+ body: JSON.stringify({ strength: Number(opts.strength) }),
88
+ }));
89
+ });
90
+ program
91
+ .command('warn <edge>')
92
+ .description('Raise resistance on a path. Edge format: source>target')
93
+ .option('--strength <n>', 'Strength value', '1')
94
+ .option('--api <url>', 'API base URL', DEFAULT_API)
95
+ .action(async (edge, opts) => {
96
+ out(await api(`${base(opts)}/api/warn/${encodeURIComponent(edge)}`, {
97
+ method: 'POST',
98
+ body: JSON.stringify({ strength: Number(opts.strength) }),
99
+ }));
100
+ });
101
+ program
102
+ .command('fade')
103
+ .description('Asymmetric decay of all paths')
104
+ .option('--rate <n>', 'Decay rate 0–1')
105
+ .option('--api <url>', 'API base URL', DEFAULT_API)
106
+ .action(async (opts) => {
107
+ out(await api(`${base(opts)}/api/fade`, {
108
+ method: 'POST',
109
+ body: JSON.stringify({ rate: opts.rate !== undefined ? Number(opts.rate) : undefined }),
110
+ }));
111
+ });
112
+ program
113
+ .command('sub <tag> <actor>')
114
+ .description('Subscribe an actor to a tag')
115
+ .option('--scope <scope>', 'private | public', 'private')
116
+ .option('--api <url>', 'API base URL', DEFAULT_API)
117
+ .action(async (tag, actor, opts) => {
118
+ out(await api(`${base(opts)}/api/sub`, {
119
+ method: 'POST',
120
+ body: JSON.stringify({ receiver: actor, tags: [tag], scope: opts.scope }),
121
+ }));
122
+ });
123
+ program
124
+ .command('follow <type>')
125
+ .description('Deterministic path selection — strongest path for a type')
126
+ .option('--api <url>', 'API base URL', DEFAULT_API)
127
+ .action(async (type, opts) => {
128
+ out(await api(`${base(opts)}/api/follow?tag=${encodeURIComponent(type)}`));
129
+ });
130
+ program
131
+ .command('select <type>')
132
+ .description('Probabilistic path selection (pheromone-weighted)')
133
+ .option('--exploration <n>', 'Exploration factor 0–1')
134
+ .option('--api <url>', 'API base URL', DEFAULT_API)
135
+ .action(async (type, opts) => {
136
+ const q = new URLSearchParams({ type });
137
+ if (opts.exploration)
138
+ q.set('exploration', opts.exploration);
139
+ out(await api(`${base(opts)}/api/select?${q}`));
140
+ });
141
+ program
142
+ .command('groups')
143
+ .description('List groups (dimension 1 — containers)')
144
+ .option('--type <type>')
145
+ .option('--limit <n>', 'Max results', '20')
146
+ .option('--after <cursor>', 'Pagination cursor')
147
+ .option('--api <url>', 'API base URL', DEFAULT_API)
148
+ .action(async (opts) => {
149
+ const q = new URLSearchParams({ limit: opts.limit });
150
+ if (opts.type)
151
+ q.set('type', opts.type);
152
+ if (opts.after)
153
+ q.set('after', opts.after);
154
+ out(await api(`${base(opts)}/api/export/groups?${q}`));
155
+ });
156
+ program
157
+ .command('actors')
158
+ .description('List actors (dimension 2 — humans, agents, bots)')
159
+ .option('--type <type>')
160
+ .option('--tag <tag>')
161
+ .option('--limit <n>', 'Max results', '20')
162
+ .option('--after <cursor>')
163
+ .option('--api <url>', 'API base URL', DEFAULT_API)
164
+ .action(async (opts) => {
165
+ const q = new URLSearchParams({ limit: opts.limit });
166
+ if (opts.type)
167
+ q.set('type', opts.type);
168
+ if (opts.tag)
169
+ q.set('tag', opts.tag);
170
+ if (opts.after)
171
+ q.set('after', opts.after);
172
+ out(await api(`${base(opts)}/api/export/actors?${q}`));
173
+ });
174
+ program
175
+ .command('things')
176
+ .description('List things (dimension 3 — skills, tasks, tokens)')
177
+ .option('--type <type>')
178
+ .option('--tag <tag>')
179
+ .option('--limit <n>', 'Max results', '20')
180
+ .option('--after <cursor>')
181
+ .option('--api <url>', 'API base URL', DEFAULT_API)
182
+ .action(async (opts) => {
183
+ const q = new URLSearchParams({ limit: opts.limit });
184
+ if (opts.type)
185
+ q.set('type', opts.type);
186
+ if (opts.tag)
187
+ q.set('tag', opts.tag);
188
+ if (opts.after)
189
+ q.set('after', opts.after);
190
+ out(await api(`${base(opts)}/api/things?${q}`));
191
+ });
192
+ program
193
+ .command('paths')
194
+ .description('List paths (dimension 4 — weighted connections)')
195
+ .option('--source <source>')
196
+ .option('--target <target>')
197
+ .option('--min-strength <n>', 'Minimum strength filter')
198
+ .option('--limit <n>', 'Max results', '20')
199
+ .option('--after <cursor>')
200
+ .option('--api <url>', 'API base URL', DEFAULT_API)
201
+ .action(async (opts) => {
202
+ const q = new URLSearchParams({ limit: opts.limit });
203
+ if (opts.source)
204
+ q.set('source', opts.source);
205
+ if (opts.target)
206
+ q.set('target', opts.target);
207
+ if (opts.minStrength)
208
+ q.set('minStrength', opts.minStrength);
209
+ if (opts.after)
210
+ q.set('after', opts.after);
211
+ out(await api(`${base(opts)}/api/export/paths?${q}`));
212
+ });
213
+ program
214
+ .command('events')
215
+ .description('List events (dimension 5 — signals, payments)')
216
+ .option('--actor <actor>')
217
+ .option('--tag <tag>')
218
+ .option('--from <iso>', 'ISO timestamp filter from')
219
+ .option('--to <iso>', 'ISO timestamp filter to')
220
+ .option('--limit <n>', 'Max results', '20')
221
+ .option('--api <url>', 'API base URL', DEFAULT_API)
222
+ .action(async (opts) => {
223
+ const q = new URLSearchParams({ limit: opts.limit });
224
+ if (opts.actor)
225
+ q.set('actor', opts.actor);
226
+ if (opts.tag)
227
+ q.set('tag', opts.tag);
228
+ if (opts.from)
229
+ q.set('from', opts.from);
230
+ if (opts.to)
231
+ q.set('to', opts.to);
232
+ out(await api(`${base(opts)}/api/events?${q}`));
233
+ });
234
+ program
235
+ .command('learning')
236
+ .description('List hypotheses (dimension 6 — what was discovered)')
237
+ .option('--status <status>', 'pending | testing | confirmed | rejected')
238
+ .option('--actor <actor>')
239
+ .option('--tag <tag>')
240
+ .option('--limit <n>', 'Max results', '20')
241
+ .option('--api <url>', 'API base URL', DEFAULT_API)
242
+ .action(async (opts) => {
243
+ const q = new URLSearchParams({ limit: opts.limit });
244
+ if (opts.status)
245
+ q.set('status', opts.status);
246
+ if (opts.actor)
247
+ q.set('actor', opts.actor);
248
+ if (opts.tag)
249
+ q.set('tag', opts.tag);
250
+ out(await api(`${base(opts)}/api/learning?${q}`));
251
+ });
252
+ }
@@ -0,0 +1 @@
1
+ export declare const TEMPLATES: Record<string, string>;
@@ -0,0 +1,205 @@
1
+ export const TEMPLATES = {
2
+ core: `---
3
+ agentmd: "0.1"
4
+ name: template
5
+ title: Template Agent
6
+ model: anthropic/claude-haiku-4-5
7
+ summary: A helpful agent.
8
+ description: Use when you need to accomplish tasks.
9
+ sensitivity: public
10
+ lifecycle: active
11
+ ---
12
+
13
+ You are a helpful assistant. Complete tasks clearly and concisely.
14
+ `,
15
+ commerce: `---
16
+ agentmd: "0.1"
17
+ name: template
18
+ title: Template Commerce Agent
19
+ model: anthropic/claude-haiku-4-5
20
+ summary: An agent that provides paid services.
21
+ description: Use when you need paid skill execution with x402 payments.
22
+ sensitivity: public
23
+ lifecycle: active
24
+ skills: []
25
+ wallet: ""
26
+ accepts:
27
+ - scheme: exact
28
+ network: "eip155:8453"
29
+ asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
30
+ max: "0.05"
31
+ ---
32
+
33
+ You provide services at a fee. Verify payment before executing paid skills.
34
+ `,
35
+ asi: `---
36
+ agentmd: "0.1"
37
+ name: template
38
+ title: Template ASI Agent
39
+ model: anthropic/claude-opus-4-7
40
+ summary: An autonomous agent registered on Fetch.ai Almanac.
41
+ description: Use for long-running autonomous tasks and multi-agent coordination.
42
+ sensitivity: restricted
43
+ lifecycle: active
44
+ mailbox: true
45
+ agentverse: https://agentverse.ai
46
+ intervals:
47
+ - period: 300
48
+ task: Check for new signals and coordinate with peer agents.
49
+ skills: []
50
+ ---
51
+
52
+ You are an autonomous agent. Coordinate with peers, monitor signals, and act on intervals.
53
+ `,
54
+ 'travel-planner': `---
55
+ agentmd: "0.1"
56
+ name: template
57
+ title: Travel Planner
58
+ model: anthropic/claude-sonnet-4-5
59
+ summary: Creates detailed travel itineraries with real logistics and budgets.
60
+ description: Use when you need personalised travel planning — itinerary, budget, packing.
61
+ sensitivity: public
62
+ lifecycle: active
63
+ tools:
64
+ - emit_card
65
+ - emit_chips
66
+ skills:
67
+ - name: plan
68
+ description: Research and create a day-by-day travel itinerary
69
+ price: 0.10
70
+ tags: [travel, planning, itinerary]
71
+ - name: budget
72
+ description: Estimate trip costs including flights, hotels, meals, activities
73
+ price: 0.05
74
+ tags: [travel, budget, finance]
75
+ ---
76
+
77
+ You are a personal travel planner. You turn destinations and dates into detailed, actionable itineraries — real places, real logistics, real costs.
78
+
79
+ Ask first: where, when, how long, who's going, budget range. Then deliver a day-by-day plan with morning/afternoon/evening blocks, transport options, and booking notes.
80
+ `,
81
+ 'marketing-strategist': `---
82
+ agentmd: "0.1"
83
+ name: template
84
+ title: Marketing Strategist
85
+ model: anthropic/claude-sonnet-4-5
86
+ summary: Audits channels, plans campaigns, writes copy, and reads metrics.
87
+ description: Use when you need strategic marketing thinking plus concrete deliverables.
88
+ sensitivity: public
89
+ lifecycle: active
90
+ tools:
91
+ - emit_card
92
+ - emit_chips
93
+ skills:
94
+ - name: audit
95
+ description: Audit existing marketing channels and surface quick wins
96
+ price: 0.08
97
+ tags: [marketing, audit, analysis]
98
+ - name: campaign
99
+ description: Plan a campaign from brief to launch checklist
100
+ price: 0.12
101
+ tags: [marketing, campaign, strategy]
102
+ - name: copy
103
+ description: Write headlines, CTAs, email subjects, ad copy variants
104
+ price: 0.06
105
+ tags: [marketing, copy, writing]
106
+ ---
107
+
108
+ You are a senior marketing strategist. You think in funnels and ICPs, then translate that into concrete copy and launch plans any team can execute.
109
+
110
+ Start by understanding the product, the customer, and the current state of marketing. Then: audit → recommend → plan → execute.
111
+ `,
112
+ 'support-tier1': `---
113
+ agentmd: "0.1"
114
+ name: template
115
+ title: Support — Tier 1
116
+ model: anthropic/claude-sonnet-4-5
117
+ summary: Resolves common support issues fast; escalates edge cases with full context.
118
+ description: Use as a first-line support agent for how-to, account, and billing questions.
119
+ sensitivity: public
120
+ lifecycle: active
121
+ tools:
122
+ - emit_card
123
+ - emit_chips
124
+ skills:
125
+ - name: triage
126
+ description: Classify the issue and route to the right resolution path
127
+ price: 0.02
128
+ tags: [support, triage, routing]
129
+ - name: resolve
130
+ description: Walk the user through a step-by-step fix
131
+ price: 0.03
132
+ tags: [support, resolution, troubleshooting]
133
+ - name: escalate
134
+ description: Prepare a structured escalation summary for Tier 2
135
+ price: 0.02
136
+ tags: [support, escalation, handoff]
137
+ ---
138
+
139
+ You are a Tier 1 support agent. Your job is to resolve common issues fast, escalate edge cases with full context, and leave every user feeling heard.
140
+
141
+ 1. Acknowledge — one sentence that shows you understand the problem. 2. Triage — classify: account / billing / bug / how-to / feature request. 3. Resolve — walk through it step by step. 4. Escalate — prepare a clean handoff summary.
142
+ `,
143
+ 'sales-discovery': `---
144
+ agentmd: "0.1"
145
+ name: template
146
+ title: Sales Discovery
147
+ model: anthropic/claude-sonnet-4-5
148
+ summary: Qualifies leads, preps discovery calls, handles objections, and structures proposals.
149
+ description: Use to accelerate the discovery-to-proposal stage of your sales process.
150
+ sensitivity: restricted
151
+ lifecycle: active
152
+ tools:
153
+ - emit_card
154
+ - emit_chips
155
+ skills:
156
+ - name: qualify
157
+ description: Run a BANT qualification check on an inbound lead
158
+ price: 0.04
159
+ tags: [sales, qualification, lead]
160
+ - name: discovery
161
+ description: Deep-dive discovery call questions for a specific ICP
162
+ price: 0.06
163
+ tags: [sales, discovery, questions]
164
+ - name: proposal
165
+ description: Outline a custom proposal structure for a qualified account
166
+ price: 0.08
167
+ tags: [sales, proposal, closing]
168
+ ---
169
+
170
+ You are a sales discovery specialist. You help sales reps qualify faster, ask sharper questions, and turn stalled conversations into momentum.
171
+
172
+ Start with the lead context: industry, size, role, how they came in. Then run the right playbook: qualify → discover → handle objections → propose.
173
+ `,
174
+ 'code-reviewer': `---
175
+ agentmd: "0.1"
176
+ name: template
177
+ title: Code Reviewer
178
+ model: anthropic/claude-sonnet-4-5
179
+ summary: Gives concrete, severity-labelled code review findings with actionable fixes.
180
+ description: Use for code review, security audits, performance checks, and refactor suggestions.
181
+ sensitivity: restricted
182
+ lifecycle: active
183
+ tools:
184
+ - emit_card
185
+ - emit_chips
186
+ skills:
187
+ - name: review
188
+ description: Full code review with severity-labelled findings
189
+ price: 0.08
190
+ tags: [engineering, review, quality]
191
+ - name: security
192
+ description: Security-focused audit for OWASP Top 10 and common patterns
193
+ price: 0.10
194
+ tags: [engineering, security, audit]
195
+ - name: refactor
196
+ description: Propose a concrete refactor with before/after diffs
197
+ price: 0.08
198
+ tags: [engineering, refactor, design]
199
+ ---
200
+
201
+ You are a senior code reviewer. You give concrete, actionable feedback that improves code quality without creating review theatre.
202
+
203
+ Label every finding: BLOCKER / MAJOR / MINOR / NIT. Always include the specific line reference and a concrete fix — not vague advice.
204
+ `,
205
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@oneie/cli",
3
+ "version": "0.2.0",
4
+ "description": "ONE agent CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "oneie": "./dist/src/index.js",
8
+ "one": "./dist/src/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "dev": "tsx src/index.ts",
17
+ "typecheck": "tsc --noEmit",
18
+ "prepublishOnly": "bun run build"
19
+ },
20
+ "dependencies": {
21
+ "commander": "^12.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^25.6.0",
25
+ "tsx": "^4.0.0",
26
+ "typescript": "^5.4.0"
27
+ },
28
+ "license": "SEE LICENSE IN https://one.ie/free-license",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/one-ie/packages.git",
32
+ "directory": "cli"
33
+ }
34
+ }