@prestack/thread 0.0.2 → 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/CHANGELOG.md +98 -0
- package/dist/core/{asking.d.ts → answers.d.ts} +6 -14
- package/dist/core/{asking.js → answers.js} +13 -332
- package/dist/core/{asking.ts → answers.ts} +14 -357
- package/dist/core/attach.js +2 -2
- package/dist/core/attach.ts +2 -3
- package/dist/core/chain.js +4 -11
- package/dist/core/chain.ts +4 -3
- package/dist/core/client.d.ts +57 -0
- package/dist/core/client.js +186 -0
- package/dist/core/client.ts +227 -0
- package/dist/core/descend.d.ts +2 -0
- package/dist/core/descend.js +109 -16
- package/dist/core/descend.ts +120 -16
- package/dist/core/files.d.ts +45 -0
- package/dist/core/files.js +95 -0
- package/dist/core/files.ts +137 -0
- package/dist/core/init.d.ts +1 -0
- package/dist/core/init.js +10 -2
- package/dist/core/init.ts +8 -2
- package/dist/core/invoked.js +1 -1
- package/dist/core/invoked.ts +1 -1
- package/dist/core/rows.d.ts +2 -0
- package/dist/core/rows.js +65 -0
- package/dist/core/rows.ts +58 -0
- package/dist/core/tree.js +1 -1
- package/dist/core/tree.ts +1 -1
- package/dist/derivation/attach.js +0 -12
- package/dist/derivation/attach.ts +0 -12
- package/dist/derivation/generators/build.js +8 -7
- package/dist/derivation/generators/build.ts +8 -7
- package/dist/derivation/generators/release.d.ts +1 -1
- package/dist/derivation/generators/release.js +15 -23
- package/dist/derivation/generators/release.ts +15 -15
- package/dist/integrations/attach.js +1 -19
- package/dist/integrations/attach.ts +1 -19
- package/dist/integrations/generators/read.js +2 -2
- package/dist/integrations/generators/read.ts +4 -4
- package/dist/integrations/generators/vault.js +4 -12
- package/dist/integrations/generators/vault.ts +4 -4
- package/dist/integrations/module.js +5 -3
- package/dist/integrations/module.ts +5 -3
- package/dist/integrations/vault.js +5 -5
- package/dist/integrations/vault.ts +5 -5
- package/dist/integrity/attach.js +0 -12
- package/dist/integrity/attach.ts +0 -12
- package/dist/integrity/check-threads.js +1 -1
- package/dist/integrity/check-threads.ts +1 -1
- package/dist/integrity/constraint.d.ts +11 -2
- package/dist/integrity/constraint.js +163 -20
- package/dist/integrity/constraint.ts +174 -22
- package/dist/integrity/generators/compiler.js +1 -1
- package/dist/integrity/generators/compiler.ts +1 -1
- package/dist/integrity/generators/gate.js +8 -16
- package/dist/integrity/generators/gate.ts +8 -7
- package/dist/integrity/generators/publish.js +14 -26
- package/dist/integrity/generators/publish.ts +14 -17
- package/dist/integrity/generators/trial.d.ts +2 -2
- package/dist/integrity/generators/trial.js +108 -50
- package/dist/integrity/generators/trial.ts +107 -48
- package/dist/integrity/lint.js +3 -3
- package/dist/integrity/lint.ts +3 -3
- package/dist/integrity/lsp/diagnostics.js +1 -1
- package/dist/integrity/lsp/diagnostics.ts +1 -1
- package/dist/integrity/lsp/lint.js +1 -1
- package/dist/integrity/lsp/lint.ts +1 -1
- package/dist/integrity/slopnator.d.ts +1 -14
- package/dist/integrity/slopnator.js +8 -40
- package/dist/integrity/slopnator.ts +9 -51
- package/dist/integrity/slopnators/sl_broken_lineage.js +4 -2
- package/dist/integrity/slopnators/sl_broken_lineage.ts +4 -2
- package/dist/integrity/slopnators/sl_declared_elsewhere.js +24 -3
- package/dist/integrity/slopnators/sl_declared_elsewhere.ts +24 -3
- package/dist/integrity/slopnators/sl_derived_drift.js +10 -4
- package/dist/integrity/slopnators/sl_derived_drift.ts +10 -4
- package/dist/integrity/slopnators/sl_inert_island.js +7 -13
- package/dist/integrity/slopnators/sl_inert_island.ts +7 -16
- package/dist/integrity/slopnators/sl_inert_slopnator.js +8 -8
- package/dist/integrity/slopnators/sl_inert_slopnator.ts +8 -8
- package/dist/integrity/slopnators/sl_missing_row.js +14 -9
- package/dist/integrity/slopnators/sl_missing_row.ts +14 -10
- package/dist/integrity/slopnators/sl_no_child_process.js +8 -8
- package/dist/integrity/slopnators/sl_no_child_process.ts +8 -8
- package/dist/integrity/slopnators/sl_no_import_cycle.js +1 -1
- package/dist/integrity/slopnators/sl_no_import_cycle.ts +1 -1
- package/dist/integrity/slopnators/sl_no_such_command.js +20 -5
- package/dist/integrity/slopnators/sl_no_such_command.ts +22 -5
- package/dist/integrity/slopnators/sl_only_takes_a_literal.js +8 -8
- package/dist/integrity/slopnators/sl_only_takes_a_literal.ts +8 -8
- package/dist/integrity/slopnators/sl_stale_path.js +91 -18
- package/dist/integrity/slopnators/sl_stale_path.ts +97 -18
- package/dist/integrity/slopnators/sl_twice_meant.js +25 -2
- package/dist/integrity/slopnators/sl_twice_meant.ts +28 -2
- package/dist/integrity/slopnators/sl_twice_parented.js +26 -5
- package/dist/integrity/slopnators/sl_twice_parented.ts +26 -5
- package/dist/integrity/slopnators/sl_undeclared_node.js +18 -2
- package/dist/integrity/slopnators/sl_undeclared_node.ts +18 -2
- package/dist/integrity/slopnators/sl_undeclared_operation.js +3 -1
- package/dist/integrity/slopnators/sl_undeclared_operation.ts +3 -1
- package/dist/integrity/slopnators/sl_undeclared_variant.js +6 -2
- package/dist/integrity/slopnators/sl_undeclared_variant.ts +6 -2
- package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -4
- package/dist/integrity/slopnators/sl_ungoverned_island.ts +3 -4
- package/dist/integrity/slopnators/sl_unkept_rows.js +1 -1
- package/dist/integrity/slopnators/sl_unkept_rows.ts +1 -1
- package/dist/integrity/slopnators/sl_unpaired_member.js +13 -8
- package/dist/integrity/slopnators/sl_unpaired_member.ts +16 -8
- package/dist/integrity/slopnators/sl_unpaired_slopnator.js +16 -3
- package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +16 -3
- package/dist/integrity/slopnators/sl_unthreaded.d.ts +1 -0
- package/dist/integrity/slopnators/sl_unthreaded.js +18 -10
- package/dist/integrity/slopnators/sl_unthreaded.ts +19 -11
- package/dist/integrity/slopnators/sl_untranslated_key.js +1 -1
- package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -1
- package/dist/integrity/slopnators/sl_unversioned.js +16 -2
- package/dist/integrity/slopnators/sl_unversioned.ts +16 -2
- package/dist/integrity/sweep.js +17 -3
- package/dist/integrity/sweep.ts +20 -3
- package/dist/knowledge/attach.js +0 -6
- package/dist/knowledge/attach.ts +0 -6
- package/dist/knowledge/generators/docsgen.js +12 -3
- package/dist/knowledge/generators/docsgen.ts +12 -2
- package/dist/knowledge/generators/glossary.js +1 -1
- package/dist/knowledge/generators/glossary.ts +1 -1
- package/dist/operations/attach.js +2 -26
- package/dist/operations/attach.ts +2 -27
- package/dist/operations/dispatch.js +2 -3
- package/dist/operations/dispatch.ts +2 -3
- package/dist/operations/generators/capability.js +4 -7
- package/dist/operations/generators/capability.ts +3 -6
- package/dist/operations/generators/compile.js +8 -13
- package/dist/operations/generators/compile.ts +8 -4
- package/dist/operations/generators/permits.js +4 -13
- package/dist/operations/generators/permits.ts +3 -3
- package/dist/operations/generators/seed.js +5 -2
- package/dist/operations/generators/seed.ts +6 -2
- package/dist/operations/generators/trial.js +10 -10
- package/dist/operations/generators/trial.ts +10 -10
- package/dist/operations/http.js +4 -1
- package/dist/operations/http.ts +6 -1
- package/package.json +2 -2
- package/dist/core/cli.d.ts +0 -2
- package/dist/core/cli.js +0 -1761
- package/dist/core/cli.ts +0 -2004
- package/dist/core/generators/meta.d.ts +0 -2
- package/dist/core/generators/meta.js +0 -829
- package/dist/core/generators/meta.ts +0 -1006
- package/dist/derivation/generators/derivation.d.ts +0 -3
- package/dist/derivation/generators/derivation.js +0 -273
- package/dist/derivation/generators/derivation.ts +0 -347
- package/dist/derivation/makers/release.d.ts +0 -1
- package/dist/derivation/makers/release.js +0 -107
- package/dist/derivation/makers/release.ts +0 -135
- package/dist/integrations/generators/secret.d.ts +0 -1
- package/dist/integrations/generators/secret.js +0 -233
- package/dist/integrations/generators/secret.ts +0 -289
- package/dist/integrations/generators/target.d.ts +0 -1
- package/dist/integrations/generators/target.js +0 -775
- package/dist/integrations/generators/target.ts +0 -944
- package/dist/integrity/generators/rule.d.ts +0 -2
- package/dist/integrity/generators/rule.js +0 -213
- package/dist/integrity/generators/rule.ts +0 -271
- package/dist/integrity/generators/seal.d.ts +0 -4
- package/dist/integrity/generators/seal.js +0 -101
- package/dist/integrity/generators/seal.ts +0 -117
- package/dist/integrity/sealed.d.ts +0 -1
- package/dist/integrity/sealed.js +0 -56
- package/dist/integrity/sealed.ts +0 -56
- package/dist/knowledge/generators/skills.d.ts +0 -1
- package/dist/knowledge/generators/skills.js +0 -222
- package/dist/knowledge/generators/skills.ts +0 -263
- package/dist/operations/generators/grant.d.ts +0 -1
- package/dist/operations/generators/grant.js +0 -267
- package/dist/operations/generators/grant.ts +0 -336
- package/dist/operations/generators/operation.d.ts +0 -1
- package/dist/operations/generators/operation.js +0 -811
- package/dist/operations/generators/operation.ts +0 -972
- package/dist/operations/makers/capability.d.ts +0 -1
- package/dist/operations/makers/capability.js +0 -117
- package/dist/operations/makers/capability.ts +0 -166
- package/dist/operations/makers/trial.d.ts +0 -1
- package/dist/operations/makers/trial.js +0 -413
- package/dist/operations/makers/trial.ts +0 -520
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
import { argv, exit, stdout } from 'node:process';
|
|
5
|
-
import { RECEIPT, answer, asking, given, issue, only, refuse, spend, wordsIn } from "../../core/asking.js";
|
|
6
|
-
import { findTree } from "../../core/tree.js";
|
|
7
|
-
import { CAPABILITIES_AT, SURFACES, isSurface } from "../capabilities.js";
|
|
8
|
-
const TREE = findTree();
|
|
9
|
-
const at = resolve(TREE.at, CAPABILITIES_AT);
|
|
10
|
-
if (!existsSync(at)) {
|
|
11
|
-
refuse(`${CAPABILITIES_AT} is not there, so this app has nothing reachable to switch. Declare an operation with ` +
|
|
12
|
-
'`thread create operation` — it writes this table on its way out — or run `thread capabilities`.');
|
|
13
|
-
}
|
|
14
|
-
let table;
|
|
15
|
-
try {
|
|
16
|
-
table = JSON.parse(readFileSync(at, 'utf8'));
|
|
17
|
-
}
|
|
18
|
-
catch (thrown) {
|
|
19
|
-
refuse(`${CAPABILITIES_AT} could not be read: ${thrown instanceof Error ? thrown.message : String(thrown)}. ` +
|
|
20
|
-
'Run `thread capabilities` — it is derived, so it can always be written again.');
|
|
21
|
-
}
|
|
22
|
-
if (table.length === 0) {
|
|
23
|
-
refuse('this app declares no operation, so there is nothing to switch on or off yet.');
|
|
24
|
-
}
|
|
25
|
-
const mark = (one) => [
|
|
26
|
-
` ${one.operation} — ${one.describes}`,
|
|
27
|
-
` ${SURFACES.map((each) => `${one.live.includes(each) ? '[on] ' : '[off]'} ${each}`).join(' ')}`,
|
|
28
|
-
` ${one.browsable ? 'may be called from a page' : 'server only — it reaches a target that needs a server secret'}`,
|
|
29
|
-
];
|
|
30
|
-
const listing = [`${String(table.length)} operation(s):`, ...table.flatMap(mark)].join('\n');
|
|
31
|
-
const words = wordsIn(['edit']);
|
|
32
|
-
const verb = words[0];
|
|
33
|
-
stdout.write(`${listing}\n`);
|
|
34
|
-
const ASKS = [
|
|
35
|
-
{
|
|
36
|
-
key: 'live',
|
|
37
|
-
says: [
|
|
38
|
-
'which surfaces are on, comma-separated. Answering nothing switches every',
|
|
39
|
-
'one of them off, which leaves the operation declared, compiled and proven',
|
|
40
|
-
'and reachable by nobody — a real thing to want, and said out loud rather',
|
|
41
|
-
'than refused.',
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
const TAKES = ASKS.map((one) => one.key);
|
|
46
|
-
const ASKED = ASKS.flatMap((one) => one.says.map((line, at) => ` ${at === 0 ? `${one.key}:`.padEnd(8) : ' '.repeat(8)}${line}`));
|
|
47
|
-
const method = (nonce) => [
|
|
48
|
-
'',
|
|
49
|
-
'what this changes:',
|
|
50
|
-
'',
|
|
51
|
-
` thread create capability edit <operation> ${RECEIPT} ${nonce}`,
|
|
52
|
-
'',
|
|
53
|
-
` ${RECEIPT} is spent by one run and refused if the table moved after it was issued.`,
|
|
54
|
-
'',
|
|
55
|
-
`a surface is a way this app is CALLED, and there are ${String(SURFACES.length)}: ${SURFACES.join(', ')}.`,
|
|
56
|
-
'',
|
|
57
|
-
' cli a command a terminal runs',
|
|
58
|
-
' api a route a request arrives on, and the OpenAPI document written from it',
|
|
59
|
-
' mcp a tool an agent is offered. Switch this off and an AI actor cannot call the operation,',
|
|
60
|
-
' while everything else about it goes on working',
|
|
61
|
-
'',
|
|
62
|
-
'`edit` asks, one answer per line:',
|
|
63
|
-
'',
|
|
64
|
-
...ASKED,
|
|
65
|
-
'',
|
|
66
|
-
'It writes the flag and runs `thread capabilities`, which carries every flag across and rewrites',
|
|
67
|
-
'the tool list, the OpenAPI document and the client bundle from them.',
|
|
68
|
-
].join('\n');
|
|
69
|
-
const flagged = argv.indexOf(RECEIPT);
|
|
70
|
-
if (verb === undefined && flagged === -1) {
|
|
71
|
-
const nonce = issue(TREE.at, listing);
|
|
72
|
-
stdout.write(`${method(nonce)}\n`);
|
|
73
|
-
stdout.write(`\ncapability: receipt ${nonce} — spent on use, and stale the moment ${CAPABILITIES_AT} changes.\n`);
|
|
74
|
-
exit(0);
|
|
75
|
-
}
|
|
76
|
-
spend(TREE.at, listing, argv[flagged + 1], CAPABILITIES_AT);
|
|
77
|
-
if (verb !== 'edit') {
|
|
78
|
-
refuse(`there is nothing called "${verb ?? ''}" to do here — say edit. A capability is derived, so there is none to add`);
|
|
79
|
-
}
|
|
80
|
-
const which = words[1];
|
|
81
|
-
if (which === undefined) {
|
|
82
|
-
refuse('`edit` takes the name of an operation this app declares');
|
|
83
|
-
}
|
|
84
|
-
const one = table.find((each) => each.operation === which);
|
|
85
|
-
if (one === undefined) {
|
|
86
|
-
refuse(`\`${which}\` is not an operation this app declares. What is here is ${table.map((each) => each.operation).join(', ')}`);
|
|
87
|
-
}
|
|
88
|
-
const piped = given();
|
|
89
|
-
only(piped, TAKES, 'editing a capability');
|
|
90
|
-
const { ask, shut } = asking(piped);
|
|
91
|
-
const said = (piped.length > 0
|
|
92
|
-
? (answer(piped, 'live') ?? '')
|
|
93
|
-
: await ask('live', `which surfaces are on — ${SURFACES.join(', ')} (now: ${one.live.join(', ') || 'none'}): `)).trim();
|
|
94
|
-
shut();
|
|
95
|
-
const wanted = said
|
|
96
|
-
.split(',')
|
|
97
|
-
.map((each) => each.trim().toLowerCase())
|
|
98
|
-
.filter((each) => each !== '');
|
|
99
|
-
const wrong = wanted.filter((each) => !isSurface(each));
|
|
100
|
-
if (wrong.length > 0) {
|
|
101
|
-
refuse(`there is no surface called ${wrong.map((each) => `"${each}"`).join(', ')}. There are ${String(SURFACES.length)}: ` +
|
|
102
|
-
`${SURFACES.join(', ')}. Nothing was written.`);
|
|
103
|
-
}
|
|
104
|
-
const live = SURFACES.filter((each) => wanted.includes(each));
|
|
105
|
-
writeFileSync(at, `${JSON.stringify(table.map((each) => (each.operation === one.operation ? { ...each, live } : each)), null, 2)}\n`);
|
|
106
|
-
const off = SURFACES.filter((each) => !live.includes(each));
|
|
107
|
-
stdout.write(`capability: ${one.operation} is live on ${live.join(', ') || 'nothing'}` +
|
|
108
|
-
`${off.length === 0 ? '' : `, and off for ${off.join(', ')}`}.\n`);
|
|
109
|
-
for (const what of [['capabilities'], ['docs']]) {
|
|
110
|
-
const made = spawnSync('npx', ['thread', ...what], { cwd: TREE.at, encoding: 'utf8' });
|
|
111
|
-
stdout.write(`${`${made.stdout ?? ''}${made.stderr ?? ''}`.trim()}\n`);
|
|
112
|
-
if (made.status !== 0) {
|
|
113
|
-
stdout.write(`capability: the flag is written and stands; \`thread ${what.join(' ')}\` refused above.\n`);
|
|
114
|
-
exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exit(0);
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process'
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
-
import { resolve } from 'node:path'
|
|
4
|
-
import { argv, exit, stdout } from 'node:process'
|
|
5
|
-
|
|
6
|
-
import { RECEIPT, answer, asking, given, issue, only, refuse, spend, wordsIn } from '../../core/asking.ts'
|
|
7
|
-
import { findTree } from '../../core/tree.ts'
|
|
8
|
-
|
|
9
|
-
import { CAPABILITIES_AT, SURFACES, isSurface, type Capability, type Surface } from '../capabilities.ts'
|
|
10
|
-
|
|
11
|
-
const TREE = findTree()
|
|
12
|
-
|
|
13
|
-
const at = resolve(TREE.at, CAPABILITIES_AT)
|
|
14
|
-
|
|
15
|
-
if (!existsSync(at)) {
|
|
16
|
-
refuse(
|
|
17
|
-
`${CAPABILITIES_AT} is not there, so this app has nothing reachable to switch. Declare an operation with ` +
|
|
18
|
-
'`thread create operation` — it writes this table on its way out — or run `thread capabilities`.',
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let table: readonly Capability[]
|
|
23
|
-
try {
|
|
24
|
-
table = JSON.parse(readFileSync(at, 'utf8')) as readonly Capability[]
|
|
25
|
-
} catch (thrown) {
|
|
26
|
-
refuse(
|
|
27
|
-
`${CAPABILITIES_AT} could not be read: ${thrown instanceof Error ? thrown.message : String(thrown)}. ` +
|
|
28
|
-
'Run `thread capabilities` — it is derived, so it can always be written again.',
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (table.length === 0) {
|
|
33
|
-
refuse('this app declares no operation, so there is nothing to switch on or off yet.')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const mark = (one: Capability): readonly string[] => [
|
|
37
|
-
` ${one.operation} — ${one.describes}`,
|
|
38
|
-
` ${SURFACES.map((each) => `${one.live.includes(each) ? '[on] ' : '[off]'} ${each}`).join(' ')}`,
|
|
39
|
-
` ${one.browsable ? 'may be called from a page' : 'server only — it reaches a target that needs a server secret'}`,
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
const listing = [`${String(table.length)} operation(s):`, ...table.flatMap(mark)].join('\n')
|
|
43
|
-
|
|
44
|
-
const words = wordsIn(['edit'])
|
|
45
|
-
|
|
46
|
-
const verb = words[0]
|
|
47
|
-
|
|
48
|
-
stdout.write(`${listing}\n`)
|
|
49
|
-
|
|
50
|
-
const ASKS: readonly { readonly key: string; readonly says: readonly string[] }[] = [
|
|
51
|
-
{
|
|
52
|
-
key: 'live',
|
|
53
|
-
says: [
|
|
54
|
-
'which surfaces are on, comma-separated. Answering nothing switches every',
|
|
55
|
-
'one of them off, which leaves the operation declared, compiled and proven',
|
|
56
|
-
'and reachable by nobody — a real thing to want, and said out loud rather',
|
|
57
|
-
'than refused.',
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
const TAKES: readonly string[] = ASKS.map((one) => one.key)
|
|
63
|
-
|
|
64
|
-
const ASKED: readonly string[] = ASKS.flatMap((one) =>
|
|
65
|
-
one.says.map((line, at) => ` ${at === 0 ? `${one.key}:`.padEnd(8) : ' '.repeat(8)}${line}`),
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
const method = (nonce: string): string =>
|
|
69
|
-
[
|
|
70
|
-
'',
|
|
71
|
-
'what this changes:',
|
|
72
|
-
'',
|
|
73
|
-
` thread create capability edit <operation> ${RECEIPT} ${nonce}`,
|
|
74
|
-
'',
|
|
75
|
-
` ${RECEIPT} is spent by one run and refused if the table moved after it was issued.`,
|
|
76
|
-
'',
|
|
77
|
-
`a surface is a way this app is CALLED, and there are ${String(SURFACES.length)}: ${SURFACES.join(', ')}.`,
|
|
78
|
-
'',
|
|
79
|
-
' cli a command a terminal runs',
|
|
80
|
-
' api a route a request arrives on, and the OpenAPI document written from it',
|
|
81
|
-
' mcp a tool an agent is offered. Switch this off and an AI actor cannot call the operation,',
|
|
82
|
-
' while everything else about it goes on working',
|
|
83
|
-
'',
|
|
84
|
-
'`edit` asks, one answer per line:',
|
|
85
|
-
'',
|
|
86
|
-
...ASKED,
|
|
87
|
-
'',
|
|
88
|
-
'It writes the flag and runs `thread capabilities`, which carries every flag across and rewrites',
|
|
89
|
-
'the tool list, the OpenAPI document and the client bundle from them.',
|
|
90
|
-
].join('\n')
|
|
91
|
-
|
|
92
|
-
const flagged = argv.indexOf(RECEIPT)
|
|
93
|
-
|
|
94
|
-
if (verb === undefined && flagged === -1) {
|
|
95
|
-
const nonce = issue(TREE.at, listing)
|
|
96
|
-
stdout.write(`${method(nonce)}\n`)
|
|
97
|
-
stdout.write(`\ncapability: receipt ${nonce} — spent on use, and stale the moment ${CAPABILITIES_AT} changes.\n`)
|
|
98
|
-
exit(0)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
spend(TREE.at, listing, argv[flagged + 1], CAPABILITIES_AT)
|
|
102
|
-
|
|
103
|
-
if (verb !== 'edit') {
|
|
104
|
-
refuse(`there is nothing called "${verb ?? ''}" to do here — say edit. A capability is derived, so there is none to add`)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const which = words[1]
|
|
108
|
-
if (which === undefined) {
|
|
109
|
-
refuse('`edit` takes the name of an operation this app declares')
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const one = table.find((each) => each.operation === which)
|
|
113
|
-
if (one === undefined) {
|
|
114
|
-
refuse(`\`${which}\` is not an operation this app declares. What is here is ${table.map((each) => each.operation).join(', ')}`)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const piped = given()
|
|
118
|
-
only(piped, TAKES, 'editing a capability')
|
|
119
|
-
const { ask, shut } = asking(piped)
|
|
120
|
-
|
|
121
|
-
const said = (
|
|
122
|
-
piped.length > 0
|
|
123
|
-
? (answer(piped, 'live') ?? '')
|
|
124
|
-
: await ask('live', `which surfaces are on — ${SURFACES.join(', ')} (now: ${one.live.join(', ') || 'none'}): `)
|
|
125
|
-
).trim()
|
|
126
|
-
shut()
|
|
127
|
-
|
|
128
|
-
const wanted = said
|
|
129
|
-
.split(',')
|
|
130
|
-
.map((each) => each.trim().toLowerCase())
|
|
131
|
-
.filter((each) => each !== '')
|
|
132
|
-
|
|
133
|
-
const wrong = wanted.filter((each) => !isSurface(each))
|
|
134
|
-
if (wrong.length > 0) {
|
|
135
|
-
refuse(
|
|
136
|
-
`there is no surface called ${wrong.map((each) => `"${each}"`).join(', ')}. There are ${String(SURFACES.length)}: ` +
|
|
137
|
-
`${SURFACES.join(', ')}. Nothing was written.`,
|
|
138
|
-
)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const live = SURFACES.filter((each) => wanted.includes(each))
|
|
142
|
-
|
|
143
|
-
writeFileSync(
|
|
144
|
-
at,
|
|
145
|
-
`${JSON.stringify(
|
|
146
|
-
table.map((each) => (each.operation === one.operation ? { ...each, live } : each)),
|
|
147
|
-
null,
|
|
148
|
-
2,
|
|
149
|
-
)}\n`,
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
const off = SURFACES.filter((each) => !live.includes(each))
|
|
153
|
-
stdout.write(
|
|
154
|
-
`capability: ${one.operation} is live on ${live.join(', ') || 'nothing'}` +
|
|
155
|
-
`${off.length === 0 ? '' : `, and off for ${off.join(', ')}`}.\n`,
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
for (const what of [['capabilities'], ['docs']]) {
|
|
159
|
-
const made = spawnSync('npx', ['thread', ...what], { cwd: TREE.at, encoding: 'utf8' })
|
|
160
|
-
stdout.write(`${`${made.stdout ?? ''}${made.stderr ?? ''}`.trim()}\n`)
|
|
161
|
-
if (made.status !== 0) {
|
|
162
|
-
stdout.write(`capability: the flag is written and stands; \`thread ${what.join(' ')}\` refused above.\n`)
|
|
163
|
-
exit(1)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exit(0)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|