harness-craft 0.1.0 → 0.1.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/README.md +9 -3
- package/dist/claude/definitions.js +10 -3
- package/dist/claude/index.js +4 -3
- package/dist/cli.js +30 -14
- package/dist/codex/agents.js +107 -0
- package/dist/codex/config.js +8 -4
- package/dist/codex/hooks.js +62 -0
- package/dist/codex/index.js +49 -34
- package/dist/codex/plugins.js +87 -0
- package/dist/codex/skills.js +116 -0
- package/dist/collect.js +18 -4
- package/dist/definitions.js +24 -5
- package/dist/items.js +1 -1
- package/dist/share-template.html +5 -5
- package/dist/shareCommand.js +1 -1
- package/dist/shareFormat.js +17 -2
- package/dist/shareProfile.js +10 -2
- package/dist/summary.js +3 -2
- package/dist/usage/claude.js +1 -0
- package/dist/usage/codex.js +142 -17
- package/package.json +2 -2
package/dist/shareCommand.js
CHANGED
|
@@ -20,7 +20,7 @@ export function formatShareSummary(result, descriptions) {
|
|
|
20
20
|
const x = result.profile.codex;
|
|
21
21
|
const mcp = (c?.mcpServers.length ?? 0) + (x?.mcpServers.length ?? 0);
|
|
22
22
|
const skills = (c?.skills.length ?? 0) + (x?.skills.length ?? 0);
|
|
23
|
-
const agents = c?.agents.length ?? 0;
|
|
23
|
+
const agents = (c?.agents.length ?? 0) + (x?.agents?.length ?? 0);
|
|
24
24
|
const hooks = (c?.hooks.length ?? 0) + (x?.hooks.length ?? 0);
|
|
25
25
|
const lines = [
|
|
26
26
|
`저장: ${result.out} (${formatSize(result.bytes)})`,
|
package/dist/shareFormat.js
CHANGED
|
@@ -6,5 +6,20 @@ export const SHARE_DATA_ID = 'harness-share-data';
|
|
|
6
6
|
export const SHARE_PLACEHOLDER = '__HARNESS_SHARE_DATA__';
|
|
7
7
|
export const SHARE_TEMPLATE_FILE = 'share-template.html';
|
|
8
8
|
export const DEFAULT_SHARE_HANDLE = 'player';
|
|
9
|
-
/**
|
|
10
|
-
export const
|
|
9
|
+
/** Display name only (nothing is verified or sent), counted in code points so Korean and emoji count as one each. */
|
|
10
|
+
export const SHARE_NAME_MAX_LENGTH = 32;
|
|
11
|
+
// C0 controls and DEL. Other text (Korean, emoji, `<`) is fine: the CLI escapes the JSON before it goes into HTML.
|
|
12
|
+
const CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
|
|
13
|
+
/** Trims and drops leading `@`. Empty → DEFAULT_SHARE_HANDLE. Control characters or more than 32 characters → error. */
|
|
14
|
+
export function validateShareName(raw) {
|
|
15
|
+
const name = raw.trim().replace(/^@+/, '').trim();
|
|
16
|
+
if (name === '')
|
|
17
|
+
return { ok: true, name: DEFAULT_SHARE_HANDLE };
|
|
18
|
+
if (CONTROL_CHARS.test(name))
|
|
19
|
+
return { ok: false, error: '제어 문자(줄바꿈·탭 등)는 쓸 수 없습니다' };
|
|
20
|
+
const length = [...name].length;
|
|
21
|
+
if (length > SHARE_NAME_MAX_LENGTH) {
|
|
22
|
+
return { ok: false, error: `${SHARE_NAME_MAX_LENGTH}자까지 쓸 수 있습니다 (지금 ${length}자)` };
|
|
23
|
+
}
|
|
24
|
+
return { ok: true, name };
|
|
25
|
+
}
|
package/dist/shareProfile.js
CHANGED
|
@@ -55,13 +55,18 @@ function shareCodex(c, filter) {
|
|
|
55
55
|
skills: keep(c.skills, filter, (s) => fromHiddenPlugin(s.source, filter)).map((s) => described(s, filter)),
|
|
56
56
|
hooks: shareHooks(c.hooks, filter),
|
|
57
57
|
commands: keep(c.commands, filter).map((cmd) => described(cmd, filter)),
|
|
58
|
+
// Older profiles have no Codex agents or plugins; keep the keys absent rather than inventing empty lists.
|
|
59
|
+
...(c.agents ? { agents: shareAgents(c.agents, filter) } : {}),
|
|
60
|
+
...(c.plugins ? { plugins: keep(c.plugins, filter).map((p) => ({ ...p })) } : {}),
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
function itemCount(profile) {
|
|
61
64
|
const c = profile.claudeCode;
|
|
62
65
|
const x = profile.codex;
|
|
63
66
|
const claude = c ? c.mcpServers.length + c.skills.length + c.agents.length + c.hooks.length + c.plugins.length + c.commands.length : 0;
|
|
64
|
-
const codex = x
|
|
67
|
+
const codex = x
|
|
68
|
+
? x.mcpServers.length + x.skills.length + (x.agents?.length ?? 0) + (x.plugins?.length ?? 0) + x.hooks.length + x.commands.length
|
|
69
|
+
: 0;
|
|
65
70
|
return claude + codex;
|
|
66
71
|
}
|
|
67
72
|
/**
|
|
@@ -71,7 +76,8 @@ function itemCount(profile) {
|
|
|
71
76
|
*/
|
|
72
77
|
export function prepareShareProfile(profile, options) {
|
|
73
78
|
const isHidden = globMatcher(options.hide);
|
|
74
|
-
|
|
79
|
+
// A hidden plugin name takes that plugin's skills and agents with it, in either tool.
|
|
80
|
+
const plugins = [...(profile.claudeCode?.plugins ?? []), ...(profile.codex?.plugins ?? [])];
|
|
75
81
|
const filter = {
|
|
76
82
|
isHidden,
|
|
77
83
|
hiddenPlugins: new Set(plugins.filter((p) => isHidden(p.name)).map((p) => p.name)),
|
|
@@ -82,6 +88,8 @@ export function prepareShareProfile(profile, options) {
|
|
|
82
88
|
collector: { ...profile.collector },
|
|
83
89
|
claudeCode: profile.claudeCode ? shareClaude(profile.claudeCode, filter) : null,
|
|
84
90
|
codex: profile.codex ? shareCodex(profile.codex, filter) : null,
|
|
91
|
+
// Counts and first/last day only, so it goes through unchanged.
|
|
92
|
+
...(profile.activity !== undefined ? { activity: profile.activity && { ...profile.activity } } : {}),
|
|
85
93
|
redactions: { ...profile.redactions },
|
|
86
94
|
warnings: [],
|
|
87
95
|
};
|
package/dist/summary.js
CHANGED
|
@@ -18,12 +18,12 @@ function claudeLines(c) {
|
|
|
18
18
|
function codexLines(c) {
|
|
19
19
|
const lines = [
|
|
20
20
|
`Codex — 모델 ${c.model ?? '-'}${c.reasoningEffort ? ` (${c.reasoningEffort})` : ''}`,
|
|
21
|
-
` MCP ${c.mcpServers.length} · 스킬 ${c.skills.length} · 훅 ${c.hooks.length} · 프롬프트 ${c.commands.length} · 규칙 파일 ${c.rulesFiles}`,
|
|
21
|
+
` MCP ${c.mcpServers.length} · 스킬 ${c.skills.length} · 에이전트 ${c.agents?.length ?? 0} · 훅 ${c.hooks.length} · 플러그인 ${c.plugins?.length ?? 0} · 프롬프트 ${c.commands.length} · 규칙 파일 ${c.rulesFiles}`,
|
|
22
22
|
` AGENTS.md ${c.instructions.present ? `${c.instructions.lines}줄` : '없음'}`,
|
|
23
23
|
];
|
|
24
24
|
const u = c.usage;
|
|
25
25
|
if (u) {
|
|
26
|
-
lines.push(` 사용 기록: 세션 ${u.sessions} · MCP 호출 ${u.mcpCalls} · 서브에이전트 ${u.subagentActivities} · 명령 실행 ${u.commandExecutions} · 활동일 ${u.activeDays}${range(u.firstActivity, u.lastActivity)}`);
|
|
26
|
+
lines.push(` 사용 기록: 세션 ${u.sessions}${u.execSessions ? ` (+ exec ${u.execSessions})` : ''} · MCP 호출 ${u.mcpCalls} · 서브에이전트 실행 ${u.subagentActivities} · 명령 실행 ${u.commandExecutions} · 활동일 ${u.activeDays}${range(u.firstActivity, u.lastActivity)}`);
|
|
27
27
|
}
|
|
28
28
|
return lines;
|
|
29
29
|
}
|
|
@@ -34,6 +34,7 @@ export function formatSummary(profile, savedTo) {
|
|
|
34
34
|
`harness-craft ${profile.collector.version} 스캔 결과`,
|
|
35
35
|
...(profile.claudeCode ? claudeLines(profile.claudeCode) : ['Claude Code — 찾지 못함']),
|
|
36
36
|
...(profile.codex ? codexLines(profile.codex) : ['Codex — 찾지 못함']),
|
|
37
|
+
...(profile.activity ? [`활동일 합계 ${profile.activity.activeDays}일 (두 도구 중 하루라도 쓴 날)${range(profile.activity.firstActivity, profile.activity.lastActivity)}`] : []),
|
|
37
38
|
`가림 처리: 경로 ${r.paths} · 이메일 ${r.emails} · 비밀값 ${r.secrets} · URL ${r.urls}`,
|
|
38
39
|
];
|
|
39
40
|
if (profile.warnings.length > 0) {
|
package/dist/usage/claude.js
CHANGED
package/dist/usage/codex.js
CHANGED
|
@@ -1,21 +1,71 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
1
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
2
2
|
import { describeError } from '../diagnostics.js';
|
|
3
3
|
import { isRecord } from '../fsutil.js';
|
|
4
4
|
import { dateRange, forEachLine, incr, listFilesRecursive, runPool } from './lines.js';
|
|
5
5
|
const ITEM_COMPLETED_MARK = Buffer.from('"item_completed"');
|
|
6
|
+
const SESSION_META_MARK = Buffer.from('"session_meta"');
|
|
7
|
+
const TURN_CONTEXT_MARK = Buffer.from('"turn_context"');
|
|
6
8
|
const PATH_DATE_PATTERN = /(?:^|\/)(\d{4})\/(\d{2})\/(\d{2})\//;
|
|
9
|
+
const SKILL_FILE_SUFFIX = '/SKILL.md';
|
|
7
10
|
const FILE_CONCURRENCY = 8;
|
|
8
11
|
const PROGRESS_EVERY_FILES = 100;
|
|
9
|
-
|
|
12
|
+
/** The built-in agent a spawned subagent runs as when its `agent_role` is null. */
|
|
13
|
+
export const CODEX_DEFAULT_ROLE = 'default';
|
|
14
|
+
/** session_meta of a non-interactive `codex exec` run. */
|
|
15
|
+
const EXEC_SOURCE = 'exec';
|
|
16
|
+
const EXEC_ORIGINATOR = 'codex_exec';
|
|
17
|
+
/** turn_context without an effort field. */
|
|
18
|
+
export const NO_EFFORT = '';
|
|
19
|
+
function addSkillRef(acc, path, turn, at) {
|
|
20
|
+
const ref = acc.skillRefs.get(path) ?? { turns: new Set(), last: null };
|
|
21
|
+
ref.turns.add(turn);
|
|
22
|
+
if (at !== null && (ref.last === null || at > ref.last))
|
|
23
|
+
ref.last = at;
|
|
24
|
+
acc.skillRefs.set(path, ref);
|
|
25
|
+
}
|
|
26
|
+
/** SKILL.md paths named by an item: explicit `$skill` mentions and implicit reads by a command. */
|
|
27
|
+
function skillPaths(item) {
|
|
28
|
+
if (item.type === 'UserMessage' && Array.isArray(item.content)) {
|
|
29
|
+
return item.content
|
|
30
|
+
.filter((c) => isRecord(c) && c.type === 'skill' && typeof c.path === 'string')
|
|
31
|
+
.map((c) => c.path)
|
|
32
|
+
.filter((p) => isAbsolute(p));
|
|
33
|
+
}
|
|
34
|
+
if (item.type === 'CommandExecution' && Array.isArray(item.parsed_cmd)) {
|
|
35
|
+
const cwd = typeof item.cwd === 'string' && isAbsolute(item.cwd) ? item.cwd : null;
|
|
36
|
+
return item.parsed_cmd
|
|
37
|
+
.filter((c) => isRecord(c) && c.type === 'read' && typeof c.path === 'string')
|
|
38
|
+
.map((c) => c.path)
|
|
39
|
+
.filter((p) => p.endsWith(SKILL_FILE_SUFFIX) && (isAbsolute(p) || cwd !== null))
|
|
40
|
+
.map((p) => (isAbsolute(p) ? p : resolve(cwd, p)));
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
function countSkillRefs(acc, file, record, item) {
|
|
45
|
+
const paths = skillPaths(item);
|
|
46
|
+
if (paths.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
const payload = record.payload;
|
|
49
|
+
// One use per skill per turn: reading SKILL.md twice, or $skill plus a read, in the same turn is one use.
|
|
50
|
+
const turn = typeof payload.turn_id === 'string' ? `turn:${payload.turn_id}` : `file:${file.rel}`;
|
|
51
|
+
const at = typeof record.timestamp === 'string' ? record.timestamp : file.day && `${file.day}T00:00:00.000Z`;
|
|
52
|
+
for (const path of paths)
|
|
53
|
+
addSkillRef(acc, path, turn, at);
|
|
54
|
+
}
|
|
55
|
+
function countItem(acc, file, record) {
|
|
10
56
|
if (!isRecord(record) || record.type !== 'event_msg' || !isRecord(record.payload))
|
|
11
57
|
return;
|
|
12
58
|
const { payload } = record;
|
|
13
59
|
if (payload.type !== 'item_completed' || !isRecord(payload.item))
|
|
14
60
|
return;
|
|
15
61
|
const { item } = payload;
|
|
62
|
+
countSkillRefs(acc, file, record, item);
|
|
16
63
|
const type = item.type;
|
|
17
64
|
if (type !== 'McpToolCall' && type !== 'SubAgentActivity' && type !== 'CommandExecution')
|
|
18
65
|
return;
|
|
66
|
+
// A subagent reports started / interacted / completed; only the spawn counts.
|
|
67
|
+
if (type === 'SubAgentActivity' && item.kind !== 'started')
|
|
68
|
+
return;
|
|
19
69
|
if (typeof item.id === 'string') {
|
|
20
70
|
const key = `${type}:${item.id}`;
|
|
21
71
|
if (acc.seen.has(key))
|
|
@@ -34,31 +84,99 @@ function countItem(acc, record) {
|
|
|
34
84
|
acc.commands += 1;
|
|
35
85
|
}
|
|
36
86
|
}
|
|
37
|
-
|
|
38
|
-
|
|
87
|
+
/** `payload.source.subagent.thread_spawn.agent_role`: a string role, null for the default agent, undefined if not spawned. */
|
|
88
|
+
function spawnedRole(subagent) {
|
|
89
|
+
if (!isRecord(subagent) || !isRecord(subagent.thread_spawn))
|
|
90
|
+
return undefined;
|
|
91
|
+
const role = subagent.thread_spawn.agent_role;
|
|
92
|
+
return typeof role === 'string' && role.trim().length > 0 ? role.trim() : null;
|
|
93
|
+
}
|
|
94
|
+
function readSessionMeta(acc, file, record) {
|
|
95
|
+
if (file.metaSeen || !isRecord(record) || record.type !== 'session_meta' || !isRecord(record.payload))
|
|
96
|
+
return;
|
|
97
|
+
file.metaSeen = true;
|
|
98
|
+
const { payload } = record;
|
|
99
|
+
if (payload.source === EXEC_SOURCE || payload.originator === EXEC_ORIGINATOR) {
|
|
100
|
+
file.kind = 'exec';
|
|
101
|
+
acc.execFiles += 1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!isRecord(payload.source) || payload.source.subagent === undefined)
|
|
105
|
+
return;
|
|
106
|
+
file.kind = 'subagent';
|
|
107
|
+
acc.subagentFiles += 1;
|
|
108
|
+
const role = spawnedRole(payload.source.subagent);
|
|
109
|
+
if (role === undefined)
|
|
110
|
+
return;
|
|
111
|
+
if (typeof payload.id === 'string') {
|
|
112
|
+
if (acc.metaIds.has(payload.id))
|
|
113
|
+
return;
|
|
114
|
+
acc.metaIds.add(payload.id);
|
|
115
|
+
}
|
|
116
|
+
incr(acc.roleCalls, role ?? CODEX_DEFAULT_ROLE);
|
|
117
|
+
}
|
|
118
|
+
function addTurn(bucket, model, effort, turnId) {
|
|
119
|
+
if (typeof turnId === 'string') {
|
|
120
|
+
if (bucket.ids.has(turnId))
|
|
121
|
+
return;
|
|
122
|
+
bucket.ids.add(turnId);
|
|
123
|
+
}
|
|
124
|
+
const efforts = bucket.turns.get(model) ?? new Map();
|
|
125
|
+
incr(efforts, effort);
|
|
126
|
+
bucket.turns.set(model, efforts);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One count per turn. Each bucket dedupes turn_id on its own: a forked subagent rollout repeats its parent's turns,
|
|
130
|
+
* and those copies must not keep the parent's turn out of the interactive bucket.
|
|
131
|
+
*/
|
|
132
|
+
function readTurnContext(acc, file, record) {
|
|
133
|
+
if (!isRecord(record) || record.type !== 'turn_context' || !isRecord(record.payload))
|
|
134
|
+
return;
|
|
135
|
+
const { payload } = record;
|
|
136
|
+
if (typeof payload.model !== 'string' || payload.model.trim().length === 0)
|
|
137
|
+
return;
|
|
138
|
+
const effort = typeof payload.effort === 'string' && payload.effort.length > 0 ? payload.effort : NO_EFFORT;
|
|
139
|
+
addTurn(acc.allModels, payload.model, effort, payload.turn_id);
|
|
140
|
+
if (file.kind === 'interactive')
|
|
141
|
+
addTurn(acc.interactiveModels, payload.model, effort, payload.turn_id);
|
|
142
|
+
}
|
|
143
|
+
function scanLine(acc, file, line) {
|
|
144
|
+
const meta = !file.metaSeen && line.indexOf(SESSION_META_MARK) !== -1;
|
|
145
|
+
const turn = line.indexOf(TURN_CONTEXT_MARK) !== -1;
|
|
146
|
+
if (!meta && !turn && line.indexOf(ITEM_COMPLETED_MARK) === -1)
|
|
39
147
|
return;
|
|
40
148
|
try {
|
|
41
|
-
|
|
149
|
+
const record = JSON.parse(line.toString('utf8'));
|
|
150
|
+
if (meta)
|
|
151
|
+
readSessionMeta(acc, file, record);
|
|
152
|
+
if (turn)
|
|
153
|
+
readTurnContext(acc, file, record);
|
|
154
|
+
countItem(acc, file, record);
|
|
42
155
|
}
|
|
43
156
|
catch {
|
|
44
157
|
acc.badLines += 1;
|
|
45
158
|
}
|
|
46
159
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
160
|
+
function pathDay(rel) {
|
|
161
|
+
const m = PATH_DATE_PATTERN.exec(rel);
|
|
162
|
+
return m ? `${m[1]}-${m[2]}-${m[3]}` : null;
|
|
163
|
+
}
|
|
164
|
+
/** Aggregates `<codexHome>/sessions/YYYY/MM/DD/*.jsonl`. Activity dates come from the path. */
|
|
165
|
+
export async function scanCodexSessions(codexHome, diag, onProgress) {
|
|
166
|
+
const sessionsDir = join(codexHome, 'sessions');
|
|
50
167
|
const files = await listFilesRecursive(sessionsDir, '.jsonl');
|
|
51
|
-
const acc = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
168
|
+
const acc = {
|
|
169
|
+
seen: new Set(), metaIds: new Set(), mcpCalls: new Map(), roleCalls: new Map(), skillRefs: new Map(),
|
|
170
|
+
allModels: { turns: new Map(), ids: new Set() }, interactiveModels: { turns: new Map(), ids: new Set() },
|
|
171
|
+
mcpTotal: 0, subagent: 0, subagentFiles: 0, execFiles: 0, commands: 0, badLines: 0,
|
|
172
|
+
};
|
|
173
|
+
const days = new Set(files.map(pathDay).filter((d) => d !== null));
|
|
58
174
|
let done = 0;
|
|
59
175
|
await runPool(files, FILE_CONCURRENCY, async (rel) => {
|
|
176
|
+
// A file without session_meta counts as interactive, as for `sessions`.
|
|
177
|
+
const file = { metaSeen: false, rel, day: pathDay(rel), kind: 'interactive' };
|
|
60
178
|
try {
|
|
61
|
-
await forEachLine(join(sessionsDir, rel), (line) => scanLine(acc, line));
|
|
179
|
+
await forEachLine(join(sessionsDir, rel), (line) => scanLine(acc, file, line));
|
|
62
180
|
}
|
|
63
181
|
catch (err) {
|
|
64
182
|
diag.warn(join(sessionsDir, rel), `읽기 실패 (${describeError(err)})`);
|
|
@@ -71,12 +189,19 @@ export async function scanCodexSessions(codexDir, diag, onProgress) {
|
|
|
71
189
|
diag.warn(sessionsDir, `JSON 파싱 실패 줄 ${acc.badLines}개 건너뜀`);
|
|
72
190
|
return {
|
|
73
191
|
usage: {
|
|
74
|
-
sessions:
|
|
192
|
+
// Interactive sessions only: not subagent rollouts, not `codex exec`. A file without session_meta still counts.
|
|
193
|
+
sessions: files.length - acc.subagentFiles - acc.execFiles,
|
|
194
|
+
execSessions: acc.execFiles,
|
|
75
195
|
mcpCalls: acc.mcpTotal,
|
|
76
196
|
subagentActivities: acc.subagent,
|
|
77
197
|
commandExecutions: acc.commands,
|
|
78
198
|
...dateRange(days),
|
|
79
199
|
},
|
|
80
200
|
mcpCalls: acc.mcpCalls,
|
|
201
|
+
roleCalls: acc.roleCalls,
|
|
202
|
+
days,
|
|
203
|
+
skillRefs: acc.skillRefs,
|
|
204
|
+
modelTurns: acc.allModels.turns,
|
|
205
|
+
interactiveModelTurns: acc.interactiveModels.turns,
|
|
81
206
|
};
|
|
82
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-craft",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Turn your Claude Code and Codex harness (MCP, skills, hooks, subagents) into a pixel-RPG character sheet HTML. No network.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-dom": "^19.3.1",
|
|
46
46
|
"tsx": "^4.23.15",
|
|
47
47
|
"typescript": "^5.9.0",
|
|
48
|
-
"@harness-craft/sheet": "0.1.0",
|
|
49
48
|
"@harness-craft/schema": "0.1.0",
|
|
49
|
+
"@harness-craft/sheet": "0.1.0",
|
|
50
50
|
"@harness-craft/sheet-ui": "0.1.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|