@buffcore/cli 0.8.48 → 0.8.49
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 +34 -0
- package/dist/commands/change-merge-serial.d.ts +6 -2
- package/dist/commands/change-merge-serial.js +5 -1
- package/dist/commands/change.js +3 -0
- package/dist/commands/check-skills.d.ts +16 -0
- package/dist/commands/check-skills.en.d.ts +14 -0
- package/dist/commands/check-skills.en.js +14 -0
- package/dist/commands/check-skills.es.d.ts +2 -0
- package/dist/commands/check-skills.es.js +14 -0
- package/dist/commands/check-skills.js +146 -0
- package/dist/commands/check.js +5 -0
- package/dist/commands/extension/config-text.d.ts +2 -0
- package/dist/commands/extension/config-text.js +2 -0
- package/dist/commands/extension/index.js +14 -2
- package/dist/commands/extension/new.d.ts +16 -0
- package/dist/commands/extension/new.js +52 -0
- package/dist/commands/extension/pack-files.d.ts +23 -0
- package/dist/commands/extension/pack-files.js +78 -0
- package/dist/commands/extension/pack-scan.d.ts +24 -0
- package/dist/commands/extension/pack-scan.js +131 -0
- package/dist/commands/extension/pack.d.ts +48 -0
- package/dist/commands/extension/pack.js +142 -0
- package/dist/commands/extension/share-text.d.ts +3 -0
- package/dist/commands/extension/share-text.js +6 -0
- package/dist/commands/extension/share.en.d.ts +32 -0
- package/dist/commands/extension/share.en.js +32 -0
- package/dist/commands/extension/share.es.d.ts +2 -0
- package/dist/commands/extension/share.es.js +32 -0
- package/dist/commands/server/setup.d.ts +1 -0
- package/dist/commands/ui/index.d.ts +1 -0
- package/dist/commands/ui/outside-merge.d.ts +13 -0
- package/dist/commands/ui/outside-merge.js +84 -0
- package/dist/commands/ui/outside.d.ts +7 -4
- package/dist/commands/ui/outside.js +3 -0
- package/dist/commands/ui/plan-extensions.d.ts +34 -0
- package/dist/commands/ui/plan-extensions.en.d.ts +4 -0
- package/dist/commands/ui/plan-extensions.en.js +4 -0
- package/dist/commands/ui/plan-extensions.es.d.ts +2 -0
- package/dist/commands/ui/plan-extensions.es.js +4 -0
- package/dist/commands/ui/plan-extensions.js +86 -0
- package/dist/commands/ui/plan-files.js +4 -1
- package/dist/commands/ui/prototype-main.d.ts +6 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +7 -0
- package/dist/commands/ui/studio.en.d.ts +2 -0
- package/dist/commands/ui/studio.en.js +2 -0
- package/dist/commands/ui/studio.es.d.ts +2 -0
- package/dist/commands/ui/studio.es.js +2 -0
- package/dist/commands/upgrade.js +1 -1
- package/dist/ui/page.js +82 -82
- package/docs/EXTENSIONS.md +6 -0
- package/docs/WORKBENCH.md +25 -2
- package/package.json +11 -11
- package/skills/ape-add-ai-purpose/SKILL.md +1 -1
- package/skills/ape-add-event/SKILL.md +1 -1
- package/skills/ape-add-extension/SKILL.md +5 -1
- package/skills/ape-add-feature/SKILL.md +1 -1
- package/skills/ape-add-generator/SKILL.md +1 -1
- package/skills/ape-add-module/SKILL.md +1 -1
- package/skills/ape-add-route/SKILL.md +3 -1
- package/skills/ape-add-service/SKILL.md +1 -1
- package/skills/ape-add-translations/SKILL.md +2 -2
- package/skills/ape-admin-screen/SKILL.md +1 -1
- package/skills/ape-app-screen/SKILL.md +1 -1
- package/skills/ape-critique/SKILL.md +11 -32
- package/skills/ape-critique/references/after.md +15 -0
- package/skills/ape-critique/references/spacing-pass.md +20 -0
- package/skills/ape-deploy/SKILL.md +4 -1
- package/skills/ape-design-system/SKILL.md +15 -15
- package/skills/ape-design-system/references/by-hand.md +7 -0
- package/skills/ape-design-system/references/reference-study.md +11 -0
- package/skills/ape-diagnose/SKILL.md +24 -0
- package/skills/ape-migration/SKILL.md +1 -1
- package/skills/ape-plan-change/SKILL.md +37 -31
- package/skills/ape-plan-change/references/change-file-fields.md +5 -0
- package/skills/ape-plan-change/references/extensions.md +25 -0
- package/skills/ape-plan-change/references/finishing.md +3 -0
- package/skills/ape-plan-change/references/fix-from-error.md +3 -0
- package/skills/ape-plan-change/references/refactor.md +9 -0
- package/skills/ape-plan-change/references/structure.md +19 -0
- package/skills/ape-prototype/SKILL.md +13 -23
- package/skills/ape-prototype/references/comp.md +3 -0
- package/skills/ape-prototype/references/scope-and-export.md +5 -0
- package/skills/ape-prototype/references/snapshot.md +3 -0
- package/skills/ape-prototype/references/structure.md +11 -0
- package/skills/ape-prototype/references/working-app.md +7 -0
- package/skills/ape-request/SKILL.md +1 -1
- package/skills/ape-upgrade/SKILL.md +4 -1
- package/templates/product/package.json +1 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { secretHits } from '../check-secrets.js';
|
|
2
|
+
import { readPackage } from './pack-files.js';
|
|
3
|
+
import { t } from './share-text.js';
|
|
4
|
+
/** A local part of 1 to 64 characters starting at a boundary, then up to 8 labels of 63. */
|
|
5
|
+
const EMAIL = /(?<![\w.+-])[\w.+-]{1,64}@([a-z0-9-]{1,63}(?:\.[a-z0-9-]{1,63}){1,8})(?![\w-])/gi;
|
|
6
|
+
/** Domains kept for examples and tests (RFC 2606, 6761), and placeholders. */
|
|
7
|
+
const EXAMPLE_DOMAIN = /(?:^|\.)(?:example\.(?:com|net|org)|[\w-]+\.(?:test|example|invalid|localhost|local|internal))$|^(?:example|localhost)$/i;
|
|
8
|
+
/** Endings that are a file's, not a domain's: `logo@2x.png`, `icon@3x.webp`. */
|
|
9
|
+
const FILE_ENDING = /^(?:png|jpe?g|gif|svg|webp|avif|ico|bmp|tiff?|js|mjs|cjs|ts|tsx|jsx|json|css|scss|html?|md|txt|xml|ya?ml|map|wasm|woff2?|ttf|otf|mp[34]|mov|pdf|zip|gz|tgz|lock)$/i;
|
|
10
|
+
/** A real-looking address: its last label letters and not a file ending, no label all digits. */
|
|
11
|
+
function realEmail(domain) {
|
|
12
|
+
const labels = domain.split('.');
|
|
13
|
+
const tld = labels.at(-1) ?? '';
|
|
14
|
+
if (!/^[a-z]{2,24}$/i.test(tld) || FILE_ENDING.test(tld))
|
|
15
|
+
return false;
|
|
16
|
+
if (labels.some((label) => /^\d+$/.test(label)))
|
|
17
|
+
return false;
|
|
18
|
+
return !EXAMPLE_DOMAIN.test(domain);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Phone numbers, kept to shapes a real number has so dates, versions, ids and drawings pass:
|
|
22
|
+
* - a `+` and a country code with 10 to 15 digits however grouped;
|
|
23
|
+
* - North American 3-3-4 with separators, unless it is one of a run of numbers (an SVG path,
|
|
24
|
+
* `M 210 320 1240`): never after a path command letter or a number, never before a number;
|
|
25
|
+
* - 10 digits alone, area code and exchange starting 2 to 9, only as a whole quoted value or after
|
|
26
|
+
* `tel:` (a bare constant such as 2147483647 is a number, not a phone);
|
|
27
|
+
* - a UK number from 0 (07xxx xxxxxx, or 0 and 10 digits alone).
|
|
28
|
+
* The fictional ranges pass: 555-0100 to 555-0199, and 07700 900000 to 900999.
|
|
29
|
+
*/
|
|
30
|
+
const PHONES = [
|
|
31
|
+
/(?<![\w.+])\+\d(?:[\s.-]?\(?\d\)?){9,14}(?![\w.])/g,
|
|
32
|
+
/(?<![\w.]|\d[\s,]{1,3}|(?:^|[\s,"'])[MLHVCSQTAZmlhvcsqtaz][\s,]?)\(?[2-9]\d{2}\)?[\s.-]\d{3}[\s.-]\d{4}(?![\w.]|[\s,]{1,3}-?\d)/g,
|
|
33
|
+
/(?<=['"`>]|tel:)[2-9]\d{2}[2-9]\d{6}(?=['"`<])/g,
|
|
34
|
+
/(?<![\w.-])0[1-9]\d{3}[\s-]?\d{6}(?![\w.-])/g,
|
|
35
|
+
];
|
|
36
|
+
const FICTIONAL_PHONE = /555[\s.)-]*01\d\d|7700[\s.-]?900\d{3}/;
|
|
37
|
+
const NOT_PHONES = new Set(['2147483647', '2147483648', '4294967295', '4294967296']);
|
|
38
|
+
const phonesIn = (line) => PHONES.flatMap((pattern) => [...line.matchAll(pattern)]
|
|
39
|
+
.map(([phone]) => phone)
|
|
40
|
+
.filter((phone) => !FICTIONAL_PHONE.test(phone) && !NOT_PHONES.has(phone)));
|
|
41
|
+
/** A text's words, lower case: split at every non-letter-or-digit and at camelCase, in one pass. */
|
|
42
|
+
export function words(text) {
|
|
43
|
+
const out = [];
|
|
44
|
+
let word = '';
|
|
45
|
+
for (let i = 0; i < text.length; i++) {
|
|
46
|
+
const c = text[i];
|
|
47
|
+
const lower = c >= 'a' && c <= 'z';
|
|
48
|
+
const upper = c >= 'A' && c <= 'Z';
|
|
49
|
+
if (!lower && !upper && !(c >= '0' && c <= '9')) {
|
|
50
|
+
if (word)
|
|
51
|
+
out.push(word);
|
|
52
|
+
word = '';
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const before = text[i - 1] ?? '';
|
|
56
|
+
const next = text[i + 1] ?? '';
|
|
57
|
+
// `brightPaws`, `v2Api`: a capital after a small letter or digit; `HTTPServer`: the last
|
|
58
|
+
// capital of a run when a small letter follows.
|
|
59
|
+
const startsWord = upper &&
|
|
60
|
+
word !== '' &&
|
|
61
|
+
(/[a-z0-9]/.test(before) || (/[A-Z]/.test(before) && next >= 'a' && next <= 'z'));
|
|
62
|
+
if (startsWord) {
|
|
63
|
+
out.push(word);
|
|
64
|
+
word = '';
|
|
65
|
+
}
|
|
66
|
+
word += c.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
if (word)
|
|
69
|
+
out.push(word);
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The product's name in any spelling: `bright-paws`, `Bright Paws`, `brightPawsApi`, `BRIGHTPAWS`.
|
|
74
|
+
* Its letters joined must equal one to four neighbouring words joined.
|
|
75
|
+
*/
|
|
76
|
+
function namedIn(name) {
|
|
77
|
+
const joined = words(name).join('');
|
|
78
|
+
return (text) => {
|
|
79
|
+
const list = words(text);
|
|
80
|
+
for (let start = 0; start < list.length; start++) {
|
|
81
|
+
let run = '';
|
|
82
|
+
for (let end = start; end < Math.min(list.length, start + 4); end++) {
|
|
83
|
+
run += list[end];
|
|
84
|
+
if (run === joined)
|
|
85
|
+
return true;
|
|
86
|
+
if (run.length >= joined.length)
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Each finding in one file's text; `allowed` are the product's reviewed public values. */
|
|
94
|
+
export function scanText(file, text, productName, allowed = []) {
|
|
95
|
+
const found = [];
|
|
96
|
+
const add = (kind, line, values = {}) => found.push({ file, line, kind, message: t(`share.pack.${kind}`, { file, line, ...values }) });
|
|
97
|
+
const reviewed = (value) => allowed.some((entry) => entry.includes(value));
|
|
98
|
+
for (const { line, rule } of secretHits(text, allowed))
|
|
99
|
+
add('secret', line, { rule });
|
|
100
|
+
const named = namedIn(productName);
|
|
101
|
+
for (const [index, raw] of text.split('\n').entries()) {
|
|
102
|
+
const line = index + 1;
|
|
103
|
+
if ([...raw.matchAll(EMAIL)].some(([email, domain]) => realEmail(domain ?? '') && !reviewed(email)))
|
|
104
|
+
add('email', line);
|
|
105
|
+
if (phonesIn(raw).some((phone) => !reviewed(phone)))
|
|
106
|
+
add('phone', line);
|
|
107
|
+
if (named(raw))
|
|
108
|
+
add('name', line, { name: productName });
|
|
109
|
+
}
|
|
110
|
+
return found;
|
|
111
|
+
}
|
|
112
|
+
/** Every finding in the package, and the files to ship: exactly the bytes that were scanned. */
|
|
113
|
+
export async function scanPackage(dir, productName, allowed = []) {
|
|
114
|
+
const { files, refused } = await readPackage(dir);
|
|
115
|
+
const findings = refused.map(({ file, why }) => ({
|
|
116
|
+
file,
|
|
117
|
+
kind: why,
|
|
118
|
+
message: t(`share.pack.${why}`, { file }),
|
|
119
|
+
}));
|
|
120
|
+
const named = namedIn(productName);
|
|
121
|
+
for (const { file, text } of files) {
|
|
122
|
+
if (named(file))
|
|
123
|
+
findings.push({
|
|
124
|
+
file,
|
|
125
|
+
kind: 'nameFile',
|
|
126
|
+
message: t('share.pack.nameFile', { file, name: productName }),
|
|
127
|
+
});
|
|
128
|
+
findings.push(...scanText(file, text, productName, allowed));
|
|
129
|
+
}
|
|
130
|
+
return { files, findings };
|
|
131
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Finding } from './pack-scan.ts';
|
|
2
|
+
/** The extension checks' result as the bundle records it; `ape check compatible` gives it. */
|
|
3
|
+
export interface CheckReport {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
checks?: unknown;
|
|
6
|
+
problem?: string;
|
|
7
|
+
}
|
|
8
|
+
type RunChecks = (dir: string, root: string) => Promise<CheckReport>;
|
|
9
|
+
export type PackResult = {
|
|
10
|
+
ok: false;
|
|
11
|
+
findings: Finding[];
|
|
12
|
+
message?: string;
|
|
13
|
+
} | {
|
|
14
|
+
ok: true;
|
|
15
|
+
path: string;
|
|
16
|
+
submission: Submission;
|
|
17
|
+
checks: CheckReport;
|
|
18
|
+
};
|
|
19
|
+
interface Submission {
|
|
20
|
+
package: string;
|
|
21
|
+
version: string;
|
|
22
|
+
key: string;
|
|
23
|
+
catalog: string | null;
|
|
24
|
+
license: string;
|
|
25
|
+
touches: {
|
|
26
|
+
reads: string[];
|
|
27
|
+
hosts: string[];
|
|
28
|
+
places: string[];
|
|
29
|
+
uploads: string[];
|
|
30
|
+
} | null;
|
|
31
|
+
screens: string[];
|
|
32
|
+
files: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `ape extension pack <key>`: a submission bundle for the catalog the product names, written to a
|
|
36
|
+
* local folder (`.ape/pack/<key>/` by default). It holds `package/` (the package's own files),
|
|
37
|
+
* `check-report.json` (the extension checks), `scan.json` (what was looked for and found) and
|
|
38
|
+
* `submission.json` (what it can touch, its licence, its screens). It refuses a package holding a
|
|
39
|
+
* secret, a real-looking email or phone, or the product's own name, listing each. It never
|
|
40
|
+
* publishes, uploads or calls the network: a person submits the folder.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pack(key: string, options?: {
|
|
43
|
+
out?: string;
|
|
44
|
+
}, root?: string, runChecks?: RunChecks): Promise<PackResult>;
|
|
45
|
+
export declare function packCommand(key: string, options: {
|
|
46
|
+
out?: string;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { existsSync, lstatSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { mkdir, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { findRoot } from '../../project.js';
|
|
5
|
+
import { allowedValues } from '../check-secrets.js';
|
|
6
|
+
import { readEditConfig } from './config-text.js';
|
|
7
|
+
import { scanPackage } from './pack-scan.js';
|
|
8
|
+
import { t } from './share-text.js';
|
|
9
|
+
import { readPackage } from './surfaces.js';
|
|
10
|
+
const runCompatible = async (dir, root) => {
|
|
11
|
+
try {
|
|
12
|
+
const { compatible } = await import('../compatible.js');
|
|
13
|
+
const result = await compatible(dir, root);
|
|
14
|
+
return { ok: result.ok, checks: result.checks };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// The bundle leaves this computer: its folders are named from the product's root.
|
|
18
|
+
const problem = error instanceof Error ? error.message : String(error);
|
|
19
|
+
return { ok: false, problem: problem.replaceAll(root, '.') };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const MARKER = '.ape-pack-bundle';
|
|
23
|
+
/**
|
|
24
|
+
* Where the bundle goes: `.ape/pack/<key>` in the product, or `--out <folder>`, a path from the
|
|
25
|
+
* product's root that stays inside `.ape/pack/`. Absolute paths and `..` are refused, and so is an
|
|
26
|
+
* existing folder pack did not write: nothing else is ever deleted.
|
|
27
|
+
*/
|
|
28
|
+
function bundleFolder(root, key, given) {
|
|
29
|
+
const base = resolve(root, '.ape', 'pack');
|
|
30
|
+
const refuse = { message: t('share.pack.outside', { out: given ?? '' }) };
|
|
31
|
+
if (given !== undefined &&
|
|
32
|
+
(isAbsolute(given) || /^[\\/]|^[a-z]:/i.test(given) || given.split(/[\\/]/).includes('..')))
|
|
33
|
+
return refuse;
|
|
34
|
+
const folder = join(given === undefined ? base : resolve(root, given), key);
|
|
35
|
+
const inside = relative(base, folder);
|
|
36
|
+
if (!inside || inside.startsWith('..') || isAbsolute(inside))
|
|
37
|
+
return refuse;
|
|
38
|
+
// Each step from the product down to the bundle is a real folder: a link or junction on the way
|
|
39
|
+
// (`.ape` itself included) could point outside, so it is refused, not followed.
|
|
40
|
+
let at = root;
|
|
41
|
+
for (const part of relative(root, folder).split(sep)) {
|
|
42
|
+
at = join(at, part);
|
|
43
|
+
if (!existsSync(at))
|
|
44
|
+
break;
|
|
45
|
+
if (lstatSync(at).isSymbolicLink() ||
|
|
46
|
+
realpathSync(at) !== join(realpathSync(root), relative(root, at)))
|
|
47
|
+
return refuse;
|
|
48
|
+
}
|
|
49
|
+
if (existsSync(folder) && !existsSync(join(folder, MARKER)))
|
|
50
|
+
return {
|
|
51
|
+
message: t('share.pack.notBundle', { path: relative(root, folder).split(sep).join('/') }),
|
|
52
|
+
};
|
|
53
|
+
return folder;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `ape extension pack <key>`: a submission bundle for the catalog the product names, written to a
|
|
57
|
+
* local folder (`.ape/pack/<key>/` by default). It holds `package/` (the package's own files),
|
|
58
|
+
* `check-report.json` (the extension checks), `scan.json` (what was looked for and found) and
|
|
59
|
+
* `submission.json` (what it can touch, its licence, its screens). It refuses a package holding a
|
|
60
|
+
* secret, a real-looking email or phone, or the product's own name, listing each. It never
|
|
61
|
+
* publishes, uploads or calls the network: a person submits the folder.
|
|
62
|
+
*/
|
|
63
|
+
export async function pack(key, options = {}, root = findRoot(), runChecks = runCompatible) {
|
|
64
|
+
const dir = join(root, 'packages', key);
|
|
65
|
+
if (!/^[a-z][a-z0-9]*$/.test(key) || !existsSync(join(dir, 'package.json')))
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
findings: [],
|
|
69
|
+
message: t('share.pack.missing', { path: `packages/${key}` }),
|
|
70
|
+
};
|
|
71
|
+
const config = await readEditConfig(root);
|
|
72
|
+
const { files: shipped, findings } = await scanPackage(dir, config.name(), allowedValues(root));
|
|
73
|
+
const files = shipped.map(({ file }) => file);
|
|
74
|
+
if (findings.length)
|
|
75
|
+
return { ok: false, findings };
|
|
76
|
+
const json = readPackage(dir);
|
|
77
|
+
const grant = config.grants[key];
|
|
78
|
+
const exportsOf = (json.exports ?? {});
|
|
79
|
+
const submission = {
|
|
80
|
+
package: json.name ?? `${key}-extension`,
|
|
81
|
+
version: json.version ?? '0.0.0',
|
|
82
|
+
key,
|
|
83
|
+
catalog: config.catalog().catalog?.url ?? null,
|
|
84
|
+
license: json.license ?? 'UNLICENSED',
|
|
85
|
+
touches: grant
|
|
86
|
+
? {
|
|
87
|
+
reads: [...(grant.reads ?? [])],
|
|
88
|
+
hosts: [...(grant.hosts ?? [])],
|
|
89
|
+
places: [...(grant.places ?? [])],
|
|
90
|
+
uploads: [...(grant.uploads ?? [])],
|
|
91
|
+
}
|
|
92
|
+
: null,
|
|
93
|
+
screens: files.filter((file) => (('./admin' in exportsOf && file.startsWith('src/admin/')) ||
|
|
94
|
+
('./app' in exportsOf && file.startsWith('src/app/'))) &&
|
|
95
|
+
/View\.tsx$/.test(file)),
|
|
96
|
+
files,
|
|
97
|
+
};
|
|
98
|
+
const out = bundleFolder(root, key, options.out);
|
|
99
|
+
if (typeof out !== 'string')
|
|
100
|
+
return { ok: false, findings: [], message: out.message };
|
|
101
|
+
const checks = await runChecks(dir, root);
|
|
102
|
+
// Only a folder pack made (its marker inside) is replaced; the bytes written are those scanned.
|
|
103
|
+
await rm(out, { recursive: true, force: true });
|
|
104
|
+
for (const { file, bytes } of shipped) {
|
|
105
|
+
await mkdir(dirname(join(out, 'package', file)), { recursive: true });
|
|
106
|
+
await writeFile(join(out, 'package', file), bytes);
|
|
107
|
+
}
|
|
108
|
+
await writeFile(join(out, MARKER), '');
|
|
109
|
+
const write = (file, value) => writeFile(join(out, file), `${JSON.stringify(value, null, 2)}\n`);
|
|
110
|
+
await write('submission.json', submission);
|
|
111
|
+
await write('check-report.json', checks);
|
|
112
|
+
await write('scan.json', {
|
|
113
|
+
looked: ['secrets', 'secret files', 'emails', 'phone numbers', 'the product name'],
|
|
114
|
+
findings: [],
|
|
115
|
+
});
|
|
116
|
+
return { ok: true, path: relative(root, out).split(sep).join('/'), submission, checks };
|
|
117
|
+
}
|
|
118
|
+
const list = (values) => values?.length ? values.join(', ') : t('share.pack.none');
|
|
119
|
+
export async function packCommand(key, options) {
|
|
120
|
+
const result = await pack(key, options);
|
|
121
|
+
if (!result.ok) {
|
|
122
|
+
if (result.message)
|
|
123
|
+
console.error(result.message);
|
|
124
|
+
else {
|
|
125
|
+
console.error(t('share.pack.refused', { count: result.findings.length }));
|
|
126
|
+
for (const finding of result.findings)
|
|
127
|
+
console.error(` ${finding.message}`);
|
|
128
|
+
}
|
|
129
|
+
process.exitCode = 1;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const { submission: s, checks } = result;
|
|
133
|
+
console.log(t('share.pack.done', { path: result.path, catalog: s.catalog ?? t('share.pack.noCatalog') }));
|
|
134
|
+
console.log(t('share.pack.touches', {
|
|
135
|
+
reads: list(s.touches?.reads),
|
|
136
|
+
hosts: list(s.touches?.hosts),
|
|
137
|
+
places: list(s.touches?.places),
|
|
138
|
+
}));
|
|
139
|
+
console.log(t('share.pack.license', { license: s.license }));
|
|
140
|
+
console.log(t('share.pack.screens', { screens: list(s.screens) }));
|
|
141
|
+
console.log(t('share.pack.checks', { state: t(checks.ok ? 'share.pack.passed' : 'share.pack.failed') }));
|
|
142
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createI18n } from '@buffcore/i18n';
|
|
2
|
+
import { en } from './share.en.js';
|
|
3
|
+
import { es } from './share.es.js';
|
|
4
|
+
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
5
|
+
/** The words of `ape extension new` and `ape extension pack`, in the terminal's language. */
|
|
6
|
+
export const t = (key, values) => messages.t(/^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en', key, values);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
readonly 'share.new.command': 'Start an extension built to share in this product: packages/<key> with its own tables, neutral words, tests on its own small product and its guide';
|
|
3
|
+
readonly 'share.new.key': 'The key is lowercase letters and digits, starting with a letter (sms, invoices2)';
|
|
4
|
+
readonly 'share.new.product': 'Run it in a product: no buffcore.config.ts here';
|
|
5
|
+
readonly 'share.new.exists': '{path} already exists: pick another key, or keep building that one';
|
|
6
|
+
readonly 'share.new.made': "Started {path} ({name}). Install it with pnpm ape add ./{path}; its tests run with the product's, and pnpm ape check compatible ./{path} checks it as the catalog will.";
|
|
7
|
+
readonly 'share.pack.command': 'Write a submission bundle for the catalog the product names: the package, its check report and the scan. Never publishes or calls the network';
|
|
8
|
+
readonly 'share.pack.out': 'the folder the bundle goes in (default .ape/pack)';
|
|
9
|
+
readonly 'share.pack.missing': 'No extension at {path} (pnpm ape extension new <key> starts one)';
|
|
10
|
+
readonly 'share.pack.refused': 'Not packed: {count, plural, one {# finding} other {# findings}} to take out first (each named, never its value):';
|
|
11
|
+
readonly 'share.pack.secret': '{file}:{line}: a secret ({rule})';
|
|
12
|
+
readonly 'share.pack.secretFile': '{file}: a secret or data file, by its name';
|
|
13
|
+
readonly 'share.pack.email': '{file}:{line}: an email address that looks real (use example.com)';
|
|
14
|
+
readonly 'share.pack.phone': '{file}:{line}: a phone number that looks real (use 555-0100 to 555-0199)';
|
|
15
|
+
readonly 'share.pack.name': '{file}:{line}: the product\'s own name, "{name}" (an extension\'s words name no product)';
|
|
16
|
+
readonly 'share.pack.nameFile': '{file}: the product\'s own name, "{name}", in its path';
|
|
17
|
+
readonly 'share.pack.hidden': '{file}: a hidden file or folder, never shipped (only .gitignore, .npmignore and .editorconfig are)';
|
|
18
|
+
readonly 'share.pack.notText': '{file}: not text pack can scan (an archive or another binary); only text, images and fonts ship';
|
|
19
|
+
readonly 'share.pack.outside': 'The bundle goes inside .ape/pack/ in the product: {out} is not there';
|
|
20
|
+
readonly 'share.pack.notBundle': '{path} exists and is not a bundle pack wrote; move it away first';
|
|
21
|
+
readonly 'share.new.installed': '{key} is installed already: pick another key, or its tables would clash';
|
|
22
|
+
readonly 'share.new.reserved': '{key} is a name Windows keeps for itself: pick another key';
|
|
23
|
+
readonly 'share.pack.done': 'Bundle written to {path}, for {catalog}. Nothing was sent: a person submits it.';
|
|
24
|
+
readonly 'share.pack.noCatalog': 'no catalog named in buffcore.config.ts yet';
|
|
25
|
+
readonly 'share.pack.checks': 'Checks: {state}. The report is check-report.json.';
|
|
26
|
+
readonly 'share.pack.passed': 'passed';
|
|
27
|
+
readonly 'share.pack.failed': 'not passed yet, see the report';
|
|
28
|
+
readonly 'share.pack.touches': 'It can touch: reads {reads}; hosts {hosts}; places {places}';
|
|
29
|
+
readonly 'share.pack.license': 'Licence: {license}';
|
|
30
|
+
readonly 'share.pack.screens': 'Screens: {screens}';
|
|
31
|
+
readonly 'share.pack.none': 'none';
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'share.new.command': 'Start an extension built to share in this product: packages/<key> with its own tables, neutral words, tests on its own small product and its guide',
|
|
3
|
+
'share.new.key': 'The key is lowercase letters and digits, starting with a letter (sms, invoices2)',
|
|
4
|
+
'share.new.product': 'Run it in a product: no buffcore.config.ts here',
|
|
5
|
+
'share.new.exists': '{path} already exists: pick another key, or keep building that one',
|
|
6
|
+
'share.new.made': "Started {path} ({name}). Install it with pnpm ape add ./{path}; its tests run with the product's, and pnpm ape check compatible ./{path} checks it as the catalog will.",
|
|
7
|
+
'share.pack.command': 'Write a submission bundle for the catalog the product names: the package, its check report and the scan. Never publishes or calls the network',
|
|
8
|
+
'share.pack.out': 'the folder the bundle goes in (default .ape/pack)',
|
|
9
|
+
'share.pack.missing': 'No extension at {path} (pnpm ape extension new <key> starts one)',
|
|
10
|
+
'share.pack.refused': 'Not packed: {count, plural, one {# finding} other {# findings}} to take out first (each named, never its value):',
|
|
11
|
+
'share.pack.secret': '{file}:{line}: a secret ({rule})',
|
|
12
|
+
'share.pack.secretFile': '{file}: a secret or data file, by its name',
|
|
13
|
+
'share.pack.email': '{file}:{line}: an email address that looks real (use example.com)',
|
|
14
|
+
'share.pack.phone': '{file}:{line}: a phone number that looks real (use 555-0100 to 555-0199)',
|
|
15
|
+
'share.pack.name': '{file}:{line}: the product\'s own name, "{name}" (an extension\'s words name no product)',
|
|
16
|
+
'share.pack.nameFile': '{file}: the product\'s own name, "{name}", in its path',
|
|
17
|
+
'share.pack.hidden': '{file}: a hidden file or folder, never shipped (only .gitignore, .npmignore and .editorconfig are)',
|
|
18
|
+
'share.pack.notText': '{file}: not text pack can scan (an archive or another binary); only text, images and fonts ship',
|
|
19
|
+
'share.pack.outside': 'The bundle goes inside .ape/pack/ in the product: {out} is not there',
|
|
20
|
+
'share.pack.notBundle': '{path} exists and is not a bundle pack wrote; move it away first',
|
|
21
|
+
'share.new.installed': '{key} is installed already: pick another key, or its tables would clash',
|
|
22
|
+
'share.new.reserved': '{key} is a name Windows keeps for itself: pick another key',
|
|
23
|
+
'share.pack.done': 'Bundle written to {path}, for {catalog}. Nothing was sent: a person submits it.',
|
|
24
|
+
'share.pack.noCatalog': 'no catalog named in buffcore.config.ts yet',
|
|
25
|
+
'share.pack.checks': 'Checks: {state}. The report is check-report.json.',
|
|
26
|
+
'share.pack.passed': 'passed',
|
|
27
|
+
'share.pack.failed': 'not passed yet, see the report',
|
|
28
|
+
'share.pack.touches': 'It can touch: reads {reads}; hosts {hosts}; places {places}',
|
|
29
|
+
'share.pack.license': 'Licence: {license}',
|
|
30
|
+
'share.pack.screens': 'Screens: {screens}',
|
|
31
|
+
'share.pack.none': 'none',
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const es = {
|
|
2
|
+
'share.new.command': 'Empieza una extensión construida para compartir en este producto: packages/<clave> con sus propias tablas, palabras neutras, pruebas en su propio producto pequeño y su guía',
|
|
3
|
+
'share.new.key': 'La clave son letras minúsculas y dígitos, empezando por una letra (sms, invoices2)',
|
|
4
|
+
'share.new.product': 'Ejecútelo en un producto: aquí no hay buffcore.config.ts',
|
|
5
|
+
'share.new.exists': '{path} ya existe: elija otra clave, o siga construyendo esa',
|
|
6
|
+
'share.new.made': 'Empezada {path} ({name}). Instálela con pnpm ape add ./{path}; sus pruebas corren con las del producto, y pnpm ape check compatible ./{path} la comprueba como lo hará el catálogo.',
|
|
7
|
+
'share.pack.command': 'Escribe un paquete de envío para el catálogo que nombra el producto: el paquete, su informe de comprobaciones y el escaneo. Nunca publica ni llama a la red',
|
|
8
|
+
'share.pack.out': 'la carpeta donde va el paquete (por defecto .ape/pack)',
|
|
9
|
+
'share.pack.missing': 'No hay extensión en {path} (pnpm ape extension new <clave> empieza una)',
|
|
10
|
+
'share.pack.refused': 'No empaquetada: {count, plural, one {# hallazgo} other {# hallazgos}} que quitar antes (cada uno nombrado, nunca su valor):',
|
|
11
|
+
'share.pack.secret': '{file}:{line}: un secreto ({rule})',
|
|
12
|
+
'share.pack.secretFile': '{file}: un archivo de secretos o datos, por su nombre',
|
|
13
|
+
'share.pack.email': '{file}:{line}: una dirección de correo que parece real (use example.com)',
|
|
14
|
+
'share.pack.phone': '{file}:{line}: un número de teléfono que parece real (use 555-0100 a 555-0199)',
|
|
15
|
+
'share.pack.name': '{file}:{line}: el nombre del propio producto, "{name}" (las palabras de una extensión no nombran ningún producto)',
|
|
16
|
+
'share.pack.nameFile': '{file}: el nombre del propio producto, "{name}", en su ruta',
|
|
17
|
+
'share.pack.hidden': '{file}: un archivo o carpeta oculto, nunca se envía (solo .gitignore, .npmignore y .editorconfig)',
|
|
18
|
+
'share.pack.notText': '{file}: no es texto que pack pueda escanear (un archivo comprimido u otro binario); solo se envían texto, imágenes y fuentes',
|
|
19
|
+
'share.pack.outside': 'El paquete va dentro de .ape/pack/ en el producto: {out} no está ahí',
|
|
20
|
+
'share.pack.notBundle': '{path} existe y no es un paquete que escribió pack; muévalo antes',
|
|
21
|
+
'share.new.installed': '{key} ya está instalada: elija otra clave, o sus tablas chocarían',
|
|
22
|
+
'share.new.reserved': '{key} es un nombre que Windows reserva: elija otra clave',
|
|
23
|
+
'share.pack.done': 'Paquete escrito en {path}, para {catalog}. No se envió nada: una persona lo presenta.',
|
|
24
|
+
'share.pack.noCatalog': 'aún no hay catálogo nombrado en buffcore.config.ts',
|
|
25
|
+
'share.pack.checks': 'Comprobaciones: {state}. El informe es check-report.json.',
|
|
26
|
+
'share.pack.passed': 'pasadas',
|
|
27
|
+
'share.pack.failed': 'aún no pasadas, vea el informe',
|
|
28
|
+
'share.pack.touches': 'Puede tocar: lee {reads}; hosts {hosts}; lugares {places}',
|
|
29
|
+
'share.pack.license': 'Licencia: {license}',
|
|
30
|
+
'share.pack.screens': 'Pantallas: {screens}',
|
|
31
|
+
'share.pack.none': 'ninguno',
|
|
32
|
+
};
|
|
@@ -67,6 +67,7 @@ export declare function settingsFor(path: string, plan: ServerPlan): {
|
|
|
67
67
|
APE_BACKUP_KEY?: string | undefined;
|
|
68
68
|
TURNSTILE_SITE_KEY?: string | undefined;
|
|
69
69
|
TURNSTILE_SECRET_KEY?: string | undefined;
|
|
70
|
+
APE_HOST_KEY_SHA256?: string | undefined;
|
|
70
71
|
};
|
|
71
72
|
appOrigin?: string | undefined;
|
|
72
73
|
};
|
|
@@ -44,6 +44,7 @@ export declare function uiEnvironment(root: string): {
|
|
|
44
44
|
APE_BACKUP_KEY?: string | undefined;
|
|
45
45
|
TURNSTILE_SITE_KEY?: string | undefined;
|
|
46
46
|
TURNSTILE_SECRET_KEY?: string | undefined;
|
|
47
|
+
APE_HOST_KEY_SHA256?: string | undefined;
|
|
47
48
|
};
|
|
48
49
|
hostLaunched: boolean;
|
|
49
50
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type OutsideMergeReply, type Viewer } from '@buffcore/contracts/workbench';
|
|
2
|
+
import type { HostOutside } from './outside.ts';
|
|
3
|
+
import type { UiRoute } from './routes.ts';
|
|
4
|
+
/** After a timeout or a closed studio, the lock waits this many time limits for `act` to settle. */
|
|
5
|
+
export declare const HOLD_FACTOR = 4;
|
|
6
|
+
/**
|
|
7
|
+
* One call to the host's `act`, in the studio's one merge queue: it waits for no one and refuses
|
|
8
|
+
* while another merge holds the lock (as a studio merge does). The Autopilot merge hold stops only
|
|
9
|
+
* Autopilot, so it does not refuse a person's outside Merge, as it does not refuse an inside one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function outsideMerge(root: string, outside: HostOutside, viewer: Readonly<Viewer>, change: string, stop?: AbortSignal): Promise<OutsideMergeReply>;
|
|
12
|
+
/** Person-only, like `/api/merge`: no MCP tool and no Autopilot path calls it. */
|
|
13
|
+
export declare function outsideMergeRoute(root: string): UiRoute;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { outsideActAnswerSchema, outsideMergeBodySchema, workbenchApi, } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { defaultMergeTools } from '../change-merge.js';
|
|
3
|
+
import { serialized } from '../change-merge-serial.js';
|
|
4
|
+
import { hostCall } from './host-call.js';
|
|
5
|
+
import { studioT } from './studio-messages.js';
|
|
6
|
+
const DEFAULT_TIMEOUT = 5_000;
|
|
7
|
+
/** After a timeout or a closed studio, the lock waits this many time limits for `act` to settle. */
|
|
8
|
+
export const HOLD_FACTOR = 4;
|
|
9
|
+
const status = { merged: 200, pending: 202 };
|
|
10
|
+
/**
|
|
11
|
+
* One call to the host's `act`, in the studio's one merge queue: it waits for no one and refuses
|
|
12
|
+
* while another merge holds the lock (as a studio merge does). The Autopilot merge hold stops only
|
|
13
|
+
* Autopilot, so it does not refuse a person's outside Merge, as it does not refuse an inside one.
|
|
14
|
+
*/
|
|
15
|
+
export async function outsideMerge(root, outside, viewer, change, stop) {
|
|
16
|
+
const act = outside.changes?.act;
|
|
17
|
+
if (!act)
|
|
18
|
+
return { status: 'error' };
|
|
19
|
+
// The same frozen viewer the reads get: the host's code cannot widen its own rights.
|
|
20
|
+
const verified = {
|
|
21
|
+
...viewer,
|
|
22
|
+
rights: viewer.rights === 'all' ? 'all' : [...viewer.rights],
|
|
23
|
+
};
|
|
24
|
+
if (verified.rights !== 'all')
|
|
25
|
+
Object.freeze(verified.rights);
|
|
26
|
+
Object.freeze(verified);
|
|
27
|
+
const timeout = outside.timeoutMs ?? DEFAULT_TIMEOUT;
|
|
28
|
+
const answered = Promise.withResolvers();
|
|
29
|
+
const queued = serialized(root, `outside ${change}`, defaultMergeTools, async () => {
|
|
30
|
+
let running = Promise.resolve();
|
|
31
|
+
const reply = await hostCall((signal) => {
|
|
32
|
+
running = Promise.resolve().then(() => act(Object.freeze({ viewer: verified, change, signal })));
|
|
33
|
+
return running;
|
|
34
|
+
}, (answer) => {
|
|
35
|
+
const parsed = outsideActAnswerSchema.safeParse(answer);
|
|
36
|
+
return parsed.success ? parsed.data : { status: 'error' };
|
|
37
|
+
}, (reason) => ({ status: reason }), timeout, stop);
|
|
38
|
+
// A settled `act` frees the queue before the answer is sent. One still running (a timeout, a
|
|
39
|
+
// closed studio) has its signal aborted, but the host may still be merging: the answer goes out
|
|
40
|
+
// now and the queue stays taken until it settles, for at most HOLD_FACTOR time limits.
|
|
41
|
+
if (await settledWithin(running, 0))
|
|
42
|
+
return reply;
|
|
43
|
+
answered.resolve(reply);
|
|
44
|
+
if (!(await settledWithin(running, timeout * HOLD_FACTOR)))
|
|
45
|
+
console.error(studioT('ui.outside.lockReleased', { change, ms: timeout * HOLD_FACTOR }));
|
|
46
|
+
return reply;
|
|
47
|
+
}).then((result) => ('ok' in result ? { status: 'busy' } : result), () => ({ status: 'error' }));
|
|
48
|
+
return Promise.race([answered.promise, queued]);
|
|
49
|
+
}
|
|
50
|
+
async function settledWithin(running, bound) {
|
|
51
|
+
let timer;
|
|
52
|
+
const late = new Promise((done) => {
|
|
53
|
+
timer = setTimeout(() => done(false), bound);
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
return await Promise.race([
|
|
57
|
+
running.then(() => true, () => true),
|
|
58
|
+
late,
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Person-only, like `/api/merge`: no MCP tool and no Autopilot path calls it. */
|
|
66
|
+
export function outsideMergeRoute(root) {
|
|
67
|
+
return {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
path: workbenchApi.outsideMerge,
|
|
70
|
+
right: 'build',
|
|
71
|
+
origin: true,
|
|
72
|
+
handle: async ({ hosted, outside, identity, body, stop, signal }) => {
|
|
73
|
+
if (!hosted || !outside?.changes?.act || !identity)
|
|
74
|
+
return { status: 404, body: { error: studioT('ui.outside.unavailable') } };
|
|
75
|
+
const parsed = outsideMergeBodySchema.safeParse(await body());
|
|
76
|
+
if (!parsed.success)
|
|
77
|
+
return { status: 400, body: { error: studioT('ui.outside.invalid') } };
|
|
78
|
+
// Only the studio closing stops the host's merge: a closed connection does not.
|
|
79
|
+
const reply = await outsideMerge(root, outside, identity.viewer, parsed.data.change, stop ?? signal);
|
|
80
|
+
return { status: answered(reply) ? status[reply.status] : 409, body: reply };
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const answered = (reply) => reply.status === 'merged' || reply.status === 'pending';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type OutsideReply, type OutsideState, type Viewer } from '@buffcore/contracts/workbench';
|
|
1
|
+
import { type OutsideActAnswer, type OutsideReply, type OutsideState, type Viewer } from '@buffcore/contracts/workbench';
|
|
2
2
|
export type HostOutsideReadInput = Readonly<{
|
|
3
3
|
viewer: Readonly<Viewer>;
|
|
4
4
|
signal: AbortSignal;
|
|
@@ -25,10 +25,13 @@ export type HostOutside = Readonly<{
|
|
|
25
25
|
}>) => Promise<AnswerResult>;
|
|
26
26
|
};
|
|
27
27
|
changes?: HostSource & {
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A person pressed Merge on this change: merge it (the host checks the id is one it listed and
|
|
30
|
+
* that this viewer may merge it), or answer `refused` with a code, or `pending`.
|
|
31
|
+
*/
|
|
29
32
|
act?: (input: HostOutsideReadInput & Readonly<{
|
|
30
33
|
change: string;
|
|
31
|
-
}>) => Promise<
|
|
34
|
+
}>) => Promise<OutsideActAnswer>;
|
|
32
35
|
};
|
|
33
36
|
timeoutMs?: number;
|
|
34
37
|
}>;
|
|
@@ -50,7 +53,7 @@ export declare function checkedOutside(outside: HostOutside | undefined, signedI
|
|
|
50
53
|
read: (input: HostOutsideReadInput) => Promise<unknown>;
|
|
51
54
|
act: ((input: HostOutsideReadInput & Readonly<{
|
|
52
55
|
change: string;
|
|
53
|
-
}>) => Promise<
|
|
56
|
+
}>) => Promise<OutsideActAnswer>) | undefined;
|
|
54
57
|
} | undefined;
|
|
55
58
|
timeoutMs: number;
|
|
56
59
|
} | undefined;
|
|
@@ -17,6 +17,8 @@ export function checkedOutside(outside, signedIn) {
|
|
|
17
17
|
typeof registration.read !== 'function')
|
|
18
18
|
throw new Error(studioT('ui.outside.source'));
|
|
19
19
|
}
|
|
20
|
+
if (changes?.act !== undefined && typeof changes.act !== 'function')
|
|
21
|
+
throw new Error(studioT('ui.outside.source'));
|
|
20
22
|
if (!issues && !changes)
|
|
21
23
|
return;
|
|
22
24
|
return {
|
|
@@ -32,6 +34,7 @@ export function outsideState(outside) {
|
|
|
32
34
|
...(outside.issues ? { issues: { source: outside.issues.source } } : {}),
|
|
33
35
|
...(outside.changes ? { changes: { source: outside.changes.source } } : {}),
|
|
34
36
|
...(typeof outside.issues?.answer === 'function' ? { answers: true } : {}),
|
|
37
|
+
...(typeof outside.changes?.act === 'function' ? { merges: true } : {}),
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
async function readSource(registration, schema, viewer, timeoutMs, stop) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type PlanFacts } from '@buffcore/contracts/workbench';
|
|
2
|
+
/**
|
|
3
|
+
* `plan/extensions.md`: one line per capability the product needs, with the plan's answer for it.
|
|
4
|
+
*
|
|
5
|
+
* - use: uploads - photos on each job
|
|
6
|
+
* - build to share: sms - texting customers, as any shop would (extra: about half a day)
|
|
7
|
+
*
|
|
8
|
+
* Only bullet lines are read; headings, prose and comments are the person's and stay as written,
|
|
9
|
+
* so an edit anywhere else keeps every kind. An unknown kind is a problem, never a guess.
|
|
10
|
+
*/
|
|
11
|
+
export type PlanExtension = NonNullable<PlanFacts['extensions']>[number];
|
|
12
|
+
export interface PlanExtensionProblem {
|
|
13
|
+
line: number;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Close to a kind: a typo of one, at most one edit for a kind of four letters or fewer (`use`),
|
|
18
|
+
* two for a longer one (`requst`, `improv`, `build to shre`). `note`, `todo` and `ask` stay prose.
|
|
19
|
+
*/
|
|
20
|
+
export declare const nearKind: (head: string) => boolean;
|
|
21
|
+
export declare function parsePlanExtensions(text: string): {
|
|
22
|
+
extensions: PlanExtension[];
|
|
23
|
+
problems: PlanExtensionProblem[];
|
|
24
|
+
};
|
|
25
|
+
/** One line in the file's form; `parsePlanExtensions` reads back exactly what it was given. */
|
|
26
|
+
export declare function planExtensionLine(e: PlanExtension): string;
|
|
27
|
+
/** The studio's read: the known lines, or absent when the file is missing, linked or too big. */
|
|
28
|
+
export declare function readPlanExtensions(root: string): Promise<PlanExtension[] | null>;
|
|
29
|
+
/** `ape change`'s check of the file: each line it cannot read, as a change file's problems are. */
|
|
30
|
+
export declare function planExtensionProblems(root: string): Promise<{
|
|
31
|
+
file: string;
|
|
32
|
+
field: string;
|
|
33
|
+
message: string;
|
|
34
|
+
}[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
readonly 'planExtensions.kind': '"{kind}" is not a kind. Write one of: use, improve, build to share, request, product only (as "- build to share: <name> - <why>")';
|
|
3
|
+
readonly 'planExtensions.form': 'not in the form "- <kind>: <name> - <why>", with "(extra: <cost>)" at the end when it is built to share';
|
|
4
|
+
};
|