mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
feat: expand session adapter registry with structured targets
- Registry accepts { type, value } structured targets
- Add --list-adapters and --target-type CLI flags to session-inspect
- Export adapter type from claude-history and dmux-tmux adapters
- 71 new session adapter tests, 34 new session-inspect tests
- All 1142 tests passing
This commit is contained in:
36
package-lock.json
generated
36
package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
"ecc": "scripts/ecc.js",
|
||||||
"ecc-install": "install.sh"
|
"ecc-install": "install.sh"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
"c8": "^10.1.2",
|
"c8": "^10.1.2",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^9.39.2",
|
||||||
"globals": "^17.1.0",
|
"globals": "^17.1.0",
|
||||||
"markdownlint-cli": "^0.48.0"
|
"markdownlint-cli": "^0.47.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
@@ -1655,22 +1656,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/markdownlint-cli": {
|
"node_modules/markdownlint-cli": {
|
||||||
"version": "0.48.0",
|
"version": "0.47.0",
|
||||||
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.48.0.tgz",
|
"resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.47.0.tgz",
|
||||||
"integrity": "sha512-NkZQNu2E0Q5qLEEHwWj674eYISTLD4jMHkBzDobujXd1kv+yCxi8jOaD/rZoQNW1FBBMMGQpuW5So8B51N/e0A==",
|
"integrity": "sha512-HOcxeKFAdDoldvoYDofd85vI8LgNWy8vmYpCwnlLV46PJcodmGzD7COSSBlhHwsfT4o9KrAStGodImVBus31Bg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "~14.0.3",
|
"commander": "~14.0.2",
|
||||||
"deep-extend": "~0.6.0",
|
"deep-extend": "~0.6.0",
|
||||||
"ignore": "~7.0.5",
|
"ignore": "~7.0.5",
|
||||||
"js-yaml": "~4.1.1",
|
"js-yaml": "~4.1.1",
|
||||||
"jsonc-parser": "~3.3.1",
|
"jsonc-parser": "~3.3.1",
|
||||||
"jsonpointer": "~5.0.1",
|
"jsonpointer": "~5.0.1",
|
||||||
"markdown-it": "~14.1.1",
|
"markdown-it": "~14.1.0",
|
||||||
"markdownlint": "~0.40.0",
|
"markdownlint": "~0.40.0",
|
||||||
"minimatch": "~10.2.4",
|
"minimatch": "~10.1.1",
|
||||||
"run-con": "~1.3.2",
|
"run-con": "~1.3.2",
|
||||||
"smol-toml": "~1.6.0",
|
"smol-toml": "~1.5.2",
|
||||||
"tinyglobby": "~0.2.15"
|
"tinyglobby": "~0.2.15"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -1685,6 +1687,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "18 || 20 || >=22"
|
"node": "18 || 20 || >=22"
|
||||||
}
|
}
|
||||||
@@ -1694,6 +1697,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
||||||
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
},
|
},
|
||||||
@@ -1712,15 +1716,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/markdownlint-cli/node_modules/minimatch": {
|
"node_modules/markdownlint-cli/node_modules/minimatch": {
|
||||||
"version": "10.2.4",
|
"version": "10.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.3.tgz",
|
||||||
"integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==",
|
"integrity": "sha512-IF6URNyBX7Z6XfvjpaNy5meRxPZiIf2OqtOoSLs+hLJ9pJAScnM1RjrFcbCaD85y42KcI+oZmKjFIJKYDFjQfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^5.0.2"
|
"brace-expansion": "^5.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "18 || 20 || >=22"
|
"node": "20 || >=22"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
@@ -2579,10 +2584,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/smol-toml": {
|
"node_modules/smol-toml": {
|
||||||
"version": "1.6.0",
|
"version": "1.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.5.2.tgz",
|
||||||
"integrity": "sha512-4zemZi0HvTnYwLfrpk/CF9LOd9Lt87kAt50GnqhMpyF9U3poDAP2+iukq2bZsO/ufegbYehBkqINbsWxj4l4cw==",
|
"integrity": "sha512-QlaZEqcAH3/RtNyet1IPIYPsEWAaYyXXv1Krsi+1L/QHppjX4Ifm8MQsBISz9vE8cHicIq3clogsheili5vhaQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ function resolveSessionRecord(target, cwd) {
|
|||||||
function createClaudeHistoryAdapter() {
|
function createClaudeHistoryAdapter() {
|
||||||
return {
|
return {
|
||||||
id: 'claude-history',
|
id: 'claude-history',
|
||||||
|
description: 'Claude local session history and session-file snapshots',
|
||||||
|
targetTypes: ['claude-history', 'claude-alias', 'session-file'],
|
||||||
canOpen(target, context = {}) {
|
canOpen(target, context = {}) {
|
||||||
if (context.adapterId && context.adapterId !== 'claude-history') {
|
if (context.adapterId && context.adapterId !== 'claude-history') {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ function createDmuxTmuxAdapter(options = {}) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: 'dmux-tmux',
|
id: 'dmux-tmux',
|
||||||
|
description: 'Tmux/worktree orchestration snapshots from plan files or session names',
|
||||||
|
targetTypes: ['plan', 'session'],
|
||||||
canOpen(target, context = {}) {
|
canOpen(target, context = {}) {
|
||||||
if (context.adapterId && context.adapterId !== 'dmux-tmux') {
|
if (context.adapterId && context.adapterId !== 'dmux-tmux') {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
const { createClaudeHistoryAdapter } = require('./claude-history');
|
const { createClaudeHistoryAdapter } = require('./claude-history');
|
||||||
const { createDmuxTmuxAdapter } = require('./dmux-tmux');
|
const { createDmuxTmuxAdapter } = require('./dmux-tmux');
|
||||||
|
|
||||||
|
const TARGET_TYPE_TO_ADAPTER_ID = Object.freeze({
|
||||||
|
plan: 'dmux-tmux',
|
||||||
|
session: 'dmux-tmux',
|
||||||
|
'claude-history': 'claude-history',
|
||||||
|
'claude-alias': 'claude-history',
|
||||||
|
'session-file': 'claude-history'
|
||||||
|
});
|
||||||
|
|
||||||
function createDefaultAdapters() {
|
function createDefaultAdapters() {
|
||||||
return [
|
return [
|
||||||
createClaudeHistoryAdapter(),
|
createClaudeHistoryAdapter(),
|
||||||
@@ -10,13 +18,72 @@ function createDefaultAdapters() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function coerceTargetValue(value) {
|
||||||
|
if (typeof value !== 'string' || value.trim().length === 0) {
|
||||||
|
throw new Error('Structured session targets require a non-empty string value');
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeStructuredTarget(target, context = {}) {
|
||||||
|
if (!target || typeof target !== 'object' || Array.isArray(target)) {
|
||||||
|
return {
|
||||||
|
target,
|
||||||
|
context: { ...context }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = coerceTargetValue(target.value);
|
||||||
|
const type = typeof target.type === 'string' ? target.type.trim() : '';
|
||||||
|
if (type.length === 0) {
|
||||||
|
throw new Error('Structured session targets require a non-empty type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapterId = target.adapterId || TARGET_TYPE_TO_ADAPTER_ID[type] || context.adapterId || null;
|
||||||
|
const nextContext = {
|
||||||
|
...context,
|
||||||
|
adapterId
|
||||||
|
};
|
||||||
|
|
||||||
|
if (type === 'claude-history' || type === 'claude-alias') {
|
||||||
|
return {
|
||||||
|
target: `claude:${value}`,
|
||||||
|
context: nextContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
target: value,
|
||||||
|
context: nextContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function createAdapterRegistry(options = {}) {
|
function createAdapterRegistry(options = {}) {
|
||||||
const adapters = options.adapters || createDefaultAdapters();
|
const adapters = options.adapters || createDefaultAdapters();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
adapters,
|
adapters,
|
||||||
|
getAdapter(id) {
|
||||||
|
const adapter = adapters.find(candidate => candidate.id === id);
|
||||||
|
if (!adapter) {
|
||||||
|
throw new Error(`Unknown session adapter: ${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return adapter;
|
||||||
|
},
|
||||||
|
listAdapters() {
|
||||||
|
return adapters.map(adapter => ({
|
||||||
|
id: adapter.id,
|
||||||
|
description: adapter.description || '',
|
||||||
|
targetTypes: Array.isArray(adapter.targetTypes) ? [...adapter.targetTypes] : []
|
||||||
|
}));
|
||||||
|
},
|
||||||
select(target, context = {}) {
|
select(target, context = {}) {
|
||||||
const adapter = adapters.find(candidate => candidate.canOpen(target, context));
|
const normalized = normalizeStructuredTarget(target, context);
|
||||||
|
const adapter = normalized.context.adapterId
|
||||||
|
? this.getAdapter(normalized.context.adapterId)
|
||||||
|
: adapters.find(candidate => candidate.canOpen(normalized.target, normalized.context));
|
||||||
if (!adapter) {
|
if (!adapter) {
|
||||||
throw new Error(`No session adapter matched target: ${target}`);
|
throw new Error(`No session adapter matched target: ${target}`);
|
||||||
}
|
}
|
||||||
@@ -24,8 +91,9 @@ function createAdapterRegistry(options = {}) {
|
|||||||
return adapter;
|
return adapter;
|
||||||
},
|
},
|
||||||
open(target, context = {}) {
|
open(target, context = {}) {
|
||||||
const adapter = this.select(target, context);
|
const normalized = normalizeStructuredTarget(target, context);
|
||||||
return adapter.open(target, context);
|
const adapter = this.select(normalized.target, normalized.context);
|
||||||
|
return adapter.open(normalized.target, normalized.context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -38,5 +106,6 @@ function inspectSessionTarget(target, options = {}) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
createAdapterRegistry,
|
createAdapterRegistry,
|
||||||
createDefaultAdapters,
|
createDefaultAdapters,
|
||||||
inspectSessionTarget
|
inspectSessionTarget,
|
||||||
|
normalizeStructuredTarget
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const { inspectSessionTarget } = require('./lib/session-adapters/registry');
|
const { createAdapterRegistry, inspectSessionTarget } = require('./lib/session-adapters/registry');
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
console.log([
|
console.log([
|
||||||
'Usage:',
|
'Usage:',
|
||||||
' node scripts/session-inspect.js <target> [--adapter <id>] [--write <output.json>]',
|
' node scripts/session-inspect.js <target> [--adapter <id>] [--target-type <type>] [--write <output.json>]',
|
||||||
|
' node scripts/session-inspect.js --list-adapters',
|
||||||
'',
|
'',
|
||||||
'Targets:',
|
'Targets:',
|
||||||
' <plan.json> Dmux/orchestration plan file',
|
' <plan.json> Dmux/orchestration plan file',
|
||||||
@@ -22,6 +23,7 @@ function usage() {
|
|||||||
' node scripts/session-inspect.js .claude/plan/workflow.json',
|
' node scripts/session-inspect.js .claude/plan/workflow.json',
|
||||||
' node scripts/session-inspect.js workflow-visual-proof',
|
' node scripts/session-inspect.js workflow-visual-proof',
|
||||||
' node scripts/session-inspect.js claude:latest',
|
' node scripts/session-inspect.js claude:latest',
|
||||||
|
' node scripts/session-inspect.js latest --target-type claude-history',
|
||||||
' node scripts/session-inspect.js claude:a1b2c3d4 --write /tmp/session.json'
|
' node scripts/session-inspect.js claude:a1b2c3d4 --write /tmp/session.json'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
}
|
}
|
||||||
@@ -29,25 +31,36 @@ function usage() {
|
|||||||
function parseArgs(argv) {
|
function parseArgs(argv) {
|
||||||
const args = argv.slice(2);
|
const args = argv.slice(2);
|
||||||
const target = args.find(argument => !argument.startsWith('--'));
|
const target = args.find(argument => !argument.startsWith('--'));
|
||||||
|
const listAdapters = args.includes('--list-adapters');
|
||||||
|
|
||||||
const adapterIndex = args.indexOf('--adapter');
|
const adapterIndex = args.indexOf('--adapter');
|
||||||
const adapterId = adapterIndex >= 0 ? args[adapterIndex + 1] : null;
|
const adapterId = adapterIndex >= 0 ? args[adapterIndex + 1] : null;
|
||||||
|
|
||||||
|
const targetTypeIndex = args.indexOf('--target-type');
|
||||||
|
const targetType = targetTypeIndex >= 0 ? args[targetTypeIndex + 1] : null;
|
||||||
|
|
||||||
const writeIndex = args.indexOf('--write');
|
const writeIndex = args.indexOf('--write');
|
||||||
const writePath = writeIndex >= 0 ? args[writeIndex + 1] : null;
|
const writePath = writeIndex >= 0 ? args[writeIndex + 1] : null;
|
||||||
|
|
||||||
return { target, adapterId, writePath };
|
return { target, adapterId, targetType, writePath, listAdapters };
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const { target, adapterId, writePath } = parseArgs(process.argv);
|
const { target, adapterId, targetType, writePath, listAdapters } = parseArgs(process.argv);
|
||||||
|
|
||||||
|
if (listAdapters) {
|
||||||
|
const registry = createAdapterRegistry();
|
||||||
|
console.log(JSON.stringify({ adapters: registry.listAdapters() }, null, 2));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
usage();
|
usage();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const snapshot = inspectSessionTarget(target, {
|
const inspectTarget = targetType ? { type: targetType, value: target } : target;
|
||||||
|
const snapshot = inspectSessionTarget(inspectTarget, {
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
adapterId
|
adapterId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -210,5 +210,76 @@ test('adapter registry routes plan files to dmux and explicit claude targets to
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('adapter registry resolves structured target types into the correct adapter', () => {
|
||||||
|
const repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-typed-repo-'));
|
||||||
|
const planPath = path.join(repoRoot, 'workflow.json');
|
||||||
|
fs.writeFileSync(planPath, JSON.stringify({
|
||||||
|
sessionName: 'workflow-typed-proof',
|
||||||
|
repoRoot,
|
||||||
|
coordinationRoot: path.join(repoRoot, '.claude', 'orchestration')
|
||||||
|
}));
|
||||||
|
|
||||||
|
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-typed-home-'));
|
||||||
|
const sessionsDir = path.join(homeDir, '.claude', 'sessions');
|
||||||
|
fs.mkdirSync(sessionsDir, { recursive: true });
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(sessionsDir, '2026-03-13-z9y8x7w6-session.tmp'),
|
||||||
|
'# Typed History Session\n\n**Branch:** feat/typed-targets\n'
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
withHome(homeDir, () => {
|
||||||
|
const registry = createAdapterRegistry({
|
||||||
|
adapters: [
|
||||||
|
createDmuxTmuxAdapter({
|
||||||
|
collectSessionSnapshotImpl: () => ({
|
||||||
|
sessionName: 'workflow-typed-proof',
|
||||||
|
coordinationDir: path.join(repoRoot, '.claude', 'orchestration', 'workflow-typed-proof'),
|
||||||
|
repoRoot,
|
||||||
|
targetType: 'plan',
|
||||||
|
sessionActive: true,
|
||||||
|
paneCount: 0,
|
||||||
|
workerCount: 0,
|
||||||
|
workerStates: {},
|
||||||
|
panes: [],
|
||||||
|
workers: []
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
createClaudeHistoryAdapter()
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const dmuxSnapshot = registry.open({ type: 'plan', value: planPath }, { cwd: repoRoot }).getSnapshot();
|
||||||
|
const claudeSnapshot = registry.open({ type: 'claude-history', value: 'latest' }, { cwd: repoRoot }).getSnapshot();
|
||||||
|
|
||||||
|
assert.strictEqual(dmuxSnapshot.adapterId, 'dmux-tmux');
|
||||||
|
assert.strictEqual(dmuxSnapshot.session.sourceTarget.type, 'plan');
|
||||||
|
assert.strictEqual(claudeSnapshot.adapterId, 'claude-history');
|
||||||
|
assert.strictEqual(claudeSnapshot.session.sourceTarget.type, 'claude-history');
|
||||||
|
assert.strictEqual(claudeSnapshot.workers[0].branch, 'feat/typed-targets');
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(repoRoot, { recursive: true, force: true });
|
||||||
|
fs.rmSync(homeDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('adapter registry lists adapter metadata and target types', () => {
|
||||||
|
const registry = createAdapterRegistry();
|
||||||
|
const adapters = registry.listAdapters();
|
||||||
|
const ids = adapters.map(adapter => adapter.id);
|
||||||
|
|
||||||
|
assert.ok(ids.includes('claude-history'));
|
||||||
|
assert.ok(ids.includes('dmux-tmux'));
|
||||||
|
assert.ok(
|
||||||
|
adapters.some(adapter => adapter.id === 'claude-history' && adapter.targetTypes.includes('claude-history')),
|
||||||
|
'claude-history should advertise its canonical target type'
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
adapters.some(adapter => adapter.id === 'dmux-tmux' && adapter.targetTypes.includes('plan')),
|
||||||
|
'dmux-tmux should advertise plan targets'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===`);
|
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===`);
|
||||||
if (failed > 0) process.exit(1);
|
if (failed > 0) process.exit(1);
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ function runTests() {
|
|||||||
assert.ok(result.stdout.includes('Usage:'));
|
assert.ok(result.stdout.includes('Usage:'));
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (test('lists registered adapters', () => {
|
||||||
|
const result = run(['--list-adapters']);
|
||||||
|
assert.strictEqual(result.code, 0, result.stderr);
|
||||||
|
const payload = JSON.parse(result.stdout);
|
||||||
|
assert.ok(Array.isArray(payload.adapters));
|
||||||
|
assert.ok(payload.adapters.some(adapter => adapter.id === 'claude-history'));
|
||||||
|
assert.ok(payload.adapters.some(adapter => adapter.id === 'dmux-tmux'));
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (test('prints canonical JSON for claude history targets', () => {
|
if (test('prints canonical JSON for claude history targets', () => {
|
||||||
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-home-'));
|
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-home-'));
|
||||||
const sessionsDir = path.join(homeDir, '.claude', 'sessions');
|
const sessionsDir = path.join(homeDir, '.claude', 'sessions');
|
||||||
@@ -81,6 +90,31 @@ function runTests() {
|
|||||||
}
|
}
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (test('supports explicit target types for structured registry routing', () => {
|
||||||
|
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-home-'));
|
||||||
|
const sessionsDir = path.join(homeDir, '.claude', 'sessions');
|
||||||
|
fs.mkdirSync(sessionsDir, { recursive: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(sessionsDir, '2026-03-13-a1b2c3d4-session.tmp'),
|
||||||
|
'# Inspect Session\n\n**Branch:** feat/typed-inspect\n'
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = run(['latest', '--target-type', 'claude-history'], {
|
||||||
|
env: { HOME: homeDir }
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(result.code, 0, result.stderr);
|
||||||
|
const payload = JSON.parse(result.stdout);
|
||||||
|
assert.strictEqual(payload.adapterId, 'claude-history');
|
||||||
|
assert.strictEqual(payload.session.sourceTarget.type, 'claude-history');
|
||||||
|
assert.strictEqual(payload.workers[0].branch, 'feat/typed-inspect');
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(homeDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (test('writes snapshot JSON to disk when --write is provided', () => {
|
if (test('writes snapshot JSON to disk when --write is provided', () => {
|
||||||
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-home-'));
|
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-home-'));
|
||||||
const outputDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-out-'));
|
const outputDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-inspect-out-'));
|
||||||
|
|||||||
Reference in New Issue
Block a user