@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
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createInterface } from 'node:readline/promises';
|
|
4
|
+
const OPERATIONAL_FOLDERS = new Set(['inbox', 'journal', 'node_modules', 'observations', 'timeline']);
|
|
5
|
+
export function terminalInitPrompt(input = process.stdin, output = process.stdout) {
|
|
6
|
+
const terminal = createInterface({ input, output, terminal: true });
|
|
7
|
+
return {
|
|
8
|
+
ask: (question) => terminal.question(question),
|
|
9
|
+
say: (message) => output.write(`${message}\n`),
|
|
10
|
+
close: () => terminal.close(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export async function collectInteractiveInitAnswers(prompt, options) {
|
|
14
|
+
prompt.say('Akno guided setup');
|
|
15
|
+
prompt.say('The recommended setup uses one OpenAI endpoint and credential with two model IDs.');
|
|
16
|
+
prompt.say('Setup writes only the machine configuration; it does not modify the knowledge base.');
|
|
17
|
+
const aknoPath = await knowledgeBasePath(prompt, options.aknoPath, options.readablePath);
|
|
18
|
+
let setup = options.setup;
|
|
19
|
+
if (!setup) {
|
|
20
|
+
prompt.say('Choose a model setup:');
|
|
21
|
+
prompt.say(' 1. OpenAI minimum (recommended: embeddings + GPT-5.6 Luna)');
|
|
22
|
+
prompt.say(' 2. No models (lexical retrieval; no content is sent to a model)');
|
|
23
|
+
prompt.say(' 3. Specialist/manual roles (preserve them and configure the model blocks yourself)');
|
|
24
|
+
const selected = await choice(prompt, 'Model setup [1]: ', ['1', '2', '3'], '1');
|
|
25
|
+
setup = selected === '1' ? 'openai-luna' : selected === '2' ? 'no-model' : 'manual';
|
|
26
|
+
}
|
|
27
|
+
let maintenance;
|
|
28
|
+
if (options.maintenance) {
|
|
29
|
+
maintenance = options.maintenance;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
prompt.say('How will this memory be used?');
|
|
33
|
+
prompt.say(' 1. Connected to a trusted agent (recommended: autonomous maintenance)');
|
|
34
|
+
prompt.say(' 2. Standalone or human-reviewed (recommended: review maintenance)');
|
|
35
|
+
prompt.say(' 3. Read-only evaluation (recommended: audit maintenance)');
|
|
36
|
+
const usage = await choice(prompt, 'Usage [1]: ', ['1', '2', '3'], '1');
|
|
37
|
+
const recommended = usage === '1' ? 'autonomous' : usage === '2' ? 'review' : 'audit';
|
|
38
|
+
maintenance = await choice(prompt, `Maintenance profile [${recommended}]: `, ['audit', 'review', 'autonomous'], recommended);
|
|
39
|
+
}
|
|
40
|
+
const folderSetup = await collectInteractiveFolderSetup(prompt, {
|
|
41
|
+
aknoPath,
|
|
42
|
+
maintenance,
|
|
43
|
+
configExists: options.configExists ?? false,
|
|
44
|
+
});
|
|
45
|
+
return { aknoPath, setup, maintenance, ...(folderSetup ? { folderSetup } : {}) };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Make fact-injection authority an explicit setup choice. Discovery reads only immediate directory names;
|
|
49
|
+
* it does not inspect page text, and setup writes only the machine configuration.
|
|
50
|
+
*/
|
|
51
|
+
export async function collectInteractiveFolderSetup(prompt, options) {
|
|
52
|
+
if (options.configExists &&
|
|
53
|
+
!(await confirmInitAction(prompt, 'Review folder write boundaries and remember fallback now?', false))) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const folders = discoverSetupFolders(options.aknoPath);
|
|
57
|
+
prompt.say('Choose where remembered facts may be written. Setup reads folder names only.');
|
|
58
|
+
if (folders.length > 0) {
|
|
59
|
+
prompt.say('Top-level folders:');
|
|
60
|
+
folders.forEach((folder, index) => prompt.say(` ${index + 1}. ${folder}/`));
|
|
61
|
+
prompt.say('Unselected folders become searchable read-only knowledge; their files stay intact.');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
prompt.say('No classifiable top-level folders were found; existing and future folders remain read-only.');
|
|
65
|
+
}
|
|
66
|
+
const managed = folders.length > 0
|
|
67
|
+
? await folderSelection(prompt, 'Managed-memory folders (numbers; blank = none): ', folders)
|
|
68
|
+
: new Set();
|
|
69
|
+
const source = folders.length > 0
|
|
70
|
+
? await folderSelection(prompt, 'Source/reference folders (remaining numbers; blank = none): ', folders, managed)
|
|
71
|
+
: new Set();
|
|
72
|
+
const rules = {};
|
|
73
|
+
const counts = { managed: 0, readOnly: 0, source: 0 };
|
|
74
|
+
folders.forEach((folder, index) => {
|
|
75
|
+
const key = `${folder}/**`;
|
|
76
|
+
if (managed.has(index)) {
|
|
77
|
+
rules[key] = { role: 'knowledge', remember: 'integrate' };
|
|
78
|
+
counts.managed++;
|
|
79
|
+
}
|
|
80
|
+
else if (source.has(index)) {
|
|
81
|
+
rules[key] = { role: 'source', remember: 'deny' };
|
|
82
|
+
counts.source++;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
rules[key] = { role: 'knowledge', remember: 'deny' };
|
|
86
|
+
counts.readOnly++;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
prompt.say('A remember fallback is a last-resort managed page. It is used only after normal routing and cannot make other folders writable.');
|
|
90
|
+
const useFallback = await confirmInitAction(prompt, 'Configure a managed fallback page?', options.maintenance === 'autonomous');
|
|
91
|
+
if (!useFallback)
|
|
92
|
+
return { rules, fallbackPage: null, counts };
|
|
93
|
+
const fallbackPage = await fallbackPagePrompt(prompt);
|
|
94
|
+
const parent = fallbackPage.slice(0, fallbackPage.lastIndexOf('/'));
|
|
95
|
+
const parentGlob = `${parent}/**`;
|
|
96
|
+
const parentRule = rules[parentGlob];
|
|
97
|
+
if (!parentRule || parentRule.remember !== 'integrate') {
|
|
98
|
+
rules[parentGlob] = { role: 'knowledge', remember: 'integrate' };
|
|
99
|
+
counts.managed++;
|
|
100
|
+
if (parentRule?.role === 'source')
|
|
101
|
+
counts.source--;
|
|
102
|
+
else if (parentRule)
|
|
103
|
+
counts.readOnly--;
|
|
104
|
+
prompt.say(`${parent}/ is now an explicit managed-memory namespace for that fallback.`);
|
|
105
|
+
}
|
|
106
|
+
return { rules, fallbackPage, counts };
|
|
107
|
+
}
|
|
108
|
+
export async function confirmInitAction(prompt, question, defaultValue) {
|
|
109
|
+
const suffix = defaultValue ? ' [Y/n]: ' : ' [y/N]: ';
|
|
110
|
+
while (true) {
|
|
111
|
+
const answer = (await prompt.ask(`${question}${suffix}`)).trim().toLowerCase();
|
|
112
|
+
if (!answer)
|
|
113
|
+
return defaultValue;
|
|
114
|
+
if (answer === 'y' || answer === 'yes')
|
|
115
|
+
return true;
|
|
116
|
+
if (answer === 'n' || answer === 'no')
|
|
117
|
+
return false;
|
|
118
|
+
prompt.say('Enter yes or no.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function knowledgeBasePath(prompt, initialValue, readablePath) {
|
|
122
|
+
let candidate = initialValue?.trim() ?? '';
|
|
123
|
+
while (true) {
|
|
124
|
+
if (!candidate)
|
|
125
|
+
candidate = (await prompt.ask('Knowledge-base folder: ')).trim();
|
|
126
|
+
if (candidate && readablePath(candidate))
|
|
127
|
+
return candidate;
|
|
128
|
+
prompt.say(candidate ? `Folder is not readable: ${candidate}` : 'A knowledge-base folder is required.');
|
|
129
|
+
candidate = '';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function choice(prompt, question, allowed, defaultValue) {
|
|
133
|
+
while (true) {
|
|
134
|
+
const answer = (await prompt.ask(question)).trim().toLowerCase();
|
|
135
|
+
if (!answer)
|
|
136
|
+
return defaultValue;
|
|
137
|
+
const selected = allowed.find((value) => value === answer);
|
|
138
|
+
if (selected)
|
|
139
|
+
return selected;
|
|
140
|
+
prompt.say(`Choose one of: ${allowed.join(', ')}.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** Immediate visible directories only; hidden and Akno-owned operational paths are not policy candidates. */
|
|
144
|
+
export function discoverSetupFolders(aknoPath) {
|
|
145
|
+
return fs
|
|
146
|
+
.readdirSync(aknoPath, { withFileTypes: true })
|
|
147
|
+
.filter((entry) => entry.isDirectory() &&
|
|
148
|
+
!entry.name.startsWith('.') &&
|
|
149
|
+
!OPERATIONAL_FOLDERS.has(entry.name.toLowerCase()))
|
|
150
|
+
.map((entry) => entry.name)
|
|
151
|
+
.sort((left, right) => left.localeCompare(right));
|
|
152
|
+
}
|
|
153
|
+
async function folderSelection(prompt, question, folders, unavailable = new Set()) {
|
|
154
|
+
while (true) {
|
|
155
|
+
const answer = (await prompt.ask(question)).trim().toLowerCase();
|
|
156
|
+
if (!answer || answer === 'none')
|
|
157
|
+
return new Set();
|
|
158
|
+
const values = answer === 'all'
|
|
159
|
+
? folders.flatMap((_, index) => (unavailable.has(index) ? [] : [index + 1]))
|
|
160
|
+
: answer.split(',').map(Number);
|
|
161
|
+
const invalid = values.some((value) => !Number.isInteger(value) || value < 1 || value > folders.length || unavailable.has(value - 1));
|
|
162
|
+
if (!invalid)
|
|
163
|
+
return new Set(values.map((value) => value - 1));
|
|
164
|
+
prompt.say(unavailable.size > 0
|
|
165
|
+
? 'Choose comma-separated remaining folder numbers, all, or none.'
|
|
166
|
+
: 'Choose comma-separated folder numbers, all, or none.');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async function fallbackPagePrompt(prompt) {
|
|
170
|
+
while (true) {
|
|
171
|
+
const answer = (await prompt.ask('Fallback page [memory/inbox]: ')).trim();
|
|
172
|
+
const value = answer || 'memory/inbox';
|
|
173
|
+
if (safeFallbackPage(value))
|
|
174
|
+
return value;
|
|
175
|
+
prompt.say('Use a relative page slug inside a folder, without an extension or dot segments.');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function safeFallbackPage(value) {
|
|
179
|
+
const segments = value.split('/');
|
|
180
|
+
return (value === value.trim() &&
|
|
181
|
+
value.includes('/') &&
|
|
182
|
+
!path.isAbsolute(value) &&
|
|
183
|
+
!value.startsWith('~') &&
|
|
184
|
+
!/^[a-zA-Z]:/.test(value) &&
|
|
185
|
+
!/\.(?:md|markdown)$/i.test(value) &&
|
|
186
|
+
!value.includes('\\') &&
|
|
187
|
+
!value.includes('\0') &&
|
|
188
|
+
value.length <= 512 &&
|
|
189
|
+
segments.every((segment) => segment.length > 0 && !segment.startsWith('.')) &&
|
|
190
|
+
!OPERATIONAL_FOLDERS.has(segments[0].toLowerCase()));
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=init-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-prompts.js","sourceRoot":"","sources":["../../src/commands/init-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIzD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;AAwCtG,MAAM,UAAU,kBAAkB,CAChC,QAAkB,OAAO,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AAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3E,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-cmd.d.ts","sourceRoot":"","sources":["../../src/commands/list-cmd.ts"],"names":[],"mappings":"AAkBA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8EjE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { openOptionsFrom, parse } from "../args.js";
|
|
2
|
+
import { heading, json, line, style, truncate } from "../output.js";
|
|
3
|
+
import { resolveOps } from "../ops-handle.js";
|
|
4
|
+
const LIST_HELP = `akno list [options]
|
|
5
|
+
|
|
6
|
+
Browse structure. Folders by default; pages when a filter is given.
|
|
7
|
+
|
|
8
|
+
--kind <k> folders | pages | tree
|
|
9
|
+
--folder <path> Scope to a folder.
|
|
10
|
+
--type <t> Filter pages by frontmatter type.
|
|
11
|
+
--tag <t> Filter pages by tag.
|
|
12
|
+
--role <r> knowledge | source | inference | ignored
|
|
13
|
+
--order <o> recent | slug | size
|
|
14
|
+
--depth <n> Tree depth.
|
|
15
|
+
--limit <n>
|
|
16
|
+
--json`;
|
|
17
|
+
export async function listCommand(argv) {
|
|
18
|
+
const { values } = parse(argv, {
|
|
19
|
+
kind: { type: 'string' },
|
|
20
|
+
folder: { type: 'string' },
|
|
21
|
+
type: { type: 'string' },
|
|
22
|
+
tag: { type: 'string' },
|
|
23
|
+
role: { type: 'string' },
|
|
24
|
+
order: { type: 'string' },
|
|
25
|
+
depth: { type: 'string' },
|
|
26
|
+
limit: { type: 'string' },
|
|
27
|
+
});
|
|
28
|
+
if (values.help) {
|
|
29
|
+
line(LIST_HELP);
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
const handle = await resolveOps(values, openOptionsFrom(values));
|
|
33
|
+
try {
|
|
34
|
+
const result = await handle.ops.list({
|
|
35
|
+
...(values.kind ? { kind: values.kind } : {}),
|
|
36
|
+
...(values.folder ? { folder: values.folder } : {}),
|
|
37
|
+
...(values.type ? { type: values.type } : {}),
|
|
38
|
+
...(values.tag ? { tag: values.tag } : {}),
|
|
39
|
+
...(values.role ? { role: values.role } : {}),
|
|
40
|
+
...(values.order ? { order: values.order } : {}),
|
|
41
|
+
...(values.depth ? { depth: Number(values.depth) } : {}),
|
|
42
|
+
...(values.limit ? { limit: Number(values.limit) } : {}),
|
|
43
|
+
});
|
|
44
|
+
if (values.json) {
|
|
45
|
+
json(result);
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
if (result.tree) {
|
|
49
|
+
line(result.tree);
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
if (result.folders) {
|
|
53
|
+
heading(`${result.total} folder${result.total === 1 ? '' : 's'}`);
|
|
54
|
+
const width = Math.max(8, ...result.folders.map((f) => f.path.length));
|
|
55
|
+
for (const folder of result.folders) {
|
|
56
|
+
const rule = folder.rule ? style.grey(` ${folder.rule.role ?? ''} ← ${folder.rule.source}`) : '';
|
|
57
|
+
line(` ${folder.path.padEnd(width)} ${style.grey(`${folder.pages_deep} pages`)}` +
|
|
58
|
+
`${folder.folders > 0 ? style.grey(`, ${folder.folders} folders`) : ''}${rule}`);
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
const pages = result.pages ?? [];
|
|
63
|
+
heading(`${result.total} page${result.total === 1 ? '' : 's'}${pages.length < result.total ? ` (showing ${pages.length})` : ''}`);
|
|
64
|
+
const width = Math.max(8, ...pages.map((p) => p.slug.length));
|
|
65
|
+
for (const page of pages) {
|
|
66
|
+
line(` ${page.slug.padEnd(width)} ${style.grey(page.role.padEnd(9))}` +
|
|
67
|
+
`${style.grey((page.updated ?? '').padEnd(11))}${truncate(page.summary ?? page.title, 70)}`);
|
|
68
|
+
}
|
|
69
|
+
if (result.status === 'empty')
|
|
70
|
+
line(style.yellow(' nothing matched'));
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await handle.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=list-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-cmd.js","sourceRoot":"","sources":["../../src/commands/list-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,SAAS,GAAG;;;;;;;;;;;;SAYT,CAAC;AAEV,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAc;IAC9C,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CASrB,IAAI,EAAE;QACP,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1B,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,CAAC,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,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core';
|
|
2
|
+
/** Human view of the same typed explanation returned by --json and the service. */
|
|
3
|
+
export declare function printMaintenancePathPolicy(policy: MaintenancePathPolicy): void;
|
|
4
|
+
//# sourceMappingURL=maintenance-policy-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance-policy-output.d.ts","sourceRoot":"","sources":["../../src/commands/maintenance-policy-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAkC,MAAM,mBAAmB,CAAC;AAG/F,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAyC9E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { heading, kv, line, style } from "../output.js";
|
|
2
|
+
/** Human view of the same typed explanation returned by --json and the service. */
|
|
3
|
+
export function printMaintenancePathPolicy(policy) {
|
|
4
|
+
heading(`Maintenance policy — ${policy.slug}`);
|
|
5
|
+
kv([
|
|
6
|
+
['profile', policy.profile],
|
|
7
|
+
['run ceiling', policy.runMode],
|
|
8
|
+
['path state', policy.state.replaceAll('_', ' ')],
|
|
9
|
+
['page role', `${policy.page.role} (${policy.page.roleSource.replaceAll('_', ' ')})`],
|
|
10
|
+
['dream opt-in', `${policy.page.dream} (${policy.page.dreamSource})`],
|
|
11
|
+
['remember', `${policy.page.remember} (${policy.page.rememberSource.replaceAll('_', ' ')})`],
|
|
12
|
+
['reserved', policy.page.reserved ? 'yes' : 'no'],
|
|
13
|
+
[
|
|
14
|
+
'maintenance model',
|
|
15
|
+
policy.maintenanceModel.configured
|
|
16
|
+
? `${policy.maintenanceModel.id ?? 'configured'} (configured; health not probed)`
|
|
17
|
+
: 'not configured',
|
|
18
|
+
],
|
|
19
|
+
]);
|
|
20
|
+
line('\n page-targeted transformations');
|
|
21
|
+
const width = Math.max(...policy.transformations.map((entry) => entry.kind.length));
|
|
22
|
+
for (const entry of policy.transformations)
|
|
23
|
+
printTransform(entry, width);
|
|
24
|
+
line('\n path-independent transformations');
|
|
25
|
+
for (const entry of policy.pathIndependent) {
|
|
26
|
+
const enabled = entry.enabled && entry.policy !== 'off';
|
|
27
|
+
line(` ${entry.kind.padEnd(width)} ${enabled ? entry.policy : 'off'} ${style.grey(entry.reason)}`);
|
|
28
|
+
}
|
|
29
|
+
line('\n whole-run apply limits');
|
|
30
|
+
kv([
|
|
31
|
+
['items', policy.limits.maxItems],
|
|
32
|
+
['changed files', policy.limits.maxFilesChanged],
|
|
33
|
+
['written bytes', policy.limits.maxBytesWritten],
|
|
34
|
+
['high-risk items', policy.limits.maxHighRiskItems],
|
|
35
|
+
], ' ');
|
|
36
|
+
line(`\n ${style.grey('still required for any proposal:')}`);
|
|
37
|
+
for (const check of policy.remainingChecks)
|
|
38
|
+
line(` ${style.grey(`• ${check}`)}`);
|
|
39
|
+
}
|
|
40
|
+
function printTransform(entry, width) {
|
|
41
|
+
const outcome = outcomeLabel(entry);
|
|
42
|
+
const color = entry.outcome === 'curator_then_apply'
|
|
43
|
+
? style.green
|
|
44
|
+
: entry.outcome === 'awaiting_human' || entry.outcome === 'audit_only'
|
|
45
|
+
? style.cyan
|
|
46
|
+
: entry.outcome === 'apply_blocked'
|
|
47
|
+
? style.yellow
|
|
48
|
+
: style.grey;
|
|
49
|
+
line(` ${entry.kind.padEnd(width)} ${entry.effectivePolicy.padEnd(6)} ${color(outcome)}`);
|
|
50
|
+
for (const blocker of entry.blockers)
|
|
51
|
+
line(` ${style.grey(`blocked: ${blocker.message}`)}`);
|
|
52
|
+
for (const blocker of entry.applyBlockers) {
|
|
53
|
+
line(` ${style.grey(`apply blocked: ${blocker.message}`)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function outcomeLabel(entry) {
|
|
57
|
+
switch (entry.outcome) {
|
|
58
|
+
case 'off':
|
|
59
|
+
return 'not inspected';
|
|
60
|
+
case 'ineligible':
|
|
61
|
+
return 'not eligible';
|
|
62
|
+
case 'audit_only':
|
|
63
|
+
return 'plan and report only';
|
|
64
|
+
case 'awaiting_human':
|
|
65
|
+
return 'plan, then wait for human approval';
|
|
66
|
+
case 'curator_then_apply':
|
|
67
|
+
return 'plan, independent curator, verified apply';
|
|
68
|
+
case 'apply_blocked':
|
|
69
|
+
return 'plan, but automatic apply is currently blocked';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=maintenance-policy-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance-policy-output.js","sourceRoot":"","sources":["../../src/commands/maintenance-policy-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAExD,mFAAmF;AACnF,MAAM,UAAU,0BAA0B,CAAC,MAA6B;IACtE,OAAO,CAAC,wBAAwB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,EAAE,CAAC;QACD,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC;QAC3B,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC;QAC/B,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjD,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;QACrF,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC;QACrE,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;QAC5F,CAAC,UAAU,EAAE,MAAM,CAAC,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,CAAC;IACnE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAqC;IACzD,QAAQ,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,eAAe,CAAC;QACzB,KAAK,YAAY;YACf,OAAO,cAAc,CAAC;QACxB,KAAK,YAAY;YACf,OAAO,sBAAsB,CAAC;QAChC,KAAK,gBAAgB;YACnB,OAAO,oCAAoC,CAAC;QAC9C,KAAK,oBAAoB;YACvB,OAAO,2CAA2C,CAAC;QACrD,KAAK,eAAe;YAClB,OAAO,gDAAgD,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function forgetCommand(argv: string[]): Promise<number>;
|
|
2
|
+
export declare function undoCommand(argv: string[]): Promise<number>;
|
|
3
|
+
export declare function moveCommand(argv: string[]): Promise<number>;
|
|
4
|
+
export declare function approveCommand(argv: string[], decline?: boolean): Promise<number>;
|
|
5
|
+
//# sourceMappingURL=mutate-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate-cmd.d.ts","sourceRoot":"","sources":["../../src/commands/mutate-cmd.ts"],"names":[],"mappings":"AAiBA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAwCnE;AAYD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDjE;AAaD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BjE;AAoBD,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ErF"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { openOptionsFrom, parse } from "../args.js";
|
|
2
|
+
import { heading, json, kv, line, statusLabel, style, truncate } from "../output.js";
|
|
3
|
+
import { printWriteOutcome } from "./write-cmd.js";
|
|
4
|
+
import { resolveOps, runMaintenance } from "../ops-handle.js";
|
|
5
|
+
const FORGET_HELP = `akno forget <--fact <id> | --slug <slug> | --document <id>>
|
|
6
|
+
|
|
7
|
+
Retract a fact by removing the sentence that produced it, or move a page or a
|
|
8
|
+
document to trash. Always journalled, always reversible with undo for the
|
|
9
|
+
retention window.
|
|
10
|
+
|
|
11
|
+
Removing a fact removes a line from a file. Expiring a row while the sentence
|
|
12
|
+
stays would mean forgetting it today and reading it again tomorrow.
|
|
13
|
+
|
|
14
|
+
--actor <who> user | agent
|
|
15
|
+
--json`;
|
|
16
|
+
export async function forgetCommand(argv) {
|
|
17
|
+
const { values } = parse(argv, {
|
|
18
|
+
fact: { type: 'string' },
|
|
19
|
+
slug: { type: 'string' },
|
|
20
|
+
document: { type: 'string' },
|
|
21
|
+
actor: { type: 'string' },
|
|
22
|
+
});
|
|
23
|
+
if (values.help || [values.fact, values.slug, values.document].filter(Boolean).length !== 1) {
|
|
24
|
+
line(FORGET_HELP);
|
|
25
|
+
return values.help ? 0 : 1;
|
|
26
|
+
}
|
|
27
|
+
const handle = await resolveOps(values, openOptionsFrom(values), {
|
|
28
|
+
write: true,
|
|
29
|
+
...(values.actor === 'user' || values.actor === 'agent' ? { actor: values.actor } : {}),
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const result = await handle.ops.forget({
|
|
33
|
+
...(values.fact ? { fact: values.fact } : {}),
|
|
34
|
+
...(values.slug ? { slug: values.slug } : {}),
|
|
35
|
+
...(values.document ? { document: values.document } : {}),
|
|
36
|
+
});
|
|
37
|
+
if (values.json) {
|
|
38
|
+
json(result);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
line(`${statusLabel(result.status)} ${style.grey(`change ${result.change_id}`)}`);
|
|
42
|
+
kv([
|
|
43
|
+
['from', result.removed_from],
|
|
44
|
+
['removed', result.removed ? truncate(result.removed, 84) : null],
|
|
45
|
+
['trashed to', result.trashed],
|
|
46
|
+
]);
|
|
47
|
+
line(`\n ${style.grey(`reverse with`)} ${style.bold(`akno undo ${result.change_id}`)}`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await handle.close();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const UNDO_HELP = `akno undo <change_id>
|
|
55
|
+
akno undo --list
|
|
56
|
+
|
|
57
|
+
Reverse a change. The id outlives the session, the process, and a full rebuild of
|
|
58
|
+
every table except the journal — which holds the previous bytes rather than a
|
|
59
|
+
pointer to them.
|
|
60
|
+
|
|
61
|
+
--list Recent changes, newest first.
|
|
62
|
+
--json`;
|
|
63
|
+
export async function undoCommand(argv) {
|
|
64
|
+
const { values, positionals } = parse(argv, {
|
|
65
|
+
list: { type: 'boolean', default: false },
|
|
66
|
+
limit: { type: 'string' },
|
|
67
|
+
});
|
|
68
|
+
if (values.help || (!values.list && positionals.length === 0)) {
|
|
69
|
+
line(UNDO_HELP);
|
|
70
|
+
return values.help ? 0 : 1;
|
|
71
|
+
}
|
|
72
|
+
if (values.list) {
|
|
73
|
+
// `changes` is not an op — an agent has no business reading the journal — so it travels on the
|
|
74
|
+
// command channel, which is also how it reaches a running service instead of failing beside it.
|
|
75
|
+
const changes = await runMaintenance('changes', { limit: values.limit ? Number(values.limit) : 20 }, values, openOptionsFrom(values), async (akno) => akno.changes(values.limit ? Number(values.limit) : 20), { writable: false });
|
|
76
|
+
{
|
|
77
|
+
if (values.json) {
|
|
78
|
+
json(changes);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
heading(`${changes.length} change${changes.length === 1 ? '' : 's'}`);
|
|
82
|
+
for (const change of changes) {
|
|
83
|
+
const state = change.status === 'undone' ? style.grey('undone ') : style.green('applied');
|
|
84
|
+
line(` ${style.bold(change.id)} ${state} ${change.at.slice(0, 19).replace('T', ' ')} ${change.summary}`);
|
|
85
|
+
line(style.grey(` ${change.actor}/${change.op} ${change.files.map((f) => `${f.action} ${f.relPath}`).join(', ')}`));
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const handle = await resolveOps(values, openOptionsFrom(values), { write: true });
|
|
91
|
+
try {
|
|
92
|
+
const result = await handle.ops.undo({ change_id: positionals[0] });
|
|
93
|
+
if (values.json) {
|
|
94
|
+
json(result);
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
line(`${statusLabel(result.status)} reversed ${style.bold(result.reversed ?? '')}`);
|
|
98
|
+
for (const file of result.restored ?? [])
|
|
99
|
+
line(` ${style.green('restored')} ${file}`);
|
|
100
|
+
for (const file of result.removed ?? [])
|
|
101
|
+
line(` ${style.yellow('removed ')} ${file}`);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
await handle.close();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const MOVE_HELP = `akno move <from> <to>
|
|
109
|
+
|
|
110
|
+
Relocate a page with its documents, rewriting the page's own embeds. Inbound
|
|
111
|
+
links from other pages are reported, never rewritten — editing half a dozen
|
|
112
|
+
other pages is a bigger change than the one you asked for.
|
|
113
|
+
|
|
114
|
+
The page keeps its id, so facts, events and journal history stay attached.
|
|
115
|
+
|
|
116
|
+
--actor <who> user | agent
|
|
117
|
+
--json`;
|
|
118
|
+
export async function moveCommand(argv) {
|
|
119
|
+
const { values, positionals } = parse(argv, { actor: { type: 'string' } });
|
|
120
|
+
if (values.help || positionals.length !== 2) {
|
|
121
|
+
line(MOVE_HELP);
|
|
122
|
+
return values.help ? 0 : 1;
|
|
123
|
+
}
|
|
124
|
+
const handle = await resolveOps(values, openOptionsFrom(values), {
|
|
125
|
+
write: true,
|
|
126
|
+
...(values.actor === 'user' || values.actor === 'agent' ? { actor: values.actor } : {}),
|
|
127
|
+
});
|
|
128
|
+
try {
|
|
129
|
+
const result = await handle.ops.move({ from: positionals[0], to: positionals[1] });
|
|
130
|
+
if (values.json) {
|
|
131
|
+
json(result);
|
|
132
|
+
return result.outcome === 'ok' ? 0 : 2;
|
|
133
|
+
}
|
|
134
|
+
if (result.outcome === 'requires_folder')
|
|
135
|
+
return printWriteOutcome(result);
|
|
136
|
+
line(`${statusLabel(result.status)} ${style.grey(`change ${result.change_id}`)}`);
|
|
137
|
+
for (const file of result.moved ?? [])
|
|
138
|
+
line(` ${style.green('moved')} ${file}`);
|
|
139
|
+
for (const slug of result.broken_inbound ?? []) {
|
|
140
|
+
line(` ${style.yellow('still links to the old slug')} ${slug}`);
|
|
141
|
+
}
|
|
142
|
+
if (result.note)
|
|
143
|
+
line(style.grey(`\n ${result.note}`));
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await handle.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const APPROVE_HELP = `akno approve <proposal_id> [--slug <page>]
|
|
151
|
+
akno approve --list
|
|
152
|
+
akno decline <proposal_id>
|
|
153
|
+
|
|
154
|
+
Resolve a gated proposal. Approving applies the write that was held with it, so
|
|
155
|
+
the caller does not have to repeat it.
|
|
156
|
+
|
|
157
|
+
--slug <page> Where to write it. Required for a \`route\` proposal, which exists
|
|
158
|
+
because nothing scored high enough to choose a page — "approved"
|
|
159
|
+
with no destination is not an answer to that question. \`--list\`
|
|
160
|
+
shows the nearest candidates; naming a page that does not exist
|
|
161
|
+
yet creates it, which is often the right answer.
|
|
162
|
+
|
|
163
|
+
A declined proposal is remembered: an agent that asks for the same folder again
|
|
164
|
+
gets the refusal back instead of a second question.
|
|
165
|
+
|
|
166
|
+
--json`;
|
|
167
|
+
export async function approveCommand(argv, decline = false) {
|
|
168
|
+
const { values, positionals } = parse(argv, {
|
|
169
|
+
list: { type: 'boolean', default: false },
|
|
170
|
+
slug: { type: 'string' },
|
|
171
|
+
});
|
|
172
|
+
if (values.help || (!values.list && positionals.length === 0)) {
|
|
173
|
+
line(APPROVE_HELP);
|
|
174
|
+
return values.help ? 0 : 1;
|
|
175
|
+
}
|
|
176
|
+
// Approving is the user speaking, by definition — it is the answer to a gate that only exists for
|
|
177
|
+
// agents. It travels on the command channel rather than the op surface for the same reason: an
|
|
178
|
+
// agent that could call `approve` could wave through its own gated proposal.
|
|
179
|
+
if (values.list) {
|
|
180
|
+
const pending = await runMaintenance('proposals', {}, values, openOptionsFrom(values), async (akno) => akno.proposals(), { writable: false });
|
|
181
|
+
{
|
|
182
|
+
if (values.json) {
|
|
183
|
+
json(pending);
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
if (pending.length === 0) {
|
|
187
|
+
line(style.grey('nothing waiting'));
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
heading(`${pending.length} waiting`);
|
|
191
|
+
for (const proposal of pending) {
|
|
192
|
+
line(` ${style.bold(proposal.id)} ${style.grey(proposal.kind)} ${proposal.reason}`);
|
|
193
|
+
const nearest = JSON.parse(proposal.nearest);
|
|
194
|
+
if (nearest.length > 0)
|
|
195
|
+
line(style.grey(` could go instead: ${nearest.join(', ')}`));
|
|
196
|
+
}
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
{
|
|
201
|
+
if (decline) {
|
|
202
|
+
const result = await runMaintenance('decline', { proposal_id: positionals[0] }, values, openOptionsFrom(values), async (akno) => akno.decline(positionals[0]));
|
|
203
|
+
if (values.json) {
|
|
204
|
+
json(result);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
line(`${statusLabel('ok')} declined ${style.grey(result.subject)}`);
|
|
208
|
+
line(style.grey(' remembered, so an agent asking again gets the refusal rather than a second question'));
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
const result = await runMaintenance('approve', { proposal_id: positionals[0], ...(values.slug ? { slug: values.slug } : {}) }, values, openOptionsFrom(values), async (akno) => akno.approve(positionals[0], values.slug ? { slug: values.slug } : {}));
|
|
212
|
+
if (values.json) {
|
|
213
|
+
json(result);
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
line(`${statusLabel('ok')} approved ${style.grey(result.subject)}`);
|
|
217
|
+
// The write that was held with the proposal has just run, so report it the
|
|
218
|
+
// same way `akno write` would.
|
|
219
|
+
if (result.write)
|
|
220
|
+
return printWriteOutcome(result.write);
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=mutate-cmd.js.map
|