@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.
Files changed (89) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/commands/change-merge-serial.d.ts +6 -2
  3. package/dist/commands/change-merge-serial.js +5 -1
  4. package/dist/commands/change.js +3 -0
  5. package/dist/commands/check-skills.d.ts +16 -0
  6. package/dist/commands/check-skills.en.d.ts +14 -0
  7. package/dist/commands/check-skills.en.js +14 -0
  8. package/dist/commands/check-skills.es.d.ts +2 -0
  9. package/dist/commands/check-skills.es.js +14 -0
  10. package/dist/commands/check-skills.js +146 -0
  11. package/dist/commands/check.js +5 -0
  12. package/dist/commands/extension/config-text.d.ts +2 -0
  13. package/dist/commands/extension/config-text.js +2 -0
  14. package/dist/commands/extension/index.js +14 -2
  15. package/dist/commands/extension/new.d.ts +16 -0
  16. package/dist/commands/extension/new.js +52 -0
  17. package/dist/commands/extension/pack-files.d.ts +23 -0
  18. package/dist/commands/extension/pack-files.js +78 -0
  19. package/dist/commands/extension/pack-scan.d.ts +24 -0
  20. package/dist/commands/extension/pack-scan.js +131 -0
  21. package/dist/commands/extension/pack.d.ts +48 -0
  22. package/dist/commands/extension/pack.js +142 -0
  23. package/dist/commands/extension/share-text.d.ts +3 -0
  24. package/dist/commands/extension/share-text.js +6 -0
  25. package/dist/commands/extension/share.en.d.ts +32 -0
  26. package/dist/commands/extension/share.en.js +32 -0
  27. package/dist/commands/extension/share.es.d.ts +2 -0
  28. package/dist/commands/extension/share.es.js +32 -0
  29. package/dist/commands/server/setup.d.ts +1 -0
  30. package/dist/commands/ui/index.d.ts +1 -0
  31. package/dist/commands/ui/outside-merge.d.ts +13 -0
  32. package/dist/commands/ui/outside-merge.js +84 -0
  33. package/dist/commands/ui/outside.d.ts +7 -4
  34. package/dist/commands/ui/outside.js +3 -0
  35. package/dist/commands/ui/plan-extensions.d.ts +34 -0
  36. package/dist/commands/ui/plan-extensions.en.d.ts +4 -0
  37. package/dist/commands/ui/plan-extensions.en.js +4 -0
  38. package/dist/commands/ui/plan-extensions.es.d.ts +2 -0
  39. package/dist/commands/ui/plan-extensions.es.js +4 -0
  40. package/dist/commands/ui/plan-extensions.js +86 -0
  41. package/dist/commands/ui/plan-files.js +4 -1
  42. package/dist/commands/ui/prototype-main.d.ts +6 -0
  43. package/dist/commands/ui/studio-routes.js +2 -0
  44. package/dist/commands/ui/studio-state.d.ts +7 -0
  45. package/dist/commands/ui/studio.en.d.ts +2 -0
  46. package/dist/commands/ui/studio.en.js +2 -0
  47. package/dist/commands/ui/studio.es.d.ts +2 -0
  48. package/dist/commands/ui/studio.es.js +2 -0
  49. package/dist/commands/upgrade.js +1 -1
  50. package/dist/ui/page.js +82 -82
  51. package/docs/EXTENSIONS.md +6 -0
  52. package/docs/WORKBENCH.md +25 -2
  53. package/package.json +11 -11
  54. package/skills/ape-add-ai-purpose/SKILL.md +1 -1
  55. package/skills/ape-add-event/SKILL.md +1 -1
  56. package/skills/ape-add-extension/SKILL.md +5 -1
  57. package/skills/ape-add-feature/SKILL.md +1 -1
  58. package/skills/ape-add-generator/SKILL.md +1 -1
  59. package/skills/ape-add-module/SKILL.md +1 -1
  60. package/skills/ape-add-route/SKILL.md +3 -1
  61. package/skills/ape-add-service/SKILL.md +1 -1
  62. package/skills/ape-add-translations/SKILL.md +2 -2
  63. package/skills/ape-admin-screen/SKILL.md +1 -1
  64. package/skills/ape-app-screen/SKILL.md +1 -1
  65. package/skills/ape-critique/SKILL.md +11 -32
  66. package/skills/ape-critique/references/after.md +15 -0
  67. package/skills/ape-critique/references/spacing-pass.md +20 -0
  68. package/skills/ape-deploy/SKILL.md +4 -1
  69. package/skills/ape-design-system/SKILL.md +15 -15
  70. package/skills/ape-design-system/references/by-hand.md +7 -0
  71. package/skills/ape-design-system/references/reference-study.md +11 -0
  72. package/skills/ape-diagnose/SKILL.md +24 -0
  73. package/skills/ape-migration/SKILL.md +1 -1
  74. package/skills/ape-plan-change/SKILL.md +37 -31
  75. package/skills/ape-plan-change/references/change-file-fields.md +5 -0
  76. package/skills/ape-plan-change/references/extensions.md +25 -0
  77. package/skills/ape-plan-change/references/finishing.md +3 -0
  78. package/skills/ape-plan-change/references/fix-from-error.md +3 -0
  79. package/skills/ape-plan-change/references/refactor.md +9 -0
  80. package/skills/ape-plan-change/references/structure.md +19 -0
  81. package/skills/ape-prototype/SKILL.md +13 -23
  82. package/skills/ape-prototype/references/comp.md +3 -0
  83. package/skills/ape-prototype/references/scope-and-export.md +5 -0
  84. package/skills/ape-prototype/references/snapshot.md +3 -0
  85. package/skills/ape-prototype/references/structure.md +11 -0
  86. package/skills/ape-prototype/references/working-app.md +7 -0
  87. package/skills/ape-request/SKILL.md +1 -1
  88. package/skills/ape-upgrade/SKILL.md +4 -1
  89. package/templates/product/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ export const en = {
2
+ '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
+ 'planExtensions.form': 'not in the form "- <kind>: <name> - <why>", with "(extra: <cost>)" at the end when it is built to share',
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { en } from './plan-extensions.en.ts';
2
+ export declare const es: Record<keyof typeof en, string>;
@@ -0,0 +1,4 @@
1
+ export const es = {
2
+ 'planExtensions.kind': '"{kind}" no es un tipo. Escriba uno de: use, improve, build to share, request, product only (como "- build to share: <nombre> - <por qué>")',
3
+ 'planExtensions.form': 'no tiene la forma "- <tipo>: <nombre> - <por qué>", con "(extra: <costo>)" al final cuando se construye para compartir',
4
+ };
@@ -0,0 +1,86 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { PLAN_EXTENSION_KINDS, } from '@buffcore/contracts/workbench';
4
+ import { createI18n } from '@buffcore/i18n';
5
+ import { artifact } from './plan-artifact.js';
6
+ import { en } from './plan-extensions.en.js';
7
+ import { es } from './plan-extensions.es.js';
8
+ const messages = createI18n({ catalogs: [{ en, es }] });
9
+ const t = (key, values) => messages.t(/^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en', key, values);
10
+ const LINE = /^\s*[-*]\s+([^:]+?):\s+(\S+)(?:\s+[-–—]\s+(.*?))?(?:\s*\(extra:\s*([^)]*)\))?\s*$/i;
11
+ const MAX = 100;
12
+ const isKind = (kind) => PLAN_EXTENSION_KINDS.includes(kind);
13
+ /** Edits (insert, delete, change one letter) to turn one word into the other. */
14
+ function distance(a, b) {
15
+ let row = Array.from({ length: b.length + 1 }, (_, i) => i);
16
+ for (let i = 1; i <= a.length; i++) {
17
+ const next = [i];
18
+ for (let j = 1; j <= b.length; j++)
19
+ next[j] = Math.min((row[j] ?? 0) + 1, (next[j - 1] ?? 0) + 1, (row[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1));
20
+ row = next;
21
+ }
22
+ return row[b.length] ?? 0;
23
+ }
24
+ /**
25
+ * Close to a kind: a typo of one, at most one edit for a kind of four letters or fewer (`use`),
26
+ * two for a longer one (`requst`, `improv`, `build to shre`). `note`, `todo` and `ask` stay prose.
27
+ */
28
+ export const nearKind = (head) => PLAN_EXTENSION_KINDS.some((kind) => distance(head, kind) <= (kind.length <= 4 ? 1 : 2));
29
+ export function parsePlanExtensions(text) {
30
+ const extensions = [];
31
+ const problems = [];
32
+ // Comments become blank lines of the same count, so line numbers stay the file's own.
33
+ const lines = text
34
+ .replace(/<!--[\s\S]*?-->/g, (comment) => comment.replace(/[^\n]/g, ''))
35
+ .split(/\r?\n/);
36
+ for (const [index, raw] of lines.entries()) {
37
+ // Only a top-level bullet whose words before the colon are a kind, or close to one (a typo), is a
38
+ // line of the list. Any other bullet (`- note: …`, `- todo: …`), and a nested sub-point, is the
39
+ // person's prose and stays as written.
40
+ const head = /^[-*]\s+([a-z]+(?: [a-z]+){0,2}):(?:\s|$)/i.exec(raw)?.[1];
41
+ if (!head || !nearKind(head.toLowerCase()))
42
+ continue;
43
+ const line = index + 1;
44
+ const match = LINE.exec(raw);
45
+ if (!match) {
46
+ problems.push({ line, message: t('planExtensions.form') });
47
+ continue;
48
+ }
49
+ const kind = (match[1] ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
50
+ if (!isKind(kind)) {
51
+ problems.push({ line, message: t('planExtensions.kind', { kind }) });
52
+ continue;
53
+ }
54
+ if (extensions.length === MAX)
55
+ continue;
56
+ const why = match[3]?.trim();
57
+ const extra = match[4]?.trim();
58
+ extensions.push({
59
+ kind,
60
+ name: match[2].slice(0, 4000),
61
+ ...(why ? { why: why.slice(0, 4000) } : {}),
62
+ ...(extra ? { extra: extra.slice(0, 4000) } : {}),
63
+ });
64
+ }
65
+ return { extensions, problems };
66
+ }
67
+ /** One line in the file's form; `parsePlanExtensions` reads back exactly what it was given. */
68
+ export function planExtensionLine(e) {
69
+ return `- ${e.kind}: ${e.name}${e.why ? ` - ${e.why}` : ''}${e.extra ? ` (extra: ${e.extra})` : ''}`;
70
+ }
71
+ /** The studio's read: the known lines, or absent when the file is missing, linked or too big. */
72
+ export async function readPlanExtensions(root) {
73
+ return artifact(root, 'extensions.md', (text) => parsePlanExtensions(text).extensions);
74
+ }
75
+ /** `ape change`'s check of the file: each line it cannot read, as a change file's problems are. */
76
+ export async function planExtensionProblems(root) {
77
+ const file = 'plan/extensions.md';
78
+ const text = await readFile(join(root, file), 'utf8').catch(() => null);
79
+ if (text === null)
80
+ return [];
81
+ return parsePlanExtensions(text).problems.map((p) => ({
82
+ file,
83
+ field: String(p.line),
84
+ message: p.message,
85
+ }));
86
+ }
@@ -7,6 +7,7 @@ import { resolveMode } from '../design/state.js';
7
7
  import { brandMatches, brandPreview } from './brand-approval.js';
8
8
  import { answer, parseBrief, plain, withoutComments } from './plan-brief.js';
9
9
  import { changeDetail } from './plan-details.js';
10
+ import { readPlanExtensions } from './plan-extensions.js';
10
11
  import { planHistory } from './plan-history.js';
11
12
  import { parseJourneys } from './plan-journeys.js';
12
13
  import { readNotThis } from './plan-not.js';
@@ -166,7 +167,7 @@ async function readBrand(root, hostedAuthority = false) {
166
167
  }
167
168
  }
168
169
  export async function readPlan(root, hostedAuthority = false) {
169
- const [brief, milestones, journeys, changes, brand, structure, notThis] = await Promise.all([
170
+ const [brief, milestones, journeys, changes, brand, structure, notThis, extensions] = await Promise.all([
170
171
  readBrief(root),
171
172
  readRoadmap(root),
172
173
  readJourneys(root),
@@ -174,10 +175,12 @@ export async function readPlan(root, hostedAuthority = false) {
174
175
  readBrand(root, hostedAuthority),
175
176
  structureFacts(root),
176
177
  readNotThis(root),
178
+ readPlanExtensions(root),
177
179
  ]);
178
180
  return {
179
181
  brief,
180
182
  milestones,
183
+ ...(extensions ? { extensions } : {}),
181
184
  journeys,
182
185
  notThis,
183
186
  ...(structure ? { structure } : {}),
@@ -16,6 +16,12 @@ export declare function planPrototypeOnMain(root: string, plan: PlanFacts | unde
16
16
  name: string;
17
17
  changes: string[];
18
18
  }[];
19
+ extensions?: {
20
+ kind: "build to share" | "improve" | "product only" | "request" | "use";
21
+ name: string;
22
+ why?: string | undefined;
23
+ extra?: string | undefined;
24
+ }[] | undefined;
19
25
  changes: {
20
26
  id: string;
21
27
  title: string;
@@ -11,6 +11,7 @@ import { levelRoute } from './level-route.js';
11
11
  import { mergeRoutes } from './merge-route.js';
12
12
  import { mergeStudio } from './merge-state.js';
13
13
  import { outsideState } from './outside.js';
14
+ import { outsideMergeRoute } from './outside-merge.js';
14
15
  import { outsideRoute } from './outside-route.js';
15
16
  import { prototypeCompRoutes } from './prototype-comp-route.js';
16
17
  import { planPrototypeOnMain } from './prototype-main.js';
@@ -91,6 +92,7 @@ cached = false) {
91
92
  ...prototypeCompRoutes(root),
92
93
  structureSurfaceRoute(root),
93
94
  outsideRoute,
95
+ outsideMergeRoute(root),
94
96
  {
95
97
  method: 'GET',
96
98
  path: '/api/studio',
@@ -205,6 +205,12 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
205
205
  name: string;
206
206
  changes: string[];
207
207
  }[];
208
+ extensions?: {
209
+ kind: "build to share" | "improve" | "product only" | "request" | "use";
210
+ name: string;
211
+ why?: string | undefined;
212
+ extra?: string | undefined;
213
+ }[] | undefined;
208
214
  changes: {
209
215
  id: string;
210
216
  title: string;
@@ -376,6 +382,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
376
382
  source: string;
377
383
  } | undefined;
378
384
  answers?: true | undefined;
385
+ merges?: true | undefined;
379
386
  } | undefined;
380
387
  release?: {
381
388
  commit: string;
@@ -17,6 +17,8 @@ export declare const en: {
17
17
  'ui.outside.signIn': string;
18
18
  'ui.outside.timeout': string;
19
19
  'ui.outside.source': string;
20
+ 'ui.outside.invalid': string;
21
+ 'ui.outside.lockReleased': string;
20
22
  'ui.outside.unavailable': string;
21
23
  'ui.address.local': string;
22
24
  'ui.studio': string;
@@ -17,6 +17,8 @@ export const en = {
17
17
  'ui.outside.signIn': 'Outside sources need host sign-in.',
18
18
  'ui.outside.timeout': 'The outside source time limit must be a whole number from 1 to 30,000 milliseconds.',
19
19
  'ui.outside.source': 'An outside source needs a plain-text name of 1 to 40 characters and a read hook.',
20
+ 'ui.outside.invalid': 'Name one outside change to merge.',
21
+ 'ui.outside.lockReleased': 'ape studio: the host had not ended its outside merge of {change} {ms} ms after its answer was due; the merge queue is free again.',
20
22
  'ui.outside.unavailable': 'No outside sources are available.',
21
23
  'ui.address.local': "Only this computer's own address opens the studio.",
22
24
  'ui.studio': 'Open the studio on real state (preview)',
@@ -2,6 +2,8 @@ export declare const es: {
2
2
  'ui.outside.signIn': string;
3
3
  'ui.outside.timeout': string;
4
4
  'ui.outside.source': string;
5
+ 'ui.outside.invalid': string;
6
+ 'ui.outside.lockReleased': string;
5
7
  'ui.outside.unavailable': string;
6
8
  'ui.title': string;
7
9
  'ui.theme.refused': string;
@@ -2,6 +2,8 @@ export const es = {
2
2
  'ui.outside.signIn': 'Las fuentes externas requieren iniciar sesión a través del anfitrión.',
3
3
  'ui.outside.timeout': 'El límite de tiempo de la fuente externa debe ser un número entero entre 1 y 30.000 milisegundos.',
4
4
  'ui.outside.source': 'Una fuente externa necesita un nombre en texto sin formato de 1 a 40 caracteres y una función de lectura.',
5
+ 'ui.outside.invalid': 'Indica un cambio externo para fusionar.',
6
+ 'ui.outside.lockReleased': 'ape studio: el anfitrión no había terminado su fusión externa de {change} {ms} ms después del plazo de su respuesta; la cola de fusiones vuelve a estar libre.',
5
7
  'ui.outside.unavailable': 'No hay fuentes externas disponibles.',
6
8
  'ui.title': 'Estudio de {name}',
7
9
  'ui.theme.refused': 'El estudio no puede iniciarse con este tema ({count} problemas):',
@@ -192,7 +192,7 @@ export async function runUpgrade(root, target, steps, json = false) {
192
192
  if (json)
193
193
  console.log(JSON.stringify({ ok, from, to, places, message }));
194
194
  else if (ok)
195
- log(`Upgraded from ${from} to ${to}: migrated, and the tests pass.\nNext: work through the notes above, run pnpm verify, and say what changed in the pull request (the ape-upgrade skill).`);
195
+ log(`Upgraded from ${from} to ${to}: migrated, and the tests pass.\nNext: work through the notes above, run pnpm verify, and say what changed in the pull request (read .claude/skills/ape-upgrade/SKILL.md).`);
196
196
  return ok;
197
197
  }
198
198
  /**