@tenphi/akno 0.1.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/LICENSE +83 -0
- package/README.md +46 -0
- package/dist/args.d.ts +18 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +92 -0
- package/dist/args.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +142 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/adopt-cmd.d.ts +2 -0
- package/dist/commands/adopt-cmd.d.ts.map +1 -0
- package/dist/commands/adopt-cmd.js +61 -0
- package/dist/commands/adopt-cmd.js.map +1 -0
- package/dist/commands/answer-cmd.d.ts +2 -0
- package/dist/commands/answer-cmd.d.ts.map +1 -0
- package/dist/commands/answer-cmd.js +150 -0
- package/dist/commands/answer-cmd.js.map +1 -0
- package/dist/commands/bench-cmd.d.ts +4 -0
- package/dist/commands/bench-cmd.d.ts.map +1 -0
- package/dist/commands/bench-cmd.js +1542 -0
- package/dist/commands/bench-cmd.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +7 -0
- package/dist/commands/config-cmd.d.ts.map +1 -0
- package/dist/commands/config-cmd.js +80 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/context-cmd.d.ts +2 -0
- package/dist/commands/context-cmd.d.ts.map +1 -0
- package/dist/commands/context-cmd.js +130 -0
- package/dist/commands/context-cmd.js.map +1 -0
- package/dist/commands/doctor-cmd.d.ts +2 -0
- package/dist/commands/doctor-cmd.d.ts.map +1 -0
- package/dist/commands/doctor-cmd.js +198 -0
- package/dist/commands/doctor-cmd.js.map +1 -0
- package/dist/commands/dream-cmd.d.ts +26 -0
- package/dist/commands/dream-cmd.d.ts.map +1 -0
- package/dist/commands/dream-cmd.js +1167 -0
- package/dist/commands/dream-cmd.js.map +1 -0
- package/dist/commands/dream-model-status.d.ts +5 -0
- package/dist/commands/dream-model-status.d.ts.map +1 -0
- package/dist/commands/dream-model-status.js +33 -0
- package/dist/commands/dream-model-status.js.map +1 -0
- package/dist/commands/dream-notifications.d.ts +24 -0
- package/dist/commands/dream-notifications.d.ts.map +1 -0
- package/dist/commands/dream-notifications.js +168 -0
- package/dist/commands/dream-notifications.js.map +1 -0
- package/dist/commands/dream-schedule.d.ts +55 -0
- package/dist/commands/dream-schedule.d.ts.map +1 -0
- package/dist/commands/dream-schedule.js +160 -0
- package/dist/commands/dream-schedule.js.map +1 -0
- package/dist/commands/folder-cmd.d.ts +2 -0
- package/dist/commands/folder-cmd.d.ts.map +1 -0
- package/dist/commands/folder-cmd.js +84 -0
- package/dist/commands/folder-cmd.js.map +1 -0
- package/dist/commands/graph-cmd.d.ts +2 -0
- package/dist/commands/graph-cmd.d.ts.map +1 -0
- package/dist/commands/graph-cmd.js +126 -0
- package/dist/commands/graph-cmd.js.map +1 -0
- package/dist/commands/inbox-cmd.d.ts +2 -0
- package/dist/commands/inbox-cmd.d.ts.map +1 -0
- package/dist/commands/inbox-cmd.js +69 -0
- package/dist/commands/inbox-cmd.js.map +1 -0
- package/dist/commands/index-cmd.d.ts +2 -0
- package/dist/commands/index-cmd.d.ts.map +1 -0
- package/dist/commands/index-cmd.js +102 -0
- package/dist/commands/index-cmd.js.map +1 -0
- package/dist/commands/ingest-cmd.d.ts +2 -0
- package/dist/commands/ingest-cmd.d.ts.map +1 -0
- package/dist/commands/ingest-cmd.js +167 -0
- package/dist/commands/ingest-cmd.js.map +1 -0
- package/dist/commands/init-cmd.d.ts +292 -0
- package/dist/commands/init-cmd.d.ts.map +1 -0
- package/dist/commands/init-cmd.js +476 -0
- package/dist/commands/init-cmd.js.map +1 -0
- package/dist/commands/init-prompts.d.ts +51 -0
- package/dist/commands/init-prompts.d.ts.map +1 -0
- package/dist/commands/init-prompts.js +192 -0
- package/dist/commands/init-prompts.js.map +1 -0
- package/dist/commands/list-cmd.d.ts +2 -0
- package/dist/commands/list-cmd.d.ts.map +1 -0
- package/dist/commands/list-cmd.js +77 -0
- package/dist/commands/list-cmd.js.map +1 -0
- package/dist/commands/maintenance-policy-output.d.ts +4 -0
- package/dist/commands/maintenance-policy-output.d.ts.map +1 -0
- package/dist/commands/maintenance-policy-output.js +72 -0
- package/dist/commands/maintenance-policy-output.js.map +1 -0
- package/dist/commands/mutate-cmd.d.ts +5 -0
- package/dist/commands/mutate-cmd.d.ts.map +1 -0
- package/dist/commands/mutate-cmd.js +224 -0
- package/dist/commands/mutate-cmd.js.map +1 -0
- package/dist/commands/plan-cmd.d.ts +9 -0
- package/dist/commands/plan-cmd.d.ts.map +1 -0
- package/dist/commands/plan-cmd.js +411 -0
- package/dist/commands/plan-cmd.js.map +1 -0
- package/dist/commands/read-cmd.d.ts +2 -0
- package/dist/commands/read-cmd.d.ts.map +1 -0
- package/dist/commands/read-cmd.js +89 -0
- package/dist/commands/read-cmd.js.map +1 -0
- package/dist/commands/recall-cmd.d.ts +2 -0
- package/dist/commands/recall-cmd.d.ts.map +1 -0
- package/dist/commands/recall-cmd.js +176 -0
- package/dist/commands/recall-cmd.js.map +1 -0
- package/dist/commands/redeploy-cmd.d.ts +43 -0
- package/dist/commands/redeploy-cmd.d.ts.map +1 -0
- package/dist/commands/redeploy-cmd.js +270 -0
- package/dist/commands/redeploy-cmd.js.map +1 -0
- package/dist/commands/rules-cmd.d.ts +2 -0
- package/dist/commands/rules-cmd.d.ts.map +1 -0
- package/dist/commands/rules-cmd.js +72 -0
- package/dist/commands/rules-cmd.js.map +1 -0
- package/dist/commands/serve-cmd.d.ts +23 -0
- package/dist/commands/serve-cmd.d.ts.map +1 -0
- package/dist/commands/serve-cmd.js +415 -0
- package/dist/commands/serve-cmd.js.map +1 -0
- package/dist/commands/timeline-cmd.d.ts +2 -0
- package/dist/commands/timeline-cmd.d.ts.map +1 -0
- package/dist/commands/timeline-cmd.js +67 -0
- package/dist/commands/timeline-cmd.js.map +1 -0
- package/dist/commands/write-cmd.d.ts +49 -0
- package/dist/commands/write-cmd.d.ts.map +1 -0
- package/dist/commands/write-cmd.js +269 -0
- package/dist/commands/write-cmd.js.map +1 -0
- package/dist/ops-handle.d.ts +67 -0
- package/dist/ops-handle.d.ts.map +1 -0
- package/dist/ops-handle.js +196 -0
- package/dist/ops-handle.js.map +1 -0
- package/dist/output.d.ts +28 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +87 -0
- package/dist/output.js.map +1 -0
- package/dist/serve/http.d.ts +19 -0
- package/dist/serve/http.d.ts.map +1 -0
- package/dist/serve/http.js +135 -0
- package/dist/serve/http.js.map +1 -0
- package/dist/serve/mcp.d.ts +21 -0
- package/dist/serve/mcp.d.ts.map +1 -0
- package/dist/serve/mcp.js +79 -0
- package/dist/serve/mcp.js.map +1 -0
- package/dist/serve/socket.d.ts +15 -0
- package/dist/serve/socket.d.ts.map +1 -0
- package/dist/serve/socket.js +311 -0
- package/dist/serve/socket.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +15 -0
- package/dist/version.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
Required Notice: Copyright 2026 Andrey Yamanov (https://github.com/tenphi/akno)
|
|
6
|
+
|
|
7
|
+
Akno is source-available, not open source. Personal and other noncommercial
|
|
8
|
+
use is free. Using it commercially — including as part of, or to operate, a
|
|
9
|
+
paid product or service — is not permitted under these terms. For a commercial
|
|
10
|
+
licence, ask.
|
|
11
|
+
|
|
12
|
+
Third-party dependencies are not covered by these terms. Each remains under
|
|
13
|
+
its own licence and the copyright of its own authors.
|
|
14
|
+
|
|
15
|
+
## Acceptance
|
|
16
|
+
|
|
17
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
18
|
+
|
|
19
|
+
## Copyright License
|
|
20
|
+
|
|
21
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
22
|
+
|
|
23
|
+
## Distribution License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
26
|
+
|
|
27
|
+
## Notices
|
|
28
|
+
|
|
29
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
30
|
+
|
|
31
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
32
|
+
|
|
33
|
+
## Changes and New Works License
|
|
34
|
+
|
|
35
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
36
|
+
|
|
37
|
+
## Patent License
|
|
38
|
+
|
|
39
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
40
|
+
|
|
41
|
+
## Noncommercial Purposes
|
|
42
|
+
|
|
43
|
+
Any noncommercial purpose is a permitted purpose.
|
|
44
|
+
|
|
45
|
+
## Personal Uses
|
|
46
|
+
|
|
47
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
48
|
+
|
|
49
|
+
## Noncommercial Organizations
|
|
50
|
+
|
|
51
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
52
|
+
|
|
53
|
+
## Fair Use
|
|
54
|
+
|
|
55
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
56
|
+
|
|
57
|
+
## No Other Rights
|
|
58
|
+
|
|
59
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
60
|
+
|
|
61
|
+
## Patent Defense
|
|
62
|
+
|
|
63
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
64
|
+
|
|
65
|
+
## Violations
|
|
66
|
+
|
|
67
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
68
|
+
|
|
69
|
+
## No Liability
|
|
70
|
+
|
|
71
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
76
|
+
|
|
77
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
80
|
+
|
|
81
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
82
|
+
|
|
83
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @tenphi/akno
|
|
2
|
+
|
|
3
|
+
The Akno command-line interface and service.
|
|
4
|
+
|
|
5
|
+
Akno gives agents cited reading and guarded writing operations over a Markdown knowledge base while the files
|
|
6
|
+
remain authoritative and editable in any normal editor.
|
|
7
|
+
|
|
8
|
+
Akno's runtime currently supports macOS and Node 22.18 or newer.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @tenphi/akno
|
|
12
|
+
akno init
|
|
13
|
+
akno index
|
|
14
|
+
akno doctor
|
|
15
|
+
akno recall "How long is the Zephyr QX-100 warranty?"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`akno init` offers the qualified OpenAI single-endpoint setup, a model-free lexical setup, or preservation of
|
|
19
|
+
manually configured specialist roles. Model roles degrade independently, so `doctor` explains both availability
|
|
20
|
+
and the consequence of a missing role.
|
|
21
|
+
|
|
22
|
+
## Main operations
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
recall / answer / read / list / graph / timeline / context
|
|
26
|
+
write / remember / forget / undo / move / folder
|
|
27
|
+
ingest / inbox / adopt
|
|
28
|
+
dream / plan
|
|
29
|
+
serve / service / doctor / rules / config / bench / redeploy
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`akno --help` and `akno <command> --help` describe the installed interface. The service exposes the same typed
|
|
33
|
+
operation registry in process, over an owner-only Unix socket, through loopback HTTP for containers, and over
|
|
34
|
+
stdio MCP for agent hosts.
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
- [Project overview](https://github.com/tenphi/akno#readme)
|
|
39
|
+
- [Getting started](https://github.com/tenphi/akno/blob/main/docs/getting-started.md)
|
|
40
|
+
- [How Akno works](https://github.com/tenphi/akno/blob/main/docs/how-it-works.md)
|
|
41
|
+
- [Command reference](https://github.com/tenphi/akno/blob/main/docs/commands.md)
|
|
42
|
+
- [All guides](https://github.com/tenphi/akno/tree/main/docs)
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
PolyForm Noncommercial License 1.0.0 — noncommercial use only.
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ParseArgsConfig } from 'node:util';
|
|
2
|
+
export interface Parsed<T = Record<string, unknown>> {
|
|
3
|
+
values: T & {
|
|
4
|
+
'akno-path'?: string;
|
|
5
|
+
'state-dir'?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
connect?: boolean;
|
|
8
|
+
help?: boolean;
|
|
9
|
+
};
|
|
10
|
+
positionals: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function parse<T = Record<string, unknown>>(argv: string[], options?: NonNullable<ParseArgsConfig['options']>): Parsed<T>;
|
|
13
|
+
/** `open()` options derived from the global flags. */
|
|
14
|
+
export declare function openOptionsFrom(values: Parsed['values']): {
|
|
15
|
+
aknoPath?: string;
|
|
16
|
+
stateDir?: string;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAgB5D,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjD,MAAM,EAAE,CAAC,GAAG;QACV,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAwDD,wBAAgB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/C,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,CAAM,GACpD,MAAM,CAAC,CAAC,CAAC,CAmBX;AAED,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAKlG"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
/**
|
|
3
|
+
* Flags shared by every command. `--akno-path` and `--state-dir` exist so a
|
|
4
|
+
* one-shot invocation can point at a different knowledge base without editing a
|
|
5
|
+
* config file — useful for tests and for a second knowledge base you touch rarely.
|
|
6
|
+
*/
|
|
7
|
+
const GLOBAL_OPTIONS = {
|
|
8
|
+
'akno-path': { type: 'string' },
|
|
9
|
+
'state-dir': { type: 'string' },
|
|
10
|
+
json: { type: 'boolean', default: false },
|
|
11
|
+
/** Talk to a running `akno serve` instead of opening the index in-process. */
|
|
12
|
+
connect: { type: 'boolean', default: false },
|
|
13
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Node's `parseArgs` has no `--no-flag` negation, so every boolean option that
|
|
17
|
+
* defaults to true gets an explicit `--no-<name>` twin registered here and
|
|
18
|
+
* folded back into the positive name. Without this, `--no-watch` parses as an
|
|
19
|
+
* unknown option — which is a worse failure than it looks, because the user
|
|
20
|
+
* asked for *less* behaviour and got an error instead.
|
|
21
|
+
*/
|
|
22
|
+
function withNegations(options) {
|
|
23
|
+
const out = { ...options };
|
|
24
|
+
for (const [name, option] of Object.entries(options)) {
|
|
25
|
+
if (option.type !== 'boolean' || option.default !== true)
|
|
26
|
+
continue;
|
|
27
|
+
out[`no-${name}`] = { type: 'boolean', default: false };
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Rewrites `--name value` into `--name=value` for declared string options.
|
|
33
|
+
*
|
|
34
|
+
* Node's `parseArgs` refuses a value that starts with `-`, calling it ambiguous —
|
|
35
|
+
* which makes `--append "- Rent: 1111 EUR"` an error. A Markdown list item is the
|
|
36
|
+
* most ordinary thing anyone appends to a knowledge base, so the parser has to
|
|
37
|
+
* cope with it rather than the user having to know about `=`.
|
|
38
|
+
*/
|
|
39
|
+
function attachValues(argv, declared) {
|
|
40
|
+
const isDeclared = (token) => {
|
|
41
|
+
if (!token.startsWith('--'))
|
|
42
|
+
return false;
|
|
43
|
+
const name = token.slice(2).split('=')[0];
|
|
44
|
+
return name in declared || name.startsWith('no-');
|
|
45
|
+
};
|
|
46
|
+
const out = [];
|
|
47
|
+
for (let i = 0; i < argv.length; i++) {
|
|
48
|
+
const token = argv[i];
|
|
49
|
+
const name = token.startsWith('--') ? token.slice(2) : null;
|
|
50
|
+
const option = name && !name.includes('=') ? declared[name] : undefined;
|
|
51
|
+
if (option?.type === 'string' && i + 1 < argv.length) {
|
|
52
|
+
const next = argv[i + 1];
|
|
53
|
+
// Only claim the next token if it is not itself a flag. A string option
|
|
54
|
+
// missing its value should still be reported as missing.
|
|
55
|
+
if (!isDeclared(next)) {
|
|
56
|
+
out.push(`${token}=${next}`);
|
|
57
|
+
i++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
out.push(token);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
export function parse(argv, options = {}) {
|
|
66
|
+
const declared = { ...GLOBAL_OPTIONS, ...options };
|
|
67
|
+
const result = parseArgs({
|
|
68
|
+
args: attachValues(argv, declared),
|
|
69
|
+
options: withNegations(declared),
|
|
70
|
+
allowPositionals: true,
|
|
71
|
+
// A typo should say so rather than being silently ignored, which with a
|
|
72
|
+
// command like `forget` is the difference between a no-op and a surprise.
|
|
73
|
+
strict: true,
|
|
74
|
+
});
|
|
75
|
+
const values = { ...result.values };
|
|
76
|
+
for (const [name, option] of Object.entries(declared)) {
|
|
77
|
+
if (option.type !== 'boolean' || option.default !== true)
|
|
78
|
+
continue;
|
|
79
|
+
if (values[`no-${name}`])
|
|
80
|
+
values[name] = false;
|
|
81
|
+
delete values[`no-${name}`];
|
|
82
|
+
}
|
|
83
|
+
return { values: values, positionals: result.positionals };
|
|
84
|
+
}
|
|
85
|
+
/** `open()` options derived from the global flags. */
|
|
86
|
+
export function openOptionsFrom(values) {
|
|
87
|
+
return {
|
|
88
|
+
...(values['akno-path'] ? { aknoPath: values['akno-path'] } : {}),
|
|
89
|
+
...(values['state-dir'] ? { stateDir: values['state-dir'] } : {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAE5D;;;;GAIG;AACH,MAAM,cAAc,GAAG;IACrB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;IACxC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;IACxC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,OAAO,EAAE,KAAK,EAAE;IAClD,8EAA8E;IAC9E,OAAO,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,OAAO,EAAE,KAAK,EAAE;IACrD,IAAI,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE;CACb,CAAC;AAapD;;;;;;GAMG;AACH,SAAS,aAAa,CACpB,OAAgD;IAEhD,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI;YAAE,SAAS;QACnE,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,S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AC,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC;AACJ,CAAC"}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AknoError, OPS, OP_NAMES } from '@tenphi/akno-protocol';
|
|
3
|
+
import { fail, line, style } from "./output.js";
|
|
4
|
+
import { indexCommand } from "./commands/index-cmd.js";
|
|
5
|
+
import { recallCommand } from "./commands/recall-cmd.js";
|
|
6
|
+
import { answerCommand } from "./commands/answer-cmd.js";
|
|
7
|
+
import { readCommand } from "./commands/read-cmd.js";
|
|
8
|
+
import { listCommand } from "./commands/list-cmd.js";
|
|
9
|
+
import { timelineCommand } from "./commands/timeline-cmd.js";
|
|
10
|
+
import { doctorCommand } from "./commands/doctor-cmd.js";
|
|
11
|
+
import { rulesCommand } from "./commands/rules-cmd.js";
|
|
12
|
+
import { folderCommand } from "./commands/folder-cmd.js";
|
|
13
|
+
import { redeployCommand } from "./commands/redeploy-cmd.js";
|
|
14
|
+
import { benchCommand } from "./commands/bench-cmd.js";
|
|
15
|
+
import { configCommand } from "./commands/config-cmd.js";
|
|
16
|
+
import { serveCommand, serviceCommand } from "./commands/serve-cmd.js";
|
|
17
|
+
import { contextCommand } from "./commands/context-cmd.js";
|
|
18
|
+
import { graphCommand } from "./commands/graph-cmd.js";
|
|
19
|
+
import { rememberCommand, writeCommand } from "./commands/write-cmd.js";
|
|
20
|
+
import { approveCommand, forgetCommand, moveCommand, undoCommand } from "./commands/mutate-cmd.js";
|
|
21
|
+
import { ingestCommand } from "./commands/ingest-cmd.js";
|
|
22
|
+
import { inboxCommand } from "./commands/inbox-cmd.js";
|
|
23
|
+
import { dreamCommand } from "./commands/dream-cmd.js";
|
|
24
|
+
import { planCommand } from "./commands/plan-cmd.js";
|
|
25
|
+
import { adoptCommand } from "./commands/adopt-cmd.js";
|
|
26
|
+
import { initCommand } from "./commands/init-cmd.js";
|
|
27
|
+
import { AKNO_VERSION } from "./version.js";
|
|
28
|
+
const HELP = `${style.bold('akno')} — a two-way memory layer for agents over a Markdown knowledge base
|
|
29
|
+
|
|
30
|
+
${style.bold('Reading')}
|
|
31
|
+
recall <query> Search memory. Returns cited page and document results.
|
|
32
|
+
answer <question> Answer from memory; returns citations and related identities.
|
|
33
|
+
read <slug> One exact page or document, in full.
|
|
34
|
+
list Browse folders, pages, or a tree outline.
|
|
35
|
+
timeline When things happened.
|
|
36
|
+
context <query> The whole pre-turn bundle against one budget.
|
|
37
|
+
graph [seed] Inspect bounded evidence paths; no page bodies.
|
|
38
|
+
|
|
39
|
+
${style.bold('Writing')}
|
|
40
|
+
write Create, append, patch or replace a page.
|
|
41
|
+
remember <text> Hand over notes; Akno decides what to keep and where.
|
|
42
|
+
forget Retract a fact, trash a page or a document.
|
|
43
|
+
undo <change_id> Reverse a change. \`--list\` shows recent ones.
|
|
44
|
+
move <from> <to> Relocate a page with its documents.
|
|
45
|
+
folder <path> Declare a folder and what belongs in it. Never gated.
|
|
46
|
+
approve / decline Resolve a gated proposal. \`--list\` shows pending.
|
|
47
|
+
ingest <path|url> Extract, OCR, name, summarize and route a file or folder.
|
|
48
|
+
inbox File whatever was dropped in an inbox folder.
|
|
49
|
+
adopt <document_id> Organize one orphan document through its trust policy.
|
|
50
|
+
|
|
51
|
+
${style.bold('Admin')}
|
|
52
|
+
init Guided setup. Never guesses a path or overwrites silently.
|
|
53
|
+
dream Conflicts, observe, reflect, curate, adopt, repair, housekeeping.
|
|
54
|
+
plan Inspect, decide and apply durable maintenance plans.
|
|
55
|
+
index Reconcile the index against the knowledge base.
|
|
56
|
+
serve Hold the index, watcher and models in one process.
|
|
57
|
+
service Manage the macOS launchd agent.
|
|
58
|
+
redeploy Apply local changes: build, restart the service, wait for it.
|
|
59
|
+
doctor What's present, what's degraded, and what that costs.
|
|
60
|
+
rules [path] Which rule governs a path, and why.
|
|
61
|
+
config Resolved config and where it came from, secrets redacted.
|
|
62
|
+
bench Check the performance budgets.
|
|
63
|
+
|
|
64
|
+
${style.bold('Global flags')}
|
|
65
|
+
--akno-path <p> Knowledge base for this invocation.
|
|
66
|
+
--state-dir <p> Where the index and trash live.
|
|
67
|
+
--json Machine-readable output.
|
|
68
|
+
--connect Require a running service; do not fall back in-process.
|
|
69
|
+
-h, --help Help for any command.
|
|
70
|
+
|
|
71
|
+
${style.grey('Start with: akno init')}
|
|
72
|
+
${style.grey('Guides and command reference: https://github.com/tenphi/akno/tree/main/docs')}`;
|
|
73
|
+
const COMMANDS = {
|
|
74
|
+
recall: recallCommand,
|
|
75
|
+
answer: answerCommand,
|
|
76
|
+
read: readCommand,
|
|
77
|
+
list: listCommand,
|
|
78
|
+
timeline: timelineCommand,
|
|
79
|
+
context: contextCommand,
|
|
80
|
+
graph: graphCommand,
|
|
81
|
+
write: writeCommand,
|
|
82
|
+
remember: rememberCommand,
|
|
83
|
+
forget: forgetCommand,
|
|
84
|
+
undo: undoCommand,
|
|
85
|
+
move: moveCommand,
|
|
86
|
+
folder: folderCommand,
|
|
87
|
+
ingest: ingestCommand,
|
|
88
|
+
inbox: inboxCommand,
|
|
89
|
+
adopt: adoptCommand,
|
|
90
|
+
init: initCommand,
|
|
91
|
+
dream: dreamCommand,
|
|
92
|
+
plan: planCommand,
|
|
93
|
+
approve: approveCommand,
|
|
94
|
+
decline: (argv) => approveCommand(argv, true),
|
|
95
|
+
index: indexCommand,
|
|
96
|
+
serve: serveCommand,
|
|
97
|
+
service: serviceCommand,
|
|
98
|
+
redeploy: redeployCommand,
|
|
99
|
+
doctor: doctorCommand,
|
|
100
|
+
rules: rulesCommand,
|
|
101
|
+
config: configCommand,
|
|
102
|
+
bench: benchCommand,
|
|
103
|
+
};
|
|
104
|
+
async function main() {
|
|
105
|
+
const [, , name, ...rest] = process.argv;
|
|
106
|
+
if (!name || name === '--help' || name === '-h' || name === 'help') {
|
|
107
|
+
line(HELP);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
if (name === '--version' || name === '-v' || name === 'version') {
|
|
111
|
+
line(AKNO_VERSION);
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
const command = COMMANDS[name];
|
|
115
|
+
if (command)
|
|
116
|
+
return command(rest);
|
|
117
|
+
// A write op the user reached for before it exists should say what it will do
|
|
118
|
+
// and that it does not yet — not "unknown command", which reads like a typo.
|
|
119
|
+
if (OP_NAMES.includes(name)) {
|
|
120
|
+
const definition = OPS[name];
|
|
121
|
+
fail(`\`${name}\` is not implemented in this build.`);
|
|
122
|
+
line(`\n ${definition.description}\n`);
|
|
123
|
+
line(style.grey(' Its schema is final and it is advertised over every door, so a caller can'));
|
|
124
|
+
line(style.grey(' already discover it — calling it returns `not_implemented`.'));
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
fail(`unknown command: ${name}`);
|
|
128
|
+
line(style.grey(`\n known: ${Object.keys(COMMANDS).join(', ')}`));
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
process.exitCode = await main();
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
const error = AknoError.from(err);
|
|
136
|
+
fail(`${error.code}: ${error.message}`);
|
|
137
|
+
if (error.details && Object.keys(error.details).length > 0) {
|
|
138
|
+
line(style.grey(` ${JSON.stringify(error.details)}`));
|
|
139
|
+
}
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADD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AAC;IACX,CAAC;IAED,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,CAAC;IACH,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC;AAClC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adopt-cmd.d.ts","sourceRoot":"","sources":["../../src/commands/adopt-cmd.ts"],"names":[],"mappings":"AAqBA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuClE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { openOptionsFrom, parse } from "../args.js";
|
|
2
|
+
import { heading, json, kv, line, statusLabel, style } from "../output.js";
|
|
3
|
+
import { resolveOps } from "../ops-handle.js";
|
|
4
|
+
const ADOPT_HELP = `akno adopt <document_id>
|
|
5
|
+
|
|
6
|
+
Give one orphan document card a durable filing page. The id comes from
|
|
7
|
+
\`akno recall --json\` or \`akno read --document …\`.
|
|
8
|
+
|
|
9
|
+
This never starts a bulk adoption pass. It seals only the selected document
|
|
10
|
+
group and follows the configured maintenance.policies.adopt authority:
|
|
11
|
+
|
|
12
|
+
audit save an exact diff for inspection
|
|
13
|
+
review wait for a human plan decision
|
|
14
|
+
auto ask the independent curator, apply, reindex, and verify ownership
|
|
15
|
+
|
|
16
|
+
The source file is never moved or changed, and it remains recallable if the
|
|
17
|
+
proposal is rejected or blocked.
|
|
18
|
+
|
|
19
|
+
--json Machine-readable response.`;
|
|
20
|
+
export async function adoptCommand(argv) {
|
|
21
|
+
const { values, positionals } = parse(argv, {});
|
|
22
|
+
if (values.help || positionals.length !== 1) {
|
|
23
|
+
line(ADOPT_HELP);
|
|
24
|
+
return values.help ? 0 : 1;
|
|
25
|
+
}
|
|
26
|
+
const handle = await resolveOps(values, openOptionsFrom(values), { write: true, actor: 'user' });
|
|
27
|
+
try {
|
|
28
|
+
const result = await handle.ops.adopt({ documentId: positionals[0] });
|
|
29
|
+
if (values.json) {
|
|
30
|
+
json(result);
|
|
31
|
+
return successful(result.outcome) ? 0 : 2;
|
|
32
|
+
}
|
|
33
|
+
heading(`${statusLabel(result.status)} ${result.outcome.replaceAll('_', ' ')}`);
|
|
34
|
+
kv([
|
|
35
|
+
['document', result.document_id],
|
|
36
|
+
['page', result.slug],
|
|
37
|
+
['path', result.rel_path],
|
|
38
|
+
['plan', result.plan?.id],
|
|
39
|
+
['item', result.plan?.item_id],
|
|
40
|
+
['change', result.change_id],
|
|
41
|
+
]);
|
|
42
|
+
if (result.reason)
|
|
43
|
+
line(`\n ${style.grey(result.reason)}`);
|
|
44
|
+
if (result.outcome === 'planned' && result.plan) {
|
|
45
|
+
line(`\n inspect: ${style.bold(`akno plan diff ${result.plan.id}`)}`);
|
|
46
|
+
}
|
|
47
|
+
if (result.outcome === 'requires_review' && result.plan) {
|
|
48
|
+
line(`\n inspect: ${style.bold(`akno plan diff ${result.plan.id}`)}`);
|
|
49
|
+
line(` decide: ${style.bold(`akno plan decide ${result.plan.id} --item ${result.plan.item_id} --approve`)}`);
|
|
50
|
+
line(` apply: ${style.bold(`akno plan apply ${result.plan.id}`)}`);
|
|
51
|
+
}
|
|
52
|
+
return successful(result.outcome) ? 0 : 2;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await handle.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function successful(outcome) {
|
|
59
|
+
return ['planned', 'requires_review', 'created', 'verification_pending', 'noop'].includes(outcome);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=adopt-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adopt-cmd.js","sourceRoot":"","sources":["../../src/commands/adopt-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;uCAeoB,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,IAAI,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC,UAAU,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,eAAe,CAAC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C;QACzE,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,KAAK,iBAAiB,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACxD,IAAI,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YACvE,IAAI,CACF,cAAc,KAAK,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,EAAE,CACzG,CAAC;YACF,IAAI,CAAC,cAAc,KAAK,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-cmd.d.ts","sourceRoot":"","sources":["../../src/commands/answer-cmd.ts"],"names":[],"mappings":"AA8BA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsEnE"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { openOptionsFrom, parse } from "../args.js";
|
|
2
|
+
import { heading, json, line, statusLabel, style } from "../output.js";
|
|
3
|
+
import { resolveOps } from "../ops-handle.js";
|
|
4
|
+
const ANSWER_HELP = `akno answer <question> [options]
|
|
5
|
+
|
|
6
|
+
Ask memory for a direct grounded answer. This internally performs recall,
|
|
7
|
+
generates structured cited blocks, and independently verifies their support.
|
|
8
|
+
It returns compact related page slugs/document ids, never evidence excerpts.
|
|
9
|
+
Use recall when you need to inspect or quote the evidence itself.
|
|
10
|
+
|
|
11
|
+
--limit <n> Maximum qualified retrieval candidates.
|
|
12
|
+
--budget <n> Internal retrieval evidence budget.
|
|
13
|
+
--include <r,...> Page roles to include, e.g. source.
|
|
14
|
+
--folder <path> Restrict to a folder.
|
|
15
|
+
--type <t> Restrict to a frontmatter type.
|
|
16
|
+
--tag <t,...> Restrict to pages carrying all of these tags.
|
|
17
|
+
--source <s> page | document | both
|
|
18
|
+
--ownership <o> orphan | owned | any
|
|
19
|
+
--since <date> Earliest evidence date: YYYY, YYYY-MM, or YYYY-MM-DD.
|
|
20
|
+
--until <date> Latest evidence date: YYYY, YYYY-MM, or YYYY-MM-DD.
|
|
21
|
+
--no-expand Search the exact question without model expansion.
|
|
22
|
+
--no-graph Disable bounded graph-assisted candidate discovery.
|
|
23
|
+
--rerank Run configured retrieval reranking/qualification. Off by default.
|
|
24
|
+
--context Return the exact bounded evidence supplied to the answer model.
|
|
25
|
+
--max-answer-tokens <n>
|
|
26
|
+
Limit generated answer tokens for this call.
|
|
27
|
+
--json Machine-readable compact response.`;
|
|
28
|
+
export async function answerCommand(argv) {
|
|
29
|
+
const { values, positionals } = parse(argv, {
|
|
30
|
+
limit: { type: 'string' },
|
|
31
|
+
budget: { type: 'string' },
|
|
32
|
+
include: { type: 'string' },
|
|
33
|
+
folder: { type: 'string' },
|
|
34
|
+
type: { type: 'string' },
|
|
35
|
+
tag: { type: 'string' },
|
|
36
|
+
source: { type: 'string' },
|
|
37
|
+
ownership: { type: 'string' },
|
|
38
|
+
since: { type: 'string' },
|
|
39
|
+
until: { type: 'string' },
|
|
40
|
+
expand: { type: 'boolean', default: true },
|
|
41
|
+
graph: { type: 'boolean', default: true },
|
|
42
|
+
rerank: { type: 'boolean', default: false },
|
|
43
|
+
context: { type: 'boolean', default: false },
|
|
44
|
+
'max-answer-tokens': { type: 'string' },
|
|
45
|
+
});
|
|
46
|
+
if (values.help || positionals.length === 0) {
|
|
47
|
+
line(ANSWER_HELP);
|
|
48
|
+
return values.help ? 0 : 1;
|
|
49
|
+
}
|
|
50
|
+
const filter = {
|
|
51
|
+
...(values.folder ? { folder: values.folder } : {}),
|
|
52
|
+
...(values.type ? { type: values.type } : {}),
|
|
53
|
+
...(values.tag ? { tags: splitList(values.tag) } : {}),
|
|
54
|
+
...(values.source ? { source: values.source } : {}),
|
|
55
|
+
...(values.ownership ? { ownership: values.ownership } : {}),
|
|
56
|
+
};
|
|
57
|
+
const handle = await resolveOps(values, openOptionsFrom(values));
|
|
58
|
+
try {
|
|
59
|
+
const result = await handle.ops.answer({
|
|
60
|
+
question: positionals.join(' '),
|
|
61
|
+
...(values.limit ? { limit: Number(values.limit) } : {}),
|
|
62
|
+
...(values.budget ? { retrieval_budget: Number(values.budget) } : {}),
|
|
63
|
+
...(values.include ? { include: splitList(values.include) } : {}),
|
|
64
|
+
...(Object.keys(filter).length > 0 ? { filter } : {}),
|
|
65
|
+
...(values.since ? { since: values.since } : {}),
|
|
66
|
+
...(values.until ? { until: values.until } : {}),
|
|
67
|
+
expand: values.expand,
|
|
68
|
+
graph: values.graph,
|
|
69
|
+
rerank: values.rerank,
|
|
70
|
+
include_context: values.context,
|
|
71
|
+
...(values['max-answer-tokens'] ? { max_answer_tokens: Number(values['max-answer-tokens']) } : {}),
|
|
72
|
+
});
|
|
73
|
+
if (values.json)
|
|
74
|
+
json(result);
|
|
75
|
+
else
|
|
76
|
+
printAnswer(result);
|
|
77
|
+
return result.status === 'unavailable' ? 1 : 0;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await handle.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function printAnswer(result) {
|
|
84
|
+
line(`${statusLabel(result.status)} ${style.grey(`outcome=${result.outcome}`)} ` +
|
|
85
|
+
style.grey(`${result.related_page_slugs.length} related page(s), ` +
|
|
86
|
+
`${result.related_documents.length} related document(s)`));
|
|
87
|
+
if (result.degraded?.length)
|
|
88
|
+
line(style.yellow(` degraded: ${result.degraded.join(', ')}`));
|
|
89
|
+
if (result.answer)
|
|
90
|
+
line(`\n${result.answer}`);
|
|
91
|
+
else if (result.note)
|
|
92
|
+
line(style.grey(` ${result.note}`));
|
|
93
|
+
if (result.citations.length > 0) {
|
|
94
|
+
heading('Citations');
|
|
95
|
+
for (const citation of result.citations) {
|
|
96
|
+
if (citation.type === 'page')
|
|
97
|
+
line(` ${citation.slug}:${citation.lines.join(',')}`);
|
|
98
|
+
else {
|
|
99
|
+
const pages = citation.pages?.length ? ` pages ${citation.pages.join(',')}` : '';
|
|
100
|
+
line(` ${citation.document_id}${pages}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (result.related_page_slugs.length > 0) {
|
|
105
|
+
heading('Related pages');
|
|
106
|
+
for (const slug of result.related_page_slugs)
|
|
107
|
+
line(` ${slug}`);
|
|
108
|
+
}
|
|
109
|
+
if (result.related_documents.length > 0) {
|
|
110
|
+
heading('Related documents');
|
|
111
|
+
for (const document of result.related_documents) {
|
|
112
|
+
line(` ${document.id}${document.owner_slug ? ` (${document.owner_slug})` : ''}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (result.context?.length) {
|
|
116
|
+
heading('Context');
|
|
117
|
+
for (const item of result.context) {
|
|
118
|
+
if (item.type === 'page') {
|
|
119
|
+
line(` ${item.evidence_id} · ${item.slug} — ${item.title}`);
|
|
120
|
+
for (const sourceLine of item.lines)
|
|
121
|
+
line(` ${sourceLine.n}: ${sourceLine.text}`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const pages = item.pages?.length ? ` pages ${item.pages.join(',')}` : '';
|
|
125
|
+
line(` ${item.evidence_id} · ${item.document_id}${pages}`);
|
|
126
|
+
line(` ${item.quote}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const missing = Object.entries(result.coverage).filter(([, covered]) => !covered);
|
|
131
|
+
if (missing.length > 0) {
|
|
132
|
+
line(style.yellow(`\n uncovered: ${missing.map(([concept]) => concept).join(', ')}`));
|
|
133
|
+
}
|
|
134
|
+
if (result.searched.length > 1 || result.outcome === 'not_found') {
|
|
135
|
+
line(`\n${style.grey(`searched: ${result.searched.map((query) => `"${query}"`).join(', ')}`)}`);
|
|
136
|
+
}
|
|
137
|
+
const calls = Object.entries(result.model_usage).filter((entry) => entry[1] !== null);
|
|
138
|
+
if (calls.length > 0) {
|
|
139
|
+
line(style.grey(`model usage: ${calls
|
|
140
|
+
.map(([name, receipt]) => `${name} ${receipt.total_tokens === null ? 'tokens unreported' : `${receipt.total_tokens} tokens`}/${receipt.latency_ms}ms`)
|
|
141
|
+
.join(', ')}`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function splitList(value) {
|
|
145
|
+
return value
|
|
146
|
+
.split(',')
|
|
147
|
+
.map((entry) => entry.trim())
|
|
148
|
+
.filter(Boolean);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=answer-cmd.js.map
|