gcf-aif-ext 0.16.1 → 0.18.3

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/lib/design.js CHANGED
@@ -23,6 +23,8 @@ export const HEADER_KEYS = [
23
23
  'flags',
24
24
  'reopens',
25
25
  ];
26
+ // GCF-PRD §5.3: no more than 7 pillars.
27
+ export const PILLARS_MAX = 7;
26
28
  // Engineering decisions of the agent, not words of the designer: no provenance needed.
27
29
  export const AGENT_SLOTS = ['check', 'measure', 'contract', 'interactions'];
28
30
 
package/lib/domain.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // draws these and builds each command from `args` and `fields`; it hard-codes none of them.
5
5
  import { ITEM_MOVES, STORED } from './transitions.js';
6
6
  import { DEFAULT_GATE, GATES, ITEM_TYPES, SEVERITIES, UNIT_ITEM_TYPES } from './validate-item.js';
7
- import { SOURCES } from './inbox.js';
7
+ import { BASE_CATEGORIES, mergeVocabulary, questionOnly } from './inbox-categories.js';
8
8
  import { NOTE_MAX } from './work-ops.js';
9
9
  import { SESSION_TTL_MS } from './session-mark.js';
10
10
  import { RUN_MODES } from './gcf-paths.js';
@@ -72,12 +72,12 @@ const decide = (choice, help, fields = [], danger) => ({
72
72
  ...(danger && { danger }),
73
73
  });
74
74
  const text = (key, label, extra = {}) => ({ key, label, kind: 'text', ...extra });
75
- // How an item's run goes: a board offers its agent's presets (`presets`), and `default`, which
76
- // leaves the choice to the project's `agent.model|effort`, else the agent; a word of the
77
- // operator's own goes too.
78
- const PICKS = "default: the project's, else the agent picks";
79
- const MODEL = text('model', 'Model of its run', { presets: 'model', help: PICKS });
80
- const EFFORT = text('effort', 'Effort of its run', { presets: 'effort', help: PICKS });
75
+ // How an item's run goes (decision 36): a board offers Default (`default`), which leaves the
76
+ // choice to the project's `agent.model|effort`, else the agent's defaults (Opus, High), then its
77
+ // agent's presets (`presets`). The console takes any word.
78
+ const picks = (d) => `Default: the project's setting, else ${d}`;
79
+ const MODEL = text('model', 'Model of its run', { presets: 'model', help: picks('Opus') });
80
+ const EFFORT = text('effort', 'Effort of its run', { presets: 'effort', help: picks('High') });
81
81
  // Where an item's runs go (Methodology §7): the operator's choice over the project's run_mode;
82
82
  // the framework does not judge which a project's work needs.
83
83
  const RUN_MODE_HELP = {
@@ -230,11 +230,10 @@ const RUN = {
230
230
  // shows the proposal, the operator's click makes it.
231
231
  const NEW_ITEM = {
232
232
  label: 'create',
233
- help: 'A new work item, committed; the core refuses a type the phase does not take',
234
- args: ['gcf', 'item', 'new', '{id}', '--commit'],
233
+ help: 'A new work item, committed; its id comes from the title; the core refuses a type the phase does not take',
234
+ args: ['gcf', 'item', 'new', '--commit'],
235
235
  propose: true,
236
236
  fields: [
237
- { key: 'id', label: 'Id (lowercase-hyphen slug)', kind: 'slug', required: true },
238
237
  {
239
238
  key: 'type',
240
239
  label: 'Type',
@@ -266,11 +265,13 @@ const NEW_ITEM = {
266
265
  },
267
266
  text('release', 'Version', { required: true, when: { key: 'type', is: ['release'] } }),
268
267
  text('channel', 'Channel', { required: true, when: { key: 'type', is: ['release'] } }),
269
- text('title', 'Title: one line, what it gives'),
268
+ text('title', 'Title: one line, what it gives', { required: true }),
270
269
  text('system', 'Subsystems, comma-separated'),
271
- { key: 'depends', label: 'Depends on ids, comma-separated', kind: 'ids' },
272
- text('parent', 'Parent feature id'),
273
- text('milestone', 'Milestone'),
270
+ { key: 'depends', label: 'Depends on', kind: 'ids' },
271
+ // One live feature, picked by its title (decision 34).
272
+ { key: 'parent', label: 'Parent feature', kind: 'ids', single: true, of: ['feature'] },
273
+ // A milestone of game.md: a board picks it from the read's `design.milestones` (`from`).
274
+ text('milestone', 'Milestone', { from: 'milestones' }),
274
275
  text('blocked', 'Start blocked: why (e.g. "file needed")'),
275
276
  MODEL,
276
277
  EFFORT,
@@ -287,6 +288,294 @@ const NEW_ITEM = {
287
288
  ],
288
289
  };
289
290
 
291
+ // A part of the design a save names (`gcf design part`): its kind, and the hash it was read at.
292
+ const PART_FIELDS = [
293
+ {
294
+ key: 'kind',
295
+ label: 'Part',
296
+ kind: 'choice',
297
+ required: true,
298
+ hidden: true,
299
+ options: ['doc', 'system', 'unit'].map((k) => ({ value: k, label: k })),
300
+ },
301
+ text('base', 'Read at', { hidden: true }),
302
+ text('system', 'Subsystem of a new unit', { hidden: true }),
303
+ text('type', 'Type of a new unit', { hidden: true }),
304
+ text('title', 'Title of a new unit', { hidden: true }),
305
+ ];
306
+
307
+ // The design's moves (Board-PRD §5.24): a part saved from its form or as text, a session's
308
+ // files recorded, a designer's bundle brought back, a new unit, a draft discarded, a pillar retired, a unit dropped.
309
+ // Every save goes through the import's three-way check and the design check.
310
+ const DESIGN_SPECS = {
311
+ 'design-save': {
312
+ label: 'save',
313
+ help: 'Save the edited fields; refused when the part changed since, or on a new finding',
314
+ args: ['gcf', 'design', 'save', '{id}'],
315
+ fields: [
316
+ ...PART_FIELDS,
317
+ // The edited fields as JSON, key → value: a form builds it, not the operator.
318
+ { key: 'fields', label: 'Fields', kind: 'longtext', required: true, stdin: true },
319
+ ],
320
+ },
321
+ 'design-save-text': {
322
+ label: 'save text',
323
+ help: 'Save the part as text: for what a form cannot hold (a comment, prose)',
324
+ args: ['gcf', 'design', 'save', '{id}'],
325
+ fields: [
326
+ ...PART_FIELDS,
327
+ { key: 'text', label: 'Text', kind: 'longtext', required: true, stdin: true },
328
+ ],
329
+ },
330
+ 'design-commit': {
331
+ label: 'record design',
332
+ help: 'Commit what a design session wrote; refused while the design check has a finding',
333
+ args: ['gcf', 'design', 'commit'],
334
+ fields: [text('message', 'What changed, one line')],
335
+ },
336
+ 'design-import': {
337
+ label: 'import',
338
+ help: "Bring a designer's edited bundle back: what changed in gcf/ meanwhile is reported",
339
+ args: ['gcf', 'design', 'import', '--commit'],
340
+ fields: [{ key: 'bundle', label: 'Bundle', kind: 'longtext', required: true, stdin: true }],
341
+ },
342
+ 'design-new-unit': {
343
+ label: 'add unit',
344
+ help: 'A new unit of the subsystem, its slots TBD; its id comes from the title',
345
+ args: ['gcf', 'design', 'save', '--kind', 'unit'],
346
+ fields: [
347
+ text('system', 'Subsystem', { required: true }),
348
+ {
349
+ key: 'type',
350
+ label: 'Type',
351
+ kind: 'choice',
352
+ required: true,
353
+ options: UNIT_ITEM_TYPES.map((t) => ({ value: t, label: t })),
354
+ },
355
+ text('title', 'Title', { required: true }),
356
+ {
357
+ key: 'fields',
358
+ label: 'Fields',
359
+ kind: 'longtext',
360
+ required: true,
361
+ stdin: true,
362
+ hidden: true,
363
+ },
364
+ ],
365
+ },
366
+ 'design-discard': {
367
+ label: 'discard draft',
368
+ help: "The agent's draft not recorded goes: its files as the last record has them",
369
+ args: ['gcf', 'design', 'discard'],
370
+ fields: [],
371
+ danger: true,
372
+ },
373
+ 'pillar-retire': {
374
+ label: 'retire',
375
+ help: 'The game no longer holds it: units left with no pillar read pillars: TBD',
376
+ args: ['gcf', 'pillar', 'retire', '{id}'],
377
+ fields: [REASON],
378
+ danger: true,
379
+ },
380
+ 'unit-drop': {
381
+ label: 'drop',
382
+ help: 'The unit leaves the design into the graveyard, with the reason',
383
+ args: ['gcf', 'drop', '{id}'],
384
+ fields: [REASON, { key: 'tags', label: 'Graveyard tags', kind: 'tags' }],
385
+ danger: true,
386
+ },
387
+ };
388
+
389
+ // What an agent does for the design from the board (Board-PRD §5.24): each start opens a
390
+ // project chat thread that follows its skill, not gcf-chat, with the first message `say`
391
+ // (`{file}`: an uploaded GDD, `{unit}`: a unit id, `{system}`: a subsystem, `{text}`: the
392
+ // operator's words). `edits`: the
393
+ // files its agent writes without a permission card; everything else still asks.
394
+ const DESIGN_EDITS = [
395
+ 'gcf/game.md',
396
+ 'gcf/glossary.md',
397
+ 'gcf/backlog.md',
398
+ 'gcf/open-questions.md',
399
+ 'gcf/INDEX.md',
400
+ 'gcf/design/**',
401
+ ];
402
+ const STARTS = {
403
+ vision: {
404
+ label: 'Create with agent',
405
+ help: 'An interview about the game: genre, fantasy, references, loop, scope, what it is not',
406
+ skill: 'gcf-vision',
407
+ say: 'Start the game design with me: the vision interview.',
408
+ edits: DESIGN_EDITS,
409
+ },
410
+ ingest: {
411
+ label: 'Import GDD',
412
+ help: 'A GDD (.md) becomes design units, questions, and drafts of the vision and glossary',
413
+ skill: 'gcf-ingest',
414
+ takes: 'file',
415
+ say: 'Import the GDD {file}.',
416
+ edits: DESIGN_EDITS,
417
+ },
418
+ 'review-gdd': {
419
+ label: 'Review GDD first',
420
+ help: 'Expert lenses read the GDD before its import; their findings become questions',
421
+ skill: 'gcf-debate',
422
+ takes: 'file',
423
+ say: 'Review the GDD {file}; it is not imported yet.',
424
+ edits: ['gcf/open-questions.md', 'gcf/INDEX.md'],
425
+ },
426
+ pillars: {
427
+ label: 'Pillars interview',
428
+ help: "The game's 2..7 pillars, each with what it forbids and its review question",
429
+ skill: 'gcf-init',
430
+ say:
431
+ 'gcf/ exists: run the pillars interview with me; with gcf/PILLARS.md empty, start from ' +
432
+ 'candidates you draw from the vision and the design units.',
433
+ edits: ['gcf/PILLARS.md', 'gcf/INDEX.md'],
434
+ },
435
+ 'revise-pillars': {
436
+ label: 'Revise with agent',
437
+ help: 'Talk a change of the pillars through: the agent proposes, you confirm',
438
+ skill: 'gcf-init',
439
+ takes: 'text',
440
+ say: 'Revise the pillars with me: {text}',
441
+ edits: ['gcf/PILLARS.md', 'gcf/INDEX.md'],
442
+ },
443
+ 'revise-vision': {
444
+ label: 'Change with agent',
445
+ help: 'Talk a change of the vision, scope or milestones through',
446
+ skill: 'gcf-vision',
447
+ takes: 'text',
448
+ say: 'Change the vision with me: {text}',
449
+ edits: DESIGN_EDITS,
450
+ },
451
+ debate: {
452
+ label: 'Review with agent',
453
+ help: 'Expert lenses read the whole design: holes and contradictions become questions',
454
+ skill: 'gcf-debate',
455
+ say: 'Review the design.',
456
+ edits: DESIGN_EDITS,
457
+ },
458
+ 'debate-unit': {
459
+ label: 'Review with agent',
460
+ help: 'Expert lenses read this unit',
461
+ skill: 'gcf-debate',
462
+ takes: 'unit',
463
+ say: 'Review unit {unit}.',
464
+ edits: DESIGN_EDITS,
465
+ },
466
+ // A draft beside an empty or TBD part (decision 35): the agent writes it, records nothing; the
467
+ // operator records it, edits it in the form, or discards it.
468
+ 'draft-glossary': {
469
+ label: 'Draft with agent',
470
+ help: 'A draft of the glossary from the vision and the units: you record it, edit or discard it',
471
+ skill: 'gcf-vision',
472
+ say: 'Draft gcf/glossary.md from the vision and the design units. Write it, do not record it.',
473
+ edits: DESIGN_EDITS,
474
+ },
475
+ 'draft-system': {
476
+ label: 'Draft with agent',
477
+ help: "A draft of the subsystem's purpose from its units and the vision",
478
+ skill: 'gcf-vision',
479
+ takes: 'system',
480
+ say:
481
+ 'Draft the purpose of subsystem {system} from its units and the vision. Write it, do not ' +
482
+ 'record it.',
483
+ edits: DESIGN_EDITS,
484
+ },
485
+ 'name-pillars': {
486
+ label: 'Name with agent',
487
+ help: 'A short name for each pillar without one, from its statement',
488
+ skill: 'gcf-init',
489
+ say:
490
+ 'Give each pillar of gcf/PILLARS.md without a name a short name of 2 to 4 words from its ' +
491
+ 'statement. Change nothing else, do not record it.',
492
+ edits: ['gcf/PILLARS.md', 'gcf/INDEX.md'],
493
+ },
494
+ card: {
495
+ label: 'Fill TBDs with agent',
496
+ help: "Go through the unit's TBDs together; it goes into work only when you say so",
497
+ skill: 'gcf-card',
498
+ takes: 'unit',
499
+ say: 'Go through the TBDs of unit {unit} with me; take it into work only when I say so.',
500
+ edits: DESIGN_EDITS,
501
+ },
502
+ };
503
+
504
+ // The way from an empty project to its first work, in order: the board shows each step done or
505
+ // not (the board read's `design.steps`) with the starts that do it.
506
+ const DESIGN_STEPS = [
507
+ {
508
+ id: 'design',
509
+ label: 'The game design',
510
+ help: 'Import a GDD, or create the design with an agent: design units, the vision, the scope',
511
+ starts: ['ingest', 'review-gdd', 'vision', 'draft-glossary'],
512
+ },
513
+ {
514
+ id: 'pillars',
515
+ label: 'Pillars',
516
+ help: 'What the game always holds: every unit and every review answers to them',
517
+ starts: ['pillars', 'name-pillars'],
518
+ },
519
+ {
520
+ id: 'questions',
521
+ label: 'Open questions',
522
+ help: 'What the design leaves open: a unit a question holds cannot go into work',
523
+ },
524
+ {
525
+ id: 'work',
526
+ label: 'First work',
527
+ help: 'A unit with no TBD and no question goes into work: it becomes a card on the board',
528
+ starts: ['card'],
529
+ },
530
+ ];
531
+
532
+ // The game's own inbox categories (Board-PRD §2.6), merged over the framework's base.
533
+ const GAME_CATEGORIES = [
534
+ {
535
+ id: 'playtest',
536
+ label: 'Play note',
537
+ help: 'What you saw while playing',
538
+ rank: 5,
539
+ group: 'to-sort',
540
+ // An agent records one only in a playtest session, on the operator's words.
541
+ set_by: ['you', 'agent'],
542
+ details: null,
543
+ later: true,
544
+ },
545
+ {
546
+ id: 'tune',
547
+ label: 'Tune note',
548
+ help: 'A note on the feel or a number of an item that waits for its verdict',
549
+ rank: 10,
550
+ group: 'ideas',
551
+ set_by: ['you'],
552
+ details: null,
553
+ later: true,
554
+ },
555
+ ];
556
+
557
+ /** The inbox's vocabulary of a GCF project: the base and the game's layer (decision 32). */
558
+ export const inboxVocabulary = () => mergeVocabulary(BASE_CATEGORIES, GAME_CATEGORIES);
559
+
560
+ // An entry's category: one an entry can be filed in or moved into; the core checks who may.
561
+ const CATEGORY = (dflt) => ({
562
+ key: 'category',
563
+ label: 'Category',
564
+ kind: 'choice',
565
+ required: true,
566
+ ...(dflt && { default: dflt }),
567
+ options: inboxVocabulary()
568
+ .categories.filter((c) => !questionOnly(c) && c.set_by.length)
569
+ .map((c) => ({ value: c.id, label: c.label, help: c.help })),
570
+ });
571
+ const DETAIL = {
572
+ key: 'detail',
573
+ label: 'Detail',
574
+ kind: 'text',
575
+ max: 30,
576
+ help: 'One lowercase word after the category: asset, static-analysis, framework',
577
+ };
578
+
290
579
  // The moves of the domain's blocks: the phase, the inbox, the questions, the run order.
291
580
  const BLOCK_SPECS = {
292
581
  'item-new': NEW_ITEM,
@@ -306,18 +595,12 @@ const BLOCK_SPECS = {
306
595
  },
307
596
  'inbox-add': {
308
597
  label: 'add',
309
- help: 'A raw note for triage (an idea, a playtest note, a CI finding); line 1 is its title',
598
+ help: 'A raw note for triage (an idea, a playtest note, a bug); line 1 is its title',
310
599
  args: ['gcf', 'inbox', 'add', '--commit'],
311
600
  fields: [
312
601
  { key: 'text', label: 'Text', kind: 'longtext', required: true },
313
- {
314
- key: 'source',
315
- label: 'Source',
316
- kind: 'choice',
317
- default: 'operator',
318
- options: SOURCES.map((s) => ({ value: s, label: s })),
319
- },
320
- { key: 'tags', label: 'Tags', kind: 'tags' },
602
+ CATEGORY('note'),
603
+ DETAIL,
321
604
  ],
322
605
  propose: true,
323
606
  },
@@ -329,16 +612,27 @@ const BLOCK_SPECS = {
329
612
  danger: true,
330
613
  propose: true,
331
614
  },
332
- 'inbox-tag': {
333
- label: 'tag',
334
- help: 'Sort the entry: tags added and removed',
335
- args: ['gcf', 'inbox', 'tag', '{id}', '--commit'],
336
- fields: [
337
- { key: 'add', label: 'Add tags', kind: 'tags' },
338
- { key: 'remove', label: 'Remove tags', kind: 'tags' },
339
- ],
615
+ 'inbox-category': {
616
+ label: 'sort',
617
+ help: 'Give the entry another category or detail; where it came from stays',
618
+ args: ['gcf', 'inbox', 'category', '{id}', '--commit'],
619
+ // An emptied detail goes as `--detail=`: it clears the one there.
620
+ fields: [CATEGORY(), { ...DETAIL, clear: true }],
340
621
  propose: true,
341
622
  },
623
+ 'inbox-later': {
624
+ label: 'later',
625
+ help: 'Put the entry away to Later: nothing there asks for you now',
626
+ args: ['gcf', 'inbox', 'later', '{id}', '--commit'],
627
+ fields: [],
628
+ propose: true,
629
+ },
630
+ 'inbox-back': {
631
+ label: 'back',
632
+ help: 'Take the entry back from Later to its group',
633
+ args: ['gcf', 'inbox', 'later', '{id}', '--off', '--commit'],
634
+ fields: [],
635
+ },
342
636
  'question-answer': {
343
637
  label: 'answer',
344
638
  help: 'The answer goes into the record; the next agent on its units puts it in place',
@@ -351,6 +645,7 @@ const BLOCK_SPECS = {
351
645
  args: ['gcf', 'prioritize', '{ids}'],
352
646
  fields: [],
353
647
  },
648
+ ...DESIGN_SPECS,
354
649
  };
355
650
 
356
651
  // The item fields a board shows: on the card (`card`), in the drawer (all that have a value).
@@ -415,11 +710,23 @@ const TERMS = [
415
710
  'A parent item: when its children are done, the operator decides: close, continue or kill',
416
711
  ],
417
712
  ['design unit', 'A mechanic, resource, rule, constraint or entity of gcf/design/'],
713
+ [
714
+ 'GDD import',
715
+ 'A GDD becomes design units (each slot a GDD quote or TBD), questions, drafts of the vision ' +
716
+ 'and the glossary, and pillar candidates: no item until a unit goes into work',
717
+ ],
718
+ ['pillar', 'What the game always holds: units cite it, a review asks its question'],
719
+ [
720
+ 'record design',
721
+ 'One commit of what a design session wrote: pillars, vision, glossary, units, questions',
722
+ ],
418
723
  ['phase', 'The stage of the project (prototype, vertical slice…): the types it takes'],
419
724
  ['WIP', 'Items built and waiting for a verdict; at the limit new verdict work stops'],
420
725
  ['verify', 'The DoD: the project test and build commands, green on the code as it is'],
421
726
  ['inbox', 'Raw input waiting for triage: it becomes an item or is erased'],
422
727
  ['lesson', 'An inbox entry an agent session left: what got in its way'],
728
+ ['category', 'What an inbox entry or a question asks of you: it sets its group and rank'],
729
+ ['Later', 'Inbox entries put away: nothing there asks for you now'],
423
730
  ['D1', 'A question only the operator answers; it blocks the units it names'],
424
731
  ['D2', 'An assumption the agent made and works with; it comes back when its trigger fires'],
425
732
  ['unplayed', 'Closed by its checks without a playtest; it waits for one'],
@@ -431,12 +738,20 @@ const SECTIONS = {
431
738
  phase: { next: 'phase-next' },
432
739
  release: {},
433
740
  wip: { help: 'Items awaiting a verdict / wip_built_limit' },
434
- inbox: { add: 'inbox-add', drop: 'inbox-drop', tag: 'inbox-tag' },
741
+ inbox: {
742
+ add: 'inbox-add',
743
+ drop: 'inbox-drop',
744
+ category: 'inbox-category',
745
+ later: 'inbox-later',
746
+ back: 'inbox-back',
747
+ // The vocabulary as data: the board draws its groups and choices from it, knows none.
748
+ ...inboxVocabulary(),
749
+ },
435
750
  questions: { answer: 'question-answer' },
436
751
  lessons: {},
437
752
  playtest: {
438
- // The inbox source a note from the playtest screen goes with.
439
- source: 'playtest',
753
+ // The inbox category a note from the playtest screen goes with.
754
+ category: 'playtest',
440
755
  waits: ['awaiting-verdict', 'unplayed'],
441
756
  verdicts: ['verdict:keep', 'verdict:tune', 'verdict:kill'],
442
757
  },
@@ -444,6 +759,20 @@ const SECTIONS = {
444
759
  // `match`: the item's field Related holds against the graveyard's tags.
445
760
  graveyard: { label: 'Graveyard', match: 'system' },
446
761
  units: { label: 'Design units' },
762
+ // The game design screen (Board-PRD §5.24): the read's `design` block, its moves and starts.
763
+ design: {
764
+ label: 'Design',
765
+ steps: DESIGN_STEPS,
766
+ save: 'design-save',
767
+ save_text: 'design-save-text',
768
+ commit: 'design-commit',
769
+ import: 'design-import',
770
+ new_unit: 'design-new-unit',
771
+ discard: 'design-discard',
772
+ retire: 'pillar-retire',
773
+ drop: 'unit-drop',
774
+ answer: 'question-answer',
775
+ },
447
776
  };
448
777
 
449
778
  // The gcf commands that change the project: a project chat asks the operator before each one
@@ -459,6 +788,9 @@ const CHANGES = [
459
788
  'design export',
460
789
  'design import',
461
790
  'design migrate',
791
+ 'design save',
792
+ 'design commit',
793
+ 'design discard',
462
794
  'take',
463
795
  'done',
464
796
  'drop',
@@ -473,7 +805,9 @@ const CHANGES = [
473
805
  'block',
474
806
  'unblock',
475
807
  'inbox add',
476
- 'inbox tag',
808
+ 'inbox category',
809
+ 'inbox later',
810
+ 'inbox migrate',
477
811
  'inbox drop',
478
812
  'lessons add',
479
813
  'config set',
@@ -531,6 +865,7 @@ export function domainOf(extensions = {}) {
531
865
  new_item: 'item-new',
532
866
  rank: 'prioritize',
533
867
  chat: CHAT,
868
+ starts: STARTS,
534
869
  // A session's mark nobody refreshed for this long stops making its item `running`.
535
870
  session_ttl_min: SESSION_TTL_MS / 60_000,
536
871
  };
package/lib/git.js CHANGED
@@ -55,10 +55,15 @@ const BY = ['run', 'session', 'operator'];
55
55
 
56
56
  /**
57
57
  * Who makes a move: `GCF_MOVE_BY` when it names one (the harness sets `run` for both run modes),
58
- * else a harness run's owner, else a Claude Code session, else the operator.
58
+ * else a harness run's owner, else a Claude Code session, else the operator. Inside a run or a
59
+ * session `GCF_MOVE_BY` cannot name the operator: an agent would claim the operator's moves.
60
+ * shortcut: an agent that unsets its own markers still passes for the operator; a trusted channel
61
+ * of who runs a command would close it.
59
62
  */
60
63
  export function moveBy(env = process.env) {
61
- if (BY.includes(env.GCF_MOVE_BY ?? '')) return /** @type {string} */ (env.GCF_MOVE_BY);
64
+ const agent = Boolean(env.GCF_RUN_OWNER || env.CLAUDE_CODE_SESSION_ID);
65
+ const named = env.GCF_MOVE_BY ?? '';
66
+ if (BY.includes(named) && !(agent && named === 'operator')) return named;
62
67
  if (env.GCF_RUN_OWNER) return 'run';
63
68
 
64
69
  return env.CLAUDE_CODE_SESSION_ID ? 'session' : 'operator';
@@ -66,17 +71,19 @@ export function moveBy(env = process.env) {
66
71
 
67
72
  /**
68
73
  * The trailer paragraph of a move's commit as `git commit`/`git merge` arguments (`gcf item
69
- * history` reads it): the items and units it touched, the domain's move key, who made it. A
70
- * separate `-m`, not `--trailer`: any git version takes it. None without a move key.
71
- * @param {{key?: string, items?: string[]}} [move]
74
+ * history` reads it): the items and units it touched, the domain's move key, who made it, and
75
+ * the board's proposal it carries out (its recovery finds the move by it). A separate `-m`, not
76
+ * `--trailer`: any git version takes it. None without a move key.
77
+ * @param {{key?: string, items?: string[], proposal?: string}} [move]
72
78
  */
73
- export function moveTrailers({ key, items = [] } = {}) {
79
+ export function moveTrailers({ key, items = [], proposal } = {}) {
74
80
  if (!key) return [];
75
81
  const ids = [...new Set(items)];
76
82
  const lines = [
77
83
  ...(ids.length ? [`GCF-Items: ${ids.join(', ')}`] : []),
78
84
  `GCF-Move: ${key}`,
79
85
  `GCF-By: ${moveBy()}`,
86
+ ...(proposal ? [`GCF-Proposal: ${proposal}`] : []),
80
87
  ];
81
88
 
82
89
  return ['-m', lines.join('\n')];
package/lib/id.js CHANGED
@@ -15,6 +15,53 @@ export function slugify(name) {
15
15
  return slug;
16
16
  }
17
17
 
18
+ // Cyrillic to Latin, one way for good: an id is frozen once made, and a test holds this table
19
+ // (Board-PRD decision 34). Ukrainian and Belarusian letters too.
20
+ // prettier-ignore
21
+ const CYRILLIC = {
22
+ а: 'a', б: 'b', в: 'v', г: 'g', ґ: 'g', д: 'd', е: 'e', ё: 'e', є: 'ie', ж: 'zh', з: 'z',
23
+ и: 'i', і: 'i', ї: 'i', й: 'i', к: 'k', л: 'l', м: 'm', н: 'n', о: 'o', п: 'p', р: 'r',
24
+ с: 's', т: 't', у: 'u', ў: 'u', ф: 'f', х: 'kh', ц: 'ts', ч: 'ch', ш: 'sh', щ: 'shch',
25
+ ъ: '', ы: 'y', ь: '', э: 'e', ю: 'iu', я: 'ia',
26
+ };
27
+
28
+ /** `s` in Latin letters: Cyrillic by the table, accents dropped (`é` → `e`). */
29
+ export const transliterate = (s) =>
30
+ [...String(s).toLowerCase().normalize('NFD').replace(/\p{M}/gu, '').normalize('NFC')]
31
+ .map((ch) => CYRILLIC[ch] ?? ch)
32
+ .join('');
33
+
34
+ // About four words: an id names, a title describes.
35
+ const ID_WORDS = 4;
36
+ const ID_CHARS = 32;
37
+
38
+ /**
39
+ * The id the system makes from a title (Board-PRD decision 34): transliterated, slugged, cut at
40
+ * a word to 4 words and 32 characters, `-2`, `-3`… while `known(id)` (an id is never reused).
41
+ * A title with nothing to slug gets `<type>-<n>`, the lowest n free.
42
+ * @param {string} title
43
+ * @param {(id: string) => boolean} known
44
+ * @param {string} type
45
+ */
46
+ export function deriveId(title, known, type) {
47
+ const words = transliterate(title)
48
+ .split(/[^a-z0-9]+/)
49
+ .filter(Boolean)
50
+ .slice(0, ID_WORDS);
51
+ while (words.length > 1 && words.join('-').length > ID_CHARS) words.pop();
52
+ const base = words.join('-').slice(0, ID_CHARS).replace(/-+$/, '');
53
+ if (!base) {
54
+ let n = 1;
55
+ while (known(`${type}-${n}`)) n++;
56
+
57
+ return `${type}-${n}`;
58
+ }
59
+ let id = base;
60
+ for (let n = 2; known(id); n++) id = `${base}-${n}`;
61
+
62
+ return id;
63
+ }
64
+
18
65
  export function isValidId(id) {
19
66
  return ID_RE.test(String(id ?? ''));
20
67
  }