digdig 0.1.1 → 0.1.2
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 +39 -9
- package/dist/commands/claim.d.ts +2 -0
- package/dist/commands/claim.d.ts.map +1 -1
- package/dist/commands/claim.js +3 -1
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/doc-search.d.ts.map +1 -1
- package/dist/commands/doc-search.js +14 -1
- package/dist/commands/doc-search.js.map +1 -1
- package/dist/commands/evidence.d.ts +6 -0
- package/dist/commands/evidence.d.ts.map +1 -1
- package/dist/commands/evidence.js +4 -1
- package/dist/commands/evidence.js.map +1 -1
- package/dist/commands/graph-add.d.ts +1 -0
- package/dist/commands/graph-add.d.ts.map +1 -1
- package/dist/commands/graph-add.js +4 -1
- package/dist/commands/graph-add.js.map +1 -1
- package/dist/commands/json-input.d.ts +4 -2
- package/dist/commands/json-input.d.ts.map +1 -1
- package/dist/commands/json-input.js +30 -13
- package/dist/commands/json-input.js.map +1 -1
- package/dist/commands/results-add.d.ts +1 -0
- package/dist/commands/results-add.d.ts.map +1 -1
- package/dist/commands/results-add.js +4 -1
- package/dist/commands/results-add.js.map +1 -1
- package/dist/commands/review.js +3 -3
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/source-relations.d.ts +3 -0
- package/dist/commands/source-relations.d.ts.map +1 -1
- package/dist/commands/source-relations.js +5 -2
- package/dist/commands/source-relations.js.map +1 -1
- package/dist/commands/verdict.js +2 -2
- package/dist/commands/verdict.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -4
- package/dist/config.js.map +1 -1
- package/dist/deep/extractor.d.ts.map +1 -1
- package/dist/deep/extractor.js +20 -0
- package/dist/deep/extractor.js.map +1 -1
- package/dist/deep/fuse.d.ts.map +1 -1
- package/dist/deep/fuse.js +17 -1
- package/dist/deep/fuse.js.map +1 -1
- package/dist/deep/graph.d.ts +1 -1
- package/dist/deep/graph.d.ts.map +1 -1
- package/dist/deep/graph.js +0 -3
- package/dist/deep/graph.js.map +1 -1
- package/dist/deep/local-doc/scanner.d.ts.map +1 -1
- package/dist/deep/local-doc/scanner.js +5 -1
- package/dist/deep/local-doc/scanner.js.map +1 -1
- package/dist/deep/local-doc/searcher.d.ts.map +1 -1
- package/dist/deep/local-doc/searcher.js +3 -5
- package/dist/deep/local-doc/searcher.js.map +1 -1
- package/dist/deep/session-db.d.ts.map +1 -1
- package/dist/deep/session-db.js +22 -1
- package/dist/deep/session-db.js.map +1 -1
- package/dist/deep/session-lock.d.ts +12 -2
- package/dist/deep/session-lock.d.ts.map +1 -1
- package/dist/deep/session-lock.js +9 -0
- package/dist/deep/session-lock.js.map +1 -1
- package/dist/errors.d.ts +16 -16
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -1
- package/dist/feedback-log.d.ts +20 -2
- package/dist/feedback-log.d.ts.map +1 -1
- package/dist/feedback-log.js +22 -2
- package/dist/feedback-log.js.map +1 -1
- package/dist/protocol.d.ts +20 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +94 -0
- package/dist/protocol.js.map +1 -1
- package/dist/runCli.d.ts.map +1 -1
- package/dist/runCli.js +43 -106
- package/dist/runCli.js.map +1 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +8 -9
- package/dist/service.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/query-graph.d.ts +0 -13
- package/dist/commands/query-graph.d.ts.map +0 -1
- package/dist/commands/query-graph.js +0 -208
- package/dist/commands/query-graph.js.map +0 -1
- package/dist/deep/graph-sampling.d.ts +0 -51
- package/dist/deep/graph-sampling.d.ts.map +0 -1
- package/dist/deep/graph-sampling.js +0 -410
- package/dist/deep/graph-sampling.js.map +0 -1
package/dist/runCli.js
CHANGED
|
@@ -20,7 +20,6 @@ import { OllamaService, MAX_RESULTS as OLLAMA_MAX_RESULTS } from './ollama-servi
|
|
|
20
20
|
import { DeepSeekService, MAX_RESULTS as DEEPSEEK_MAX_RESULTS } from './deepseek-service.js';
|
|
21
21
|
import { initConfig } from './init.js';
|
|
22
22
|
import { runExtract } from './commands/extract.js';
|
|
23
|
-
import { runQueryGraph } from './commands/query-graph.js';
|
|
24
23
|
import { runGraphAdd } from './commands/graph-add.js';
|
|
25
24
|
import { runResultsAdd } from './commands/results-add.js';
|
|
26
25
|
import { runDocIndex } from './commands/doc-index.js';
|
|
@@ -35,8 +34,7 @@ import { runSessionList, runSessionDelete } from './commands/session.js';
|
|
|
35
34
|
import { graphPreprocess } from './deep/graph-preprocess.js';
|
|
36
35
|
import { checkQueryRedundancy } from './deep/query-redundancy.js';
|
|
37
36
|
import { buildPendingReport, describeResult } from './deep/pending-facts.js';
|
|
38
|
-
import {
|
|
39
|
-
import { determineSearchStage, getStrategyInfo } from './deep/search-strategy.js';
|
|
37
|
+
import { getStrategyInfo } from './deep/search-strategy.js';
|
|
40
38
|
import { getSessionAnalysis } from './deep/iteration-data.js';
|
|
41
39
|
import { runCoverage } from './commands/coverage.js';
|
|
42
40
|
import { runGraphExplore } from './commands/graph-explore.js';
|
|
@@ -245,42 +243,6 @@ function formatFactsAsMarkdown(facts) {
|
|
|
245
243
|
}
|
|
246
244
|
return lines.join('\n');
|
|
247
245
|
}
|
|
248
|
-
function formatSuggestAsMarkdown(data) {
|
|
249
|
-
const lines = [];
|
|
250
|
-
lines.push('## Query Suggestion Data');
|
|
251
|
-
lines.push('');
|
|
252
|
-
lines.push(`**Current Stage:** ${data.currentStage}`);
|
|
253
|
-
lines.push('');
|
|
254
|
-
if (data.topEntities?.length) {
|
|
255
|
-
lines.push('### Top Entities');
|
|
256
|
-
lines.push('');
|
|
257
|
-
lines.push('| Entity | Obfuscated Label | Degree | Frequency | Type |');
|
|
258
|
-
lines.push('|--------|------------------|--------|-----------|------|');
|
|
259
|
-
for (const e of data.topEntities.slice(0, 15)) {
|
|
260
|
-
lines.push(`| ${e.label} | ${e.obfuscatedLabel || '-'} | ${e.degree} | ${e.frequency} | ${e.entityType || '-'} |`);
|
|
261
|
-
}
|
|
262
|
-
lines.push('');
|
|
263
|
-
}
|
|
264
|
-
if (data.unexploredDomains?.length) {
|
|
265
|
-
lines.push('### Unexplored Domains');
|
|
266
|
-
lines.push('');
|
|
267
|
-
for (const d of data.unexploredDomains) {
|
|
268
|
-
lines.push(`- ${d}`);
|
|
269
|
-
}
|
|
270
|
-
lines.push('');
|
|
271
|
-
}
|
|
272
|
-
if (data.roundHistory?.length) {
|
|
273
|
-
lines.push('### Round History');
|
|
274
|
-
lines.push('');
|
|
275
|
-
lines.push('| Round | Query | Results |');
|
|
276
|
-
lines.push('|-------|-------|---------|');
|
|
277
|
-
for (const r of data.roundHistory) {
|
|
278
|
-
lines.push(`| ${r.round} | ${r.query} | ${r.resultCount} |`);
|
|
279
|
-
}
|
|
280
|
-
lines.push('');
|
|
281
|
-
}
|
|
282
|
-
return lines.join('\n');
|
|
283
|
-
}
|
|
284
246
|
function formatStrategyAsMarkdown(data) {
|
|
285
247
|
const lines = [];
|
|
286
248
|
lines.push('## Search Strategy Info');
|
|
@@ -450,19 +412,19 @@ function originTool(engine) {
|
|
|
450
412
|
async function runSearchInner(service, options) {
|
|
451
413
|
feedbackLog('validation', 'start');
|
|
452
414
|
if (options.limit !== undefined && (!Number.isSafeInteger(options.limit) || options.limit <= 0)) {
|
|
453
|
-
feedbackLog('validation', 'error', { error: '
|
|
415
|
+
feedbackLog('validation', 'error', { error: 'INVALID_LIMIT' });
|
|
454
416
|
console.log(JSON.stringify(createErrorEnvelope('INVALID_LIMIT', 'Limit must be a positive safe integer'), null, 2));
|
|
455
417
|
return 1;
|
|
456
418
|
}
|
|
457
419
|
const queries = options.queries || (options.query ? [options.query] : []);
|
|
458
420
|
if (queries.length === 0) {
|
|
459
|
-
feedbackLog('validation', 'error', { error: '
|
|
421
|
+
feedbackLog('validation', 'error', { error: 'MISSING_QUERY' });
|
|
460
422
|
const envelope = createErrorEnvelope('MISSING_QUERY', 'No search query provided', { hint: 'Use: dg "your search query" or dg --queries "q1,q2,q3"' });
|
|
461
423
|
console.log(JSON.stringify(envelope, null, 2));
|
|
462
424
|
return 1;
|
|
463
425
|
}
|
|
464
426
|
if (options.engines && options.engines.length === 0) {
|
|
465
|
-
feedbackLog('validation', 'error', { error: '
|
|
427
|
+
feedbackLog('validation', 'error', { error: 'INVALID_ENGINES' });
|
|
466
428
|
console.log(JSON.stringify(createErrorEnvelope('INVALID_ENGINES', 'At least one engine must be specified'), null, 2));
|
|
467
429
|
return 1;
|
|
468
430
|
}
|
|
@@ -470,7 +432,7 @@ async function runSearchInner(service, options) {
|
|
|
470
432
|
if (config.allowedEngines.length > 0) {
|
|
471
433
|
const invalid = engines.filter(e => !config.allowedEngines.includes(e));
|
|
472
434
|
if (invalid.length > 0) {
|
|
473
|
-
feedbackLog('validation', 'error', { error: '
|
|
435
|
+
feedbackLog('validation', 'error', { error: 'INVALID_ENGINES' });
|
|
474
436
|
const envelope = createErrorEnvelope('INVALID_ENGINES', `Engines not allowed: ${invalid.join(', ')}`, { hint: `Allowed engines: ${config.allowedEngines.join(', ')}` });
|
|
475
437
|
console.log(JSON.stringify(envelope, null, 2));
|
|
476
438
|
return 1;
|
|
@@ -484,7 +446,7 @@ async function runSearchInner(service, options) {
|
|
|
484
446
|
if (engines.length > 0) {
|
|
485
447
|
const unconfigured = planProviderSearch(engines, tavilyCli, firecrawlCli).unconfigured;
|
|
486
448
|
if (unconfigured.length > 0) {
|
|
487
|
-
feedbackLog('validation', 'error', { error: '
|
|
449
|
+
feedbackLog('validation', 'error', { error: 'PROVIDER_NOT_CONFIGURED' });
|
|
488
450
|
const envelope = createErrorEnvelope('PROVIDER_NOT_CONFIGURED', `Provider selected but no API key configured: ${unconfigured.join(', ')}`, { hint: unconfigured.map(p => p === 'ollama'
|
|
489
451
|
? 'Set OLLAMA_API_KEY or add "ollamaApiKey" to digdig.config.json'
|
|
490
452
|
: p === 'deepseek' ? 'Set DEEPSEEK_API_KEY or add "deepseekApiKey" to digdig.config.json'
|
|
@@ -670,11 +632,9 @@ async function runSearchInner(service, options) {
|
|
|
670
632
|
let sessionInfo = null;
|
|
671
633
|
if (options.session) {
|
|
672
634
|
feedbackLog('session', 'start');
|
|
673
|
-
sessionInfo = appendAndInjectSessionResults(options.session, fusion.display.map(
|
|
635
|
+
sessionInfo = appendAndInjectSessionResults(options.session, fusion.display.map(result => ({
|
|
674
636
|
...result,
|
|
675
|
-
//
|
|
676
|
-
// order instead of one provider's and one RRF's.
|
|
677
|
-
rank: index + 1,
|
|
637
|
+
// `rank` comes from the fusion, so it is not restated here.
|
|
678
638
|
origins: fusion.originsByKey.get(resultUrlKey(result)),
|
|
679
639
|
})), searchRound);
|
|
680
640
|
feedbackLog('session', 'ok', { count: sessionInfo.added, total: sessionInfo.total });
|
|
@@ -811,6 +771,9 @@ export function createProgram(argv = []) {
|
|
|
811
771
|
.option('--approve-file <path>', 'UTF-8 approval JSON array under this session agent-inputs directory')
|
|
812
772
|
.option('--skip-file <path>', 'UTF-8 skip JSON array under this session agent-inputs directory')
|
|
813
773
|
.option('--unskip-file <path>', 'UTF-8 restore JSON array under this session agent-inputs directory')
|
|
774
|
+
.option('--approve-stdin', 'Read the approval array from stdin')
|
|
775
|
+
.option('--skip-stdin', 'Read the skip array from stdin')
|
|
776
|
+
.option('--unskip-stdin', 'Read the restore array from stdin')
|
|
814
777
|
.option('--health', 'Check the SearXNG backend health (Ollama/DeepSeek have no health endpoint)')
|
|
815
778
|
.option('--engines-list', 'List available search engines')
|
|
816
779
|
.option('--categories-list', 'List available categories')
|
|
@@ -857,35 +820,17 @@ export function createProgram(argv = []) {
|
|
|
857
820
|
const code = await runExtract(extractor, extractOptions);
|
|
858
821
|
process.exitCode = code;
|
|
859
822
|
});
|
|
860
|
-
program
|
|
861
|
-
.command('query-graph')
|
|
862
|
-
.argument('<path>', 'Graph file or session name')
|
|
863
|
-
.description('[DEPRECATED] Query subgraph via BFS. Use graph-explore + graph-drill instead.')
|
|
864
|
-
.option('--seeds <s1,s2>', 'Seed nodes for BFS')
|
|
865
|
-
.option('--depth <n>', 'BFS depth (default: 2)', val => parseInt(val, 10), 2)
|
|
866
|
-
.option('--strategy <strategy>', 'Sampling strategy: augmented_chain | dual_core_bridge | community_core_path | deep_chain | mixed')
|
|
867
|
-
.option('-f, --format <fmt>', 'Output format: md, json')
|
|
868
|
-
.action(async (path, opts, command) => {
|
|
869
|
-
console.warn('[DEPRECATED] query-graph is deprecated. Use graph-explore + graph-drill instead.');
|
|
870
|
-
const graphFormat = command.optsWithGlobals().format === 'json' ? 'json' : 'md';
|
|
871
|
-
const code = await runQueryGraph({
|
|
872
|
-
graphFile: path,
|
|
873
|
-
seeds: opts.seeds?.split(',').map((s) => s.trim()).filter(Boolean) || [],
|
|
874
|
-
depth: opts.depth ?? 2,
|
|
875
|
-
format: graphFormat,
|
|
876
|
-
strategy: opts.strategy,
|
|
877
|
-
});
|
|
878
|
-
process.exitCode = code;
|
|
879
|
-
});
|
|
880
823
|
program
|
|
881
824
|
.command('graph-add')
|
|
882
825
|
.argument('<session>', 'Session directory or name')
|
|
883
826
|
.description('Add semantic entities/edges supported by approved extracted result IDs.')
|
|
884
|
-
.
|
|
827
|
+
.option('--data-file <path>', 'UTF-8 JSON under this session agent-inputs directory')
|
|
828
|
+
.option('--data-stdin', 'Read the same JSON from stdin instead of a file')
|
|
885
829
|
.action(async (session, opts) => {
|
|
886
830
|
const code = await runGraphAdd({
|
|
887
831
|
session,
|
|
888
832
|
dataFile: opts.dataFile,
|
|
833
|
+
dataStdin: opts.dataStdin ?? false,
|
|
889
834
|
});
|
|
890
835
|
process.exitCode = code;
|
|
891
836
|
});
|
|
@@ -894,12 +839,14 @@ export function createProgram(argv = []) {
|
|
|
894
839
|
.argument('<session>', 'Session directory or name')
|
|
895
840
|
.description('Import external search records or extracted bodies into a session')
|
|
896
841
|
.requiredOption('--kind <kind>', 'Import kind: search or extracted')
|
|
897
|
-
.
|
|
842
|
+
.option('--data-file <path>', 'UTF-8 JSON under this session agent-inputs directory')
|
|
843
|
+
.option('--data-stdin', 'Read the same JSON from stdin instead of a file')
|
|
898
844
|
.option('--query <query>', 'Discovery query (may instead be supplied per item)')
|
|
899
845
|
.option('--tool <tool>', 'Origin tool (may instead be supplied per item)')
|
|
900
846
|
.addHelpText('after', `
|
|
901
847
|
Examples:
|
|
902
848
|
dg results-add my-session --kind search --tool exa --query "async runtime" --data-file .digdig/sessions/my-session/agent-inputs/results.json
|
|
849
|
+
dg results-add my-session --kind extracted --data-stdin < results.json
|
|
903
850
|
|
|
904
851
|
Search imports await extraction; extracted imports await approval.`)
|
|
905
852
|
.action(async (session, opts) => {
|
|
@@ -907,6 +854,7 @@ Search imports await extraction; extracted imports await approval.`)
|
|
|
907
854
|
session,
|
|
908
855
|
kind: opts.kind,
|
|
909
856
|
dataFile: opts.dataFile,
|
|
857
|
+
dataStdin: opts.dataStdin ?? false,
|
|
910
858
|
query: opts.query,
|
|
911
859
|
tool: opts.tool,
|
|
912
860
|
});
|
|
@@ -1048,31 +996,7 @@ Examples:
|
|
|
1048
996
|
console.log(JSON.stringify(createSuccessEnvelope(listPendingGraph(resolveSessionPath(session))), null, 2));
|
|
1049
997
|
process.exitCode = 0;
|
|
1050
998
|
});
|
|
1051
|
-
program
|
|
1052
|
-
.command('suggest-queries')
|
|
1053
|
-
.argument('<session>', 'Session directory or name')
|
|
1054
|
-
.description('Output query suggestion data for Agent follow-up query generation')
|
|
1055
|
-
.option('-f, --format <fmt>', 'Output format: json (default), md')
|
|
1056
|
-
.addHelpText('after', `
|
|
1057
|
-
Examples:
|
|
1058
|
-
dg suggest-queries my-session
|
|
1059
|
-
dg suggest-queries my-session --format md`)
|
|
1060
|
-
.action(async (session, opts, command) => {
|
|
1061
|
-
const sessionDir = resolveSessionPath(session);
|
|
1062
|
-
const results = loadSessionResults(sessionDir);
|
|
1063
|
-
if (reportEmptySession(results.length))
|
|
1064
|
-
return;
|
|
1065
|
-
const graph = loadSessionGraph(sessionDir);
|
|
1066
|
-
const stage = determineSearchStage(graph, undefined, loadSessionRounds(sessionDir));
|
|
1067
|
-
const data = generateQuerySuggestions(graph, results, stage);
|
|
1068
|
-
if (command.optsWithGlobals().format === 'md') {
|
|
1069
|
-
console.log(formatSuggestAsMarkdown(data));
|
|
1070
|
-
}
|
|
1071
|
-
else {
|
|
1072
|
-
console.log(JSON.stringify(createSuccessEnvelope(data), null, 2));
|
|
1073
|
-
}
|
|
1074
|
-
process.exitCode = 0;
|
|
1075
|
-
});
|
|
999
|
+
program;
|
|
1076
1000
|
program
|
|
1077
1001
|
.command('strategy-info')
|
|
1078
1002
|
.argument('<session>', 'Session directory or name')
|
|
@@ -1221,15 +1145,20 @@ See also: graph-explore (for viewing relations of a known entity)`)
|
|
|
1221
1145
|
.description('Add claims (single or batch) with auto evidence-search')
|
|
1222
1146
|
.option('--claim-file <path>', 'UTF-8 JSON file with one claim')
|
|
1223
1147
|
.option('--claims-file <path>', 'UTF-8 JSON file with a claim array')
|
|
1148
|
+
.option('--claim-stdin', 'Read one claim from stdin')
|
|
1149
|
+
.option('--claims-stdin', 'Read a claim array from stdin')
|
|
1224
1150
|
.option('-f, --format <fmt>', 'Output format: json (default), md')
|
|
1225
1151
|
.addHelpText('after', `
|
|
1226
1152
|
Examples:
|
|
1227
1153
|
dg claim-add my-session --claim-file .digdig/sessions/my-session/agent-inputs/claim.json
|
|
1228
|
-
dg claim-add my-session --claims-file .digdig/sessions/my-session/agent-inputs/claims.json
|
|
1154
|
+
dg claim-add my-session --claims-file .digdig/sessions/my-session/agent-inputs/claims.json
|
|
1155
|
+
dg claim-add my-session --claims-stdin < claims.json`)
|
|
1229
1156
|
.action(async (session, opts, command) => {
|
|
1230
1157
|
const code = await runClaimAdd(session, {
|
|
1231
1158
|
claimFile: opts.claimFile,
|
|
1232
1159
|
claimsFile: opts.claimsFile,
|
|
1160
|
+
claimStdin: opts.claimStdin ?? false,
|
|
1161
|
+
claimsStdin: opts.claimsStdin ?? false,
|
|
1233
1162
|
format: command.optsWithGlobals().format,
|
|
1234
1163
|
});
|
|
1235
1164
|
process.exitCode = code;
|
|
@@ -1266,6 +1195,7 @@ Examples:
|
|
|
1266
1195
|
.description('Confirm evidence + submit stance + optional auto-policy')
|
|
1267
1196
|
.requiredOption('--claim-id <id>', 'Claim ID')
|
|
1268
1197
|
.requiredOption('--evidence-file <path>', 'UTF-8 JSON file with evidence object under this session agent-inputs directory')
|
|
1198
|
+
.option('--evidence-stdin', 'Read the same JSON from stdin instead of a file')
|
|
1269
1199
|
.requiredOption('--stance <s>', 'Stance: support, refute, insufficient')
|
|
1270
1200
|
.requiredOption('--reason <text>', 'Judgement rationale')
|
|
1271
1201
|
.option('--confidence <n>', 'Confidence 0-1')
|
|
@@ -1275,6 +1205,7 @@ Examples:
|
|
|
1275
1205
|
const code = await runEvidenceVerify(session, {
|
|
1276
1206
|
claimId: opts.claimId,
|
|
1277
1207
|
evidenceFile: opts.evidenceFile,
|
|
1208
|
+
evidenceStdin: opts.evidenceStdin ?? false,
|
|
1278
1209
|
stance: opts.stance,
|
|
1279
1210
|
reason: opts.reason,
|
|
1280
1211
|
confidence: opts.confidence === undefined ? undefined : (opts.confidence.trim() ? Number(opts.confidence) : NaN),
|
|
@@ -1317,7 +1248,8 @@ Examples:
|
|
|
1317
1248
|
.description('List or record source independence judgments')
|
|
1318
1249
|
.requiredOption('--claim-id <id>', 'Claim ID')
|
|
1319
1250
|
.option('--data-file <path>', 'Judgment or revocation JSON in agent-inputs')
|
|
1320
|
-
.
|
|
1251
|
+
.option('--data-stdin', 'Read the same JSON from stdin instead of a file')
|
|
1252
|
+
.action(async (session, opts) => { process.exitCode = await runSourceRelations(session, { claimId: opts.claimId, dataFile: opts.dataFile, dataStdin: opts.dataStdin ?? false }); });
|
|
1321
1253
|
program
|
|
1322
1254
|
.command('policy-aggregate')
|
|
1323
1255
|
.argument('<session>', 'Session directory or name')
|
|
@@ -1393,16 +1325,19 @@ export async function runCli(args, service) {
|
|
|
1393
1325
|
if (!opts.skipFile && !opts.unskipFile && !opts.approveFile && reportEmptySession(sessionResults.length))
|
|
1394
1326
|
return;
|
|
1395
1327
|
const sessionGraph = loadSessionGraph(sessionDir);
|
|
1396
|
-
const readSelections = (option, file) => {
|
|
1397
|
-
const input = readSessionJsonInput(sessionDir, [
|
|
1328
|
+
const readSelections = (option, file, stdin) => {
|
|
1329
|
+
const input = readSessionJsonInput(sessionDir, [
|
|
1330
|
+
{ option, value: file, file: true },
|
|
1331
|
+
{ option: `${option.slice(0, -'-file'.length)}-stdin`, stdin },
|
|
1332
|
+
]);
|
|
1398
1333
|
if (!input.ok || !Array.isArray(input.value) || !input.value.every(item => typeof item === 'object' && item !== null && typeof item.id === 'string' && Number.isSafeInteger(item.revision))) {
|
|
1399
1334
|
console.log(JSON.stringify(createErrorEnvelope(input.ok ? 'INVALID_APPROVAL_SELECTION' : input.code, input.ok ? `${option} must contain an array of {id, revision}` : input.message), null, 2));
|
|
1400
1335
|
return undefined;
|
|
1401
1336
|
}
|
|
1402
1337
|
return input.value;
|
|
1403
1338
|
};
|
|
1404
|
-
const applySkip = (option, file, skipped) => {
|
|
1405
|
-
const selections = readSelections(option, file);
|
|
1339
|
+
const applySkip = (option, file, stdin, skipped) => {
|
|
1340
|
+
const selections = readSelections(option, file, stdin);
|
|
1406
1341
|
if (!selections)
|
|
1407
1342
|
return false;
|
|
1408
1343
|
const result = setSkipped(sessionDir, selections, skipped);
|
|
@@ -1413,13 +1348,15 @@ export async function runCli(args, service) {
|
|
|
1413
1348
|
console.log(JSON.stringify(createSuccessEnvelope({ changed: result.changed, skipped, results: result.results.map(item => ({ id: item.id, revision: item.revision, skippedAt: item.skippedAt })) }), null, 2));
|
|
1414
1349
|
return true;
|
|
1415
1350
|
};
|
|
1416
|
-
if (opts.skipFile || opts.unskipFile) {
|
|
1417
|
-
if (opts.skipFile && opts.unskipFile) {
|
|
1418
|
-
console.log(JSON.stringify(createErrorEnvelope('MULTIPLE_SKIP_ACTIONS', 'Use only one of --skip-file or --unskip-
|
|
1351
|
+
if (opts.skipFile || opts.unskipFile || opts.skipStdin || opts.unskipStdin) {
|
|
1352
|
+
if ((opts.skipFile || opts.skipStdin) && (opts.unskipFile || opts.unskipStdin)) {
|
|
1353
|
+
console.log(JSON.stringify(createErrorEnvelope('MULTIPLE_SKIP_ACTIONS', 'Use only one of --skip-file, --skip-stdin, --unskip-file or --unskip-stdin'), null, 2));
|
|
1419
1354
|
process.exitCode = 1;
|
|
1420
1355
|
return;
|
|
1421
1356
|
}
|
|
1422
|
-
|
|
1357
|
+
const skipping = Boolean(opts.skipFile || opts.skipStdin);
|
|
1358
|
+
const option = skipping ? '--skip-file' : '--unskip-file';
|
|
1359
|
+
process.exitCode = applySkip(option, opts.skipFile ?? opts.unskipFile, skipping ? opts.skipStdin : opts.unskipStdin, skipping) ? 0 : 1;
|
|
1423
1360
|
return;
|
|
1424
1361
|
}
|
|
1425
1362
|
// Get pending results for Agent review
|
|
@@ -1428,7 +1365,7 @@ export async function runCli(args, service) {
|
|
|
1428
1365
|
// Approval is allowed only after reporting what is waiting and how
|
|
1429
1366
|
// much of it carries a body.
|
|
1430
1367
|
if (opts.approveFile) {
|
|
1431
|
-
const selections = readSelections('--approve-file', opts.approveFile);
|
|
1368
|
+
const selections = readSelections('--approve-file', opts.approveFile, opts.approveStdin);
|
|
1432
1369
|
if (!selections) {
|
|
1433
1370
|
process.exitCode = 1;
|
|
1434
1371
|
return;
|