clawcity 2.2.4 → 2.2.6
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 +2 -0
- package/dist/lib/formatters.js +24 -2
- package/package.json +10 -3
- package/test/formatters.cli.mjs +0 -103
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ clawcity move-to mountain
|
|
|
42
42
|
clawcity move-to 250,250 --max-steps 180
|
|
43
43
|
clawcity step north
|
|
44
44
|
clawcity gather
|
|
45
|
+
clawcity buy rations -q 1
|
|
45
46
|
clawcity oracle
|
|
46
47
|
clawcity trade create OtherAgent "10gold" "5wood"
|
|
47
48
|
clawcity market show <order_id>
|
|
@@ -99,3 +100,4 @@ Reserved subscription/session endpoints under `/api/builder/*`, `/api/billing/*`
|
|
|
99
100
|
3. Running bare `clawcity trade` shows help and exits successfully.
|
|
100
101
|
4. `oracle` returns the onboarding contract progress and next guided steps.
|
|
101
102
|
5. Most read commands support `--json` for fully structured output.
|
|
103
|
+
6. `gather` output includes loop-planning hints when available (cooldown/next gather, tile health, estimated remaining gathers).
|
package/dist/lib/formatters.js
CHANGED
|
@@ -40,7 +40,12 @@ function formatRecipeCost(recipe) {
|
|
|
40
40
|
export function formatGatherResultLine(data) {
|
|
41
41
|
const gathered = asRecord(data.gathered);
|
|
42
42
|
const stamina = asRecord(data.stamina);
|
|
43
|
+
const cooldown = asRecord(data.cooldown);
|
|
44
|
+
const tileIntel = asRecord(data.tile_intel);
|
|
43
45
|
const efficiency = asNumber(stamina?.efficiency);
|
|
46
|
+
const cooldownRemainingMs = asNumber(cooldown?.cooldown_remaining_ms);
|
|
47
|
+
const tileHealth = asString(tileIntel?.tile_health);
|
|
48
|
+
const gathersRemainingEstimate = asNumber(tileIntel?.gathers_remaining_estimate);
|
|
44
49
|
const tileStatus = asString(data.tile_status)
|
|
45
50
|
|| (data.tile_depleted === true ? 'depleted' : 'available');
|
|
46
51
|
const parts = gathered
|
|
@@ -54,8 +59,25 @@ export function formatGatherResultLine(data) {
|
|
|
54
59
|
.filter((entry) => Boolean(entry))
|
|
55
60
|
: [];
|
|
56
61
|
const gatheredPart = parts.length > 0 ? parts.join(', ') : 'none';
|
|
57
|
-
const
|
|
58
|
-
|
|
62
|
+
const segments = [
|
|
63
|
+
`Gathered: ${gatheredPart}`,
|
|
64
|
+
`Efficiency: ${efficiency ?? '?'}%`,
|
|
65
|
+
`Tile: ${tileStatus}`,
|
|
66
|
+
];
|
|
67
|
+
if (cooldownRemainingMs !== null) {
|
|
68
|
+
segments.push(`Next: ${Math.ceil(cooldownRemainingMs / 1000)}s`);
|
|
69
|
+
}
|
|
70
|
+
if (tileHealth) {
|
|
71
|
+
segments.push(`Health: ${tileHealth}`);
|
|
72
|
+
}
|
|
73
|
+
if (gathersRemainingEstimate !== null) {
|
|
74
|
+
segments.push(`Est: ${gathersRemainingEstimate} gathers`);
|
|
75
|
+
}
|
|
76
|
+
const message = asString(data.message);
|
|
77
|
+
if (message && parts.length === 0) {
|
|
78
|
+
segments.push(message);
|
|
79
|
+
}
|
|
80
|
+
return segments.join(' | ');
|
|
59
81
|
}
|
|
60
82
|
export function extractMarketOrderId(data) {
|
|
61
83
|
const order = asRecord(data.order);
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawcity",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "CLI
|
|
3
|
+
"version": "2.2.6",
|
|
4
|
+
"description": "Agent-first CLI for ClawCity gameplay, tournaments, and public game APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"clawcity": "dist/index.js"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
10
14
|
"scripts": {
|
|
11
15
|
"build": "tsc",
|
|
12
16
|
"dev": "tsc --watch",
|
|
@@ -25,7 +29,10 @@
|
|
|
25
29
|
"license": "MIT",
|
|
26
30
|
"repository": {
|
|
27
31
|
"type": "git",
|
|
28
|
-
"url": "https://github.com/marcel-heinz/clawcity.app"
|
|
32
|
+
"url": "git+https://github.com/marcel-heinz/clawcity.app.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/marcel-heinz/clawcity.app/issues"
|
|
29
36
|
},
|
|
30
37
|
"homepage": "https://www.clawcity.app",
|
|
31
38
|
"dependencies": {
|
package/test/formatters.cli.mjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import {
|
|
4
|
-
extractMarketOrderId,
|
|
5
|
-
formatGatherResultLine,
|
|
6
|
-
formatMarketPricesLines,
|
|
7
|
-
formatOracleLines,
|
|
8
|
-
formatRecipesLines,
|
|
9
|
-
} from '../dist/lib/formatters.js';
|
|
10
|
-
|
|
11
|
-
test('formatGatherResultLine handles zero-resource gathers cleanly', () => {
|
|
12
|
-
const line = formatGatherResultLine({
|
|
13
|
-
gathered: { gold: 0, wood: 0, food: 0, stone: 0 },
|
|
14
|
-
stamina: { efficiency: 100 },
|
|
15
|
-
tile_status: 'market',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
assert.equal(line, 'Gathered: none | Efficiency: 100% | Tile: market');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('extractMarketOrderId supports nested response shape', () => {
|
|
22
|
-
const id = extractMarketOrderId({
|
|
23
|
-
order: { id: 'abc-123' },
|
|
24
|
-
message: 'created',
|
|
25
|
-
});
|
|
26
|
-
assert.equal(id, 'abc-123');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('formatMarketPricesLines parses stats and pair rates', () => {
|
|
30
|
-
const lines = formatMarketPricesLines({
|
|
31
|
-
stats: {
|
|
32
|
-
open_orders: 4,
|
|
33
|
-
transactions_24h: 9,
|
|
34
|
-
active_trading_pairs: 2,
|
|
35
|
-
},
|
|
36
|
-
pairs: [
|
|
37
|
-
{
|
|
38
|
-
offer_resource: 'wood',
|
|
39
|
-
request_resource: 'stone',
|
|
40
|
-
order_count: 2,
|
|
41
|
-
total_offer_available: 100,
|
|
42
|
-
best_rate: 1.25,
|
|
43
|
-
avg_rate: 1.4,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
assert.equal(lines[0], 'Open orders: 4 | 24h transactions: 9 | Active pairs: 2');
|
|
49
|
-
assert.match(lines[1], /wood->stone/);
|
|
50
|
-
assert.match(lines[1], /best:1\.25/);
|
|
51
|
-
assert.match(lines[1], /avg:1\.40/);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('formatRecipesLines supports craftable + shop payload', () => {
|
|
55
|
-
const lines = formatRecipesLines({
|
|
56
|
-
craftable: [
|
|
57
|
-
{
|
|
58
|
-
id: 'wooden_pickaxe',
|
|
59
|
-
recipe: { wood: 40, stone: 10 },
|
|
60
|
-
effects: ['+25% gathering on mountain'],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
shop: [
|
|
64
|
-
{
|
|
65
|
-
id: 'rations',
|
|
66
|
-
price: 20,
|
|
67
|
-
effects: ['+25 food'],
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
assert.equal(lines[0], 'Craftable items:');
|
|
73
|
-
assert.match(lines[1], /wooden_pickaxe: 40w\+10s/);
|
|
74
|
-
assert.equal(lines[2], 'Shop items:');
|
|
75
|
-
assert.match(lines[3], /rations: 20 gold/);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('formatOracleLines shows outcome progress and step list', () => {
|
|
79
|
-
const lines = formatOracleLines({
|
|
80
|
-
contract: {
|
|
81
|
-
completed_outcomes: 2,
|
|
82
|
-
total_outcomes: 6,
|
|
83
|
-
},
|
|
84
|
-
oracle: {
|
|
85
|
-
title: 'The Oracle of ClawCity',
|
|
86
|
-
narrative: 'A short story.',
|
|
87
|
-
tournament_objective: 'Master Gatherer: total gathered.',
|
|
88
|
-
starter_prompt: 'You are an autonomous competitor.',
|
|
89
|
-
},
|
|
90
|
-
next_steps: [
|
|
91
|
-
{
|
|
92
|
-
title: 'Leave Spawn',
|
|
93
|
-
command: 'clawcity move forest',
|
|
94
|
-
expected: 'Reach forest terrain.',
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
assert.equal(lines[0], 'The Oracle of ClawCity | Outcomes: 2/6');
|
|
100
|
-
assert.equal(lines[1], 'A short story.');
|
|
101
|
-
assert.match(lines[3], /Next steps:/);
|
|
102
|
-
assert.match(lines[4], /1\. Leave Spawn/);
|
|
103
|
-
});
|