@michaelborck/honeyguide-cli 0.6.0 → 0.7.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.
- package/dist/index.d.ts +0 -0
- package/dist/index.js +62 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
3
4
|
import { readFile } from 'node:fs/promises';
|
|
4
5
|
import { Command } from 'commander';
|
|
5
|
-
import { suggestResources, suggestBatch, toBatchMarkdown, recheckResources, toRecheckMarkdown, configFromEnv, toMarkdown, toCitations, toLmsHtml, extract, } from '@michaelborck/honeyguide-core';
|
|
6
|
+
import { suggestResources, suggestBatch, toBatchMarkdown, recheckResources, toRecheckMarkdown, configFromEnv, toMarkdown, toCitations, toLmsHtml, extract, toCollectionFile, resourcesFromSaved, parseOutcomes, } from '@michaelborck/honeyguide-core';
|
|
7
|
+
function cliVersion() {
|
|
8
|
+
try {
|
|
9
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
10
|
+
return pkg.version ?? '0.0.0';
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return '0.0.0';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
6
16
|
const program = new Command();
|
|
17
|
+
async function readOutcomes(file) {
|
|
18
|
+
if (!file)
|
|
19
|
+
return [];
|
|
20
|
+
const outcomes = parseOutcomes(await readFile(file, 'utf8'));
|
|
21
|
+
if (!outcomes.length)
|
|
22
|
+
program.error('No outcomes found in file.');
|
|
23
|
+
return outcomes;
|
|
24
|
+
}
|
|
25
|
+
/** The scriptable subset of the interview brief (ADR-0018). */
|
|
26
|
+
function briefOptions(options) {
|
|
27
|
+
const constraints = {
|
|
28
|
+
...(options.openAccess ? { openAccessOnly: true } : {}),
|
|
29
|
+
...(options.noVideo ? { excludeFormats: ['video'] } : {}),
|
|
30
|
+
...(options.since ? { minYear: Number(options.since) } : {}),
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
...(Object.keys(constraints).length ? { constraints } : {}),
|
|
34
|
+
...(options.context ? { context: options.context } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
7
37
|
program
|
|
8
38
|
.name('honeyguide')
|
|
9
39
|
.description('Finds and verifies supporting resources for your teaching.')
|
|
10
|
-
.version(
|
|
40
|
+
.version(cliVersion());
|
|
11
41
|
program
|
|
12
42
|
.command('suggest')
|
|
13
43
|
.description('List mode: verified, annotated resources for a topic or document')
|
|
@@ -16,6 +46,12 @@ program
|
|
|
16
46
|
.option('-n, --max-results <n>', 'maximum number of resources', '10')
|
|
17
47
|
.option('-o, --format <format>', 'output format: markdown, json, html (LMS-ready), apa, harvard', 'markdown')
|
|
18
48
|
.option('--json', 'shorthand for --format json')
|
|
49
|
+
.option('--collection', 'write a portable collection file (JSON) that can be reopened and shared')
|
|
50
|
+
.option('--outcomes <path>', 'align resources to unit outcomes (one per line)')
|
|
51
|
+
.option('--open-access', 'only freely readable papers (best effort)')
|
|
52
|
+
.option('--no-video', 'omit video results')
|
|
53
|
+
.option('--since <year>', 'only resources published since this year')
|
|
54
|
+
.option('--context <text>', 'teaching context for the rationale')
|
|
19
55
|
.option('-c, --counterpoint', 'also surface material disagreeing with the framing')
|
|
20
56
|
.action(async (topicWords, options) => {
|
|
21
57
|
let input = topicWords.join(' ');
|
|
@@ -28,14 +64,24 @@ program
|
|
|
28
64
|
if (!input.trim()) {
|
|
29
65
|
program.error('Provide a topic or --file <path>.');
|
|
30
66
|
}
|
|
67
|
+
const outcomes = await readOutcomes(options.outcomes);
|
|
31
68
|
const result = await suggestResources({
|
|
32
69
|
input,
|
|
33
70
|
maxResults: Number(options.maxResults),
|
|
34
71
|
counterpoint: Boolean(options.counterpoint),
|
|
72
|
+
...(outcomes.length ? { outcomes } : {}),
|
|
73
|
+
...briefOptions(options),
|
|
35
74
|
}, configFromEnv());
|
|
36
|
-
const format = options.
|
|
75
|
+
const format = options.collection
|
|
76
|
+
? 'collection'
|
|
77
|
+
: options.json
|
|
78
|
+
? 'json'
|
|
79
|
+
: options.format;
|
|
37
80
|
let out;
|
|
38
81
|
switch (format) {
|
|
82
|
+
case 'collection':
|
|
83
|
+
out = JSON.stringify(toCollectionFile(label, result, outcomes), null, 2);
|
|
84
|
+
break;
|
|
39
85
|
case 'json':
|
|
40
86
|
out = JSON.stringify(result, null, 2);
|
|
41
87
|
break;
|
|
@@ -56,6 +102,11 @@ program
|
|
|
56
102
|
.description('Batch mode: verified resources for many topics at once (one per line)')
|
|
57
103
|
.argument('<file>', 'text file with one topic per line')
|
|
58
104
|
.option('-n, --max-results <n>', 'maximum resources per topic', '8')
|
|
105
|
+
.option('--outcomes <path>', 'align each topic to unit outcomes (one per line)')
|
|
106
|
+
.option('--open-access', 'only freely readable papers (best effort)')
|
|
107
|
+
.option('--no-video', 'omit video results')
|
|
108
|
+
.option('--since <year>', 'only resources published since this year')
|
|
109
|
+
.option('--context <text>', 'teaching context for rationales')
|
|
59
110
|
.option('-c, --counterpoint', 'also surface disagreeing material per topic')
|
|
60
111
|
.option('--json', 'output JSON instead of markdown')
|
|
61
112
|
.action(async (file, options) => {
|
|
@@ -65,23 +116,26 @@ program
|
|
|
65
116
|
.filter((l) => l && !l.startsWith('#'));
|
|
66
117
|
if (!topics.length)
|
|
67
118
|
program.error('No topics found in file.');
|
|
119
|
+
const outcomes = await readOutcomes(options.outcomes);
|
|
68
120
|
const entries = await suggestBatch(topics, configFromEnv(), {
|
|
69
121
|
maxResults: Number(options.maxResults),
|
|
70
122
|
counterpoint: Boolean(options.counterpoint),
|
|
123
|
+
...(outcomes.length ? { outcomes } : {}),
|
|
124
|
+
...briefOptions(options),
|
|
71
125
|
});
|
|
72
126
|
process.stdout.write((options.json ? JSON.stringify({ entries }, null, 2) : toBatchMarkdown(entries)) +
|
|
73
127
|
'\n');
|
|
74
128
|
});
|
|
75
129
|
program
|
|
76
130
|
.command('recheck')
|
|
77
|
-
.description('Link-rot re-run: re-verify a
|
|
78
|
-
.argument('<file>', '
|
|
131
|
+
.description('Link-rot re-run: re-verify a saved collection or JSON result list')
|
|
132
|
+
.argument('<file>', 'collection file, or JSON from `suggest --json` / `batch --json`')
|
|
79
133
|
.option('--json', 'output JSON instead of markdown')
|
|
80
134
|
.action(async (file, options) => {
|
|
81
135
|
const saved = JSON.parse(await readFile(file, 'utf8'));
|
|
82
|
-
const resources = saved
|
|
83
|
-
if (!
|
|
84
|
-
program.error('No resources found in file — expected suggest/batch JSON output.');
|
|
136
|
+
const resources = resourcesFromSaved(saved);
|
|
137
|
+
if (!resources.length) {
|
|
138
|
+
program.error('No resources found in file — expected a collection, or suggest/batch JSON output.');
|
|
85
139
|
}
|
|
86
140
|
const entries = await recheckResources(resources);
|
|
87
141
|
process.stdout.write((options.json ? JSON.stringify({ entries }, null, 2) : toRecheckMarkdown(entries)) +
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MA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