@runeditrun/rer 0.2.85 → 0.2.87

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 (162) hide show
  1. package/README.md +138 -29
  2. package/cli/README.md +61 -1
  3. package/cli/agent-bindings.mjs +25 -0
  4. package/cli/agent-door.mjs +145 -0
  5. package/cli/agent-fixtures.mjs +16 -0
  6. package/cli/agent-journey-fixtures.mjs +17 -0
  7. package/cli/agent-mail.mjs +54 -0
  8. package/cli/agent-network.mjs +64 -0
  9. package/cli/agent-reviewers.mjs +110 -0
  10. package/cli/agent-rpc.mjs +23 -0
  11. package/cli/agent-secrets.mjs +23 -0
  12. package/cli/agent-sponsors.mjs +43 -0
  13. package/cli/agent-surface.mjs +34 -0
  14. package/cli/agent-verifier.mjs +31 -0
  15. package/cli/agent-webhooks.mjs +19 -0
  16. package/cli/authoring.mjs +2 -1
  17. package/cli/business/archive-task.mjs +32 -0
  18. package/cli/business/carry.mjs +3 -1
  19. package/cli/business/catchup-task.mjs +42 -0
  20. package/cli/business/choices.mjs +97 -0
  21. package/cli/business/command.mjs +23 -5
  22. package/cli/business/connect.mjs +19 -7
  23. package/cli/business/detector.mjs +4 -1
  24. package/cli/business/device.mjs +13 -0
  25. package/cli/business/export-inputs.mjs +69 -0
  26. package/cli/business/export-task.mjs +17 -0
  27. package/cli/business/invocation.mjs +8 -1
  28. package/cli/business/keychain.mjs +8 -1
  29. package/cli/business/lease.mjs +11 -1
  30. package/cli/business/local-commands.mjs +79 -31
  31. package/cli/business/outbound.mjs +9 -4
  32. package/cli/business/parsers-config.mjs +8 -7
  33. package/cli/business/parsers-syntax.mjs +7 -3
  34. package/cli/business/permissions.mjs +2 -0
  35. package/cli/business/questions.mjs +89 -9
  36. package/cli/business/setup-command.mjs +49 -0
  37. package/cli/business/setup-company.json +15 -0
  38. package/cli/business/setup-demo.mjs +95 -0
  39. package/cli/business/state.mjs +44 -10
  40. package/cli/business/supervisor.mjs +94 -35
  41. package/cli/business/vendor-door.mjs +230 -0
  42. package/cli/business/vendors/README.md +29 -3
  43. package/cli/business/vendors/common.mjs +8 -6
  44. package/cli/business/vendors/index.mjs +22 -11
  45. package/cli/business/vendors/sorry.mjs +106 -0
  46. package/cli/contract.mjs +2 -2
  47. package/cli/demo-deploy-error.mjs +14 -0
  48. package/cli/demo-native.mjs +4 -1
  49. package/cli/deploy-config.mjs +1 -1
  50. package/cli/deploy-owner-input.mjs +3 -1
  51. package/cli/deploy-variables.mjs +89 -0
  52. package/cli/door-clauses.mjs +157 -0
  53. package/cli/export.mjs +17 -4
  54. package/cli/hosted-output.mjs +31 -8
  55. package/cli/inspect.mjs +4 -0
  56. package/cli/jsonc.mjs +8 -4
  57. package/cli/lifecycle.mjs +3 -1
  58. package/cli/main.mjs +1 -0
  59. package/cli/managed-data-schema.mjs +14 -1
  60. package/cli/managed-data.mjs +8 -4
  61. package/cli/portability-empty.mjs +6 -0
  62. package/cli/portability-migrations.mjs +26 -4
  63. package/cli/portability-worker.mjs +2 -1
  64. package/cli/portability.mjs +1 -0
  65. package/cli/production-auth.mjs +2 -2
  66. package/cli/production-mail.mjs +19 -3
  67. package/cli/server-registry.mjs +2 -0
  68. package/edition-authoring/archive-source.mjs +65 -0
  69. package/edition-authoring/base-copies.mjs +108 -21
  70. package/edition-authoring/cli.mjs +1 -1
  71. package/edition-authoring/copy-namespaces.mjs +28 -0
  72. package/edition-authoring/edition-migrations.mjs +7 -3
  73. package/edition-authoring/files.mjs +2 -1
  74. package/edition-authoring/module-closure.mjs +58 -27
  75. package/edition-authoring/module-edges.mjs +13 -2
  76. package/edition-authoring/workflow-copies.mjs +1 -1
  77. package/edition-authoring/workflow-scripts.mjs +12 -3
  78. package/foundation/runtime/contract-docs.mjs +220 -32
  79. package/foundation/runtime/contract-prose-patterns.mjs +14 -0
  80. package/foundation/runtime/contract-prose.mjs +88 -0
  81. package/global/CHANGELOG.md +151 -0
  82. package/global/README.md +138 -29
  83. package/global/door/command.mjs +3 -1
  84. package/global/main.mjs +1 -1
  85. package/modules/agent-door/CLAUSES.md +215 -0
  86. package/modules/agent-door/conformance/audit-pages.mjs +11 -0
  87. package/modules/agent-door/conformance/audit-rows.mjs +20 -0
  88. package/modules/agent-door/conformance/audit.mjs +63 -0
  89. package/modules/agent-door/conformance/authority.d.mts +2 -0
  90. package/modules/agent-door/conformance/authority.mjs +17 -0
  91. package/modules/agent-door/conformance/crypto.mjs +36 -0
  92. package/modules/agent-door/conformance/discovery.mjs +61 -0
  93. package/modules/agent-door/conformance/fixtures.mjs +41 -0
  94. package/modules/agent-door/conformance/index.mjs +41 -0
  95. package/modules/agent-door/conformance/injection.mjs +24 -0
  96. package/modules/agent-door/conformance/invocation.mjs +33 -0
  97. package/modules/agent-door/conformance/journey.mjs +117 -0
  98. package/modules/agent-door/conformance/narrowing.d.mts +2 -0
  99. package/modules/agent-door/conformance/narrowing.mjs +29 -0
  100. package/modules/agent-door/conformance/negative.mjs +48 -0
  101. package/modules/agent-door/conformance/network-modules.mjs +86 -0
  102. package/modules/agent-door/conformance/network-runtime.mjs +46 -0
  103. package/modules/agent-door/conformance/policy-phases.mjs +83 -0
  104. package/modules/agent-door/conformance/protocol.mjs +153 -0
  105. package/modules/agent-door/conformance/replay.mjs +39 -0
  106. package/modules/agent-door/conformance/schema.mjs +71 -0
  107. package/modules/agent-door/conformance/security.mjs +34 -0
  108. package/modules/agent-door/conformance/sponsors.mjs +68 -0
  109. package/modules/agent-door/conformance/step-hooks.mjs +4 -0
  110. package/modules/agent-door/conformance/surface.mjs +92 -0
  111. package/modules/agent-door/conformance/target.mjs +19 -0
  112. package/modules/agent-door/conformance/tool-name.d.mts +1 -0
  113. package/modules/agent-door/conformance/tool-name.mjs +7 -0
  114. package/modules/agent-door/conformance/webhooks.mjs +31 -0
  115. package/modules/container/image-variables.mjs +8 -2
  116. package/modules/delivery-producer/mail.mjs +20 -0
  117. package/modules/demo-host/README.md +6 -0
  118. package/modules/demo-host/ownership.mjs +39 -0
  119. package/modules/demo-host/plan.mjs +2 -1
  120. package/modules/demo-host/remove.mjs +6 -1
  121. package/modules/import-kit/schema/importer-verification-receipt.schema.json +171 -0
  122. package/modules/import-kit/schema/importers.schema.json +107 -0
  123. package/modules/import-kit/src/door/ADOPTING.md +20 -0
  124. package/modules/import-kit/src/door/README.md +2 -1
  125. package/modules/import-kit/src/door/admission.ts +5 -3
  126. package/modules/import-kit/src/door/archive.ts +5 -2
  127. package/modules/import-kit/src/door/authority.ts +1 -0
  128. package/modules/import-kit/src/door/grants.ts +1 -1
  129. package/modules/import-kit/src/door/handler.ts +14 -8
  130. package/modules/import-kit/src/door/index.ts +1 -1
  131. package/modules/import-kit/src/door/jobs.ts +40 -0
  132. package/modules/import-kit/src/door/operator.ts +3 -3
  133. package/modules/import-kit/src/door/planning.ts +10 -6
  134. package/modules/import-kit/src/door/protocol.ts +2 -2
  135. package/modules/import-kit/src/door/raw.ts +25 -0
  136. package/modules/import-kit/src/door/refusals.ts +1 -0
  137. package/modules/import-kit/src/door/types.ts +26 -6
  138. package/modules/import-kit/src/receipt/encoding.ts +37 -0
  139. package/modules/import-kit/src/receipt/index.ts +69 -0
  140. package/modules/import-kit/src/receipt/policy.ts +24 -0
  141. package/modules/import-kit/src/receipt/types.ts +64 -0
  142. package/modules/import-kit/src/receipt/uri.ts +45 -0
  143. package/modules/import-kit/src/receipt/validation.ts +87 -0
  144. package/modules/import-kit/src/status/encoding.ts +13 -0
  145. package/modules/import-kit/src/status/evidence.ts +218 -0
  146. package/modules/import-kit/src/status/index.ts +56 -0
  147. package/modules/import-kit/src/status/schema.ts +208 -0
  148. package/modules/import-kit/src/status/types.ts +86 -0
  149. package/modules/operator-auth/accounts/delegated.mjs +48 -0
  150. package/modules/operator-auth/index.d.mts +7 -0
  151. package/modules/operator-auth/service.mjs +2 -0
  152. package/modules/portability/README.md +37 -13
  153. package/modules/portability/bridge.mjs +22 -2
  154. package/modules/portability/catalogue.mjs +12 -2
  155. package/modules/portability/copies.mjs +8 -1
  156. package/modules/portability/derived.mjs +33 -0
  157. package/modules/portability/http-errors.mjs +1 -1
  158. package/modules/portability/import.mjs +14 -7
  159. package/package.json +4 -2
  160. package/scripts/publish-check/copy_identities.py +3 -1
  161. package/scripts/publish-check/github_refs.py +32 -13
  162. package/cli/business/opt-ins.mjs +0 -37
@@ -0,0 +1,33 @@
1
+ import { all, quote } from './storage.mjs';
2
+ import { sqliteTokens, asciiFold } from './sqlite-tokens.mjs';
3
+
4
+ const value = token => {
5
+ const text = token?.text ?? '', delimiter = text[0];
6
+ return ['"', "'", '`', '['].includes(delimiter)
7
+ ? text.slice(1, -1).replaceAll(delimiter + delimiter, delimiter) : text;
8
+ };
9
+
10
+ // Only external-content FTS5 has SQLite's native rebuild contract: its rows
11
+ // come from the migrated content table. Other derived data remains seed-owned.
12
+ function externalFts5(sql) {
13
+ const tokens = sqliteTokens(sql), words = tokens.map(token => asciiFold(token.text));
14
+ if (words.slice(0, 3).join(' ') !== 'create virtual table') return false;
15
+ const using = words.indexOf('using');
16
+ if (using < 0 || asciiFold(value(tokens[using + 1])) !== 'fts5') return false;
17
+ let depth = 0;
18
+ for (let i = using + 2; i < tokens.length; i++) {
19
+ if (tokens[i].text === '(') depth++;
20
+ else if (tokens[i].text === ')') depth--;
21
+ else if (depth === 1 && ['(', ','].includes(tokens[i - 1]?.text)
22
+ && asciiFold(value(tokens[i])) === 'content' && tokens[i + 1]?.text === '=')
23
+ return value(tokens[i + 2]).length > 0;
24
+ }
25
+ return false;
26
+ }
27
+
28
+ export async function rebuildDerivedStatements(db, config) {
29
+ if (!config.derivedTables.length) return [];
30
+ const objects = await all(db, "SELECT name,sql FROM sqlite_master WHERE type='table' AND sql IS NOT NULL ORDER BY name");
31
+ return objects.filter(object => config.derivedTables.includes(object.name) && !config.includeTables.includes(object.name) && externalFts5(object.sql))
32
+ .map(object => db.prepare(`INSERT INTO ${quote(object.name)}(${quote(object.name)}) VALUES('rebuild')`));
33
+ }
@@ -5,7 +5,7 @@ import { importRunningMetadata } from './import-lease.mjs';
5
5
  const publicCodes = new Set(`
6
6
  D1_RPC_TRANSPORT_LIMIT advance_limit archive_checksum archive_format archive_incomplete archive_json
7
7
  binary_checksum binary_inventory binary_order binary_size body_too_large bucket_inventory bucket_not_empty
8
- closing_missing column_inventory configuration_inventory confirmation_required content_checksum copy_inventory copy_rowid
8
+ closing_missing column_inventory configuration_inventory confirmation_required content_checksum copy_inventory copy_normalization_failed copy_rowid
9
9
  data_after_closing dev_data erased_row erasure_epoch excluded_destination_dependents excluded_foreign_key
10
10
  export_incomplete export_phase export_row_must_be_pure export_row_not_idempotent extra_part generated_sql
11
11
  import_applying import_complete import_lease_expired import_phase import_row_columns import_row_key import_row_must_be_pure
@@ -13,11 +13,12 @@ import { fence, mergeJournal, tombstone } from './journal.mjs';
13
13
  import { writeObject } from './payloads.mjs';
14
14
  import { createCopy,sidecar,readCopy,restoreCopy } from './copies.mjs';
15
15
  import { excludedDependentGuards, migrationSeeded, seededCondition } from './restore-safety.mjs';
16
- import { additiveBridge, sameSchemaMigrations, appliedMigrations } from './bridge.mjs';
16
+ import { additiveBridge, sameSchemaMigrations, appliedMigrations, verifiedLegacySchema } from './bridge.mjs';
17
17
  import { replayStatements } from './backfills.mjs';
18
18
  import { checkArchivedLedgers, archivedHistory } from './ledgers.mjs';
19
19
  import { legacyEmptyGuards, legacyAuditStatements, requireLegacyEmpty } from './legacy-safety.mjs';
20
20
  import { checkReferences } from './references.mjs';
21
+ import { rebuildDerivedStatements } from './derived.mjs';
21
22
  // ledgers: the rows of each migration ledger table the archive carries, as the
22
23
  // caller read them from it ({table:rows}); uploadPart binds them to its parts.
23
24
  export async function createImport(context,manifest,actor='direct',legacyRecovery,ledgers,acknowledgeUnverifiedSchemaObjects=false) {
@@ -28,17 +29,22 @@ export async function createImport(context,manifest,actor='direct',legacyRecover
28
29
  const original=manifest;manifest=await restorableManifest(original);
29
30
  const skippedTables=original.tables.filter(table=>platformTable(table.name)).map(table=>table.name);
30
31
  const cat=await catalogue(db,config),upgrade=config.acceptedSchemas[original.schema];
31
- // Table SQL and migration names cannot establish missing trigger/view/index
32
- // definitions. Never infer that an old archive's absent inventory is empty.
33
- const unverified=original.version===2 && manifest.schemaObjects===undefined && acknowledgeUnverifiedSchemaObjects===true;
34
- insist(manifest.schemaObjects!==undefined || legacyRecovery || unverified,'schema_mismatch:legacy_schema',409);
32
+ const legacy=original.version===2 && manifest.schemaObjects===undefined;
33
+ // An explicit acknowledgment keeps its existing recovery semantics. Without
34
+ // it, legacy v2 needs positive replay evidence for the complete destination.
35
+ const unverified=legacy && acknowledgeUnverifiedSchemaObjects===true;
36
+ const verifyingLegacy=legacy && !unverified && !legacyRecovery;
37
+ const history=()=>archivedHistory(original,ledgers,{allowOlderShape:unverified || verifyingLegacy});
38
+ const verified=verifyingLegacy && await verifiedLegacySchema(db,manifest,cat,context.migrations,history);
39
+ insist(!legacy || legacyRecovery || unverified || verified,'schema_mismatch:legacy_schema',409);
40
+ if(verified)manifest={...manifest,schema:cat.identity,schemaObjects:cat.schemaObjects};
35
41
  if(unverified)for(const table of manifest.tables) {
36
42
  const target=cat.tables.find(t=>t.name===table.name);
37
43
  insist(target,'schema_mismatch:table:'+table.name,409);
38
44
  for(const column of table.columns)insist(target.columns.some(c=>canonicalJson(c)===canonicalJson(column)),'schema_mismatch:column:'+table.name+':'+column.name,409);
39
45
  insist(table.dependencies.every(d=>target.dependencies.includes(d)),'schema_mismatch:dependencies:'+table.name,409);
40
46
  }
41
- const same=manifest.schema===cat.identity,history=()=>archivedHistory(original,ledgers,{allowOlderShape:unverified});
47
+ const same=manifest.schema===cat.identity;
42
48
  const {replays,...bridge}=unverified?await additiveBridge(db,manifest,cat,context.migrations,history,legacyRecovery,true):upgrade?{}:same?(await sameSchemaMigrations(db,manifest,cat,context.migrations,history)??{}):await additiveBridge(db,manifest,cat,context.migrations,history,legacyRecovery);
43
49
  // Finalize checks object references on the staged rows; a later migration
44
50
  // replayed into a reference table would publish rows that check never saw.
@@ -216,6 +222,7 @@ async function finalizeLeasedImport(context,id,{contentHash,archiveHash,laterJou
216
222
  insist(hash.digest()===object.sha256,'object_write_checksum');
217
223
  }
218
224
  for(const payload of manifest.payloads)await config.extraPayloads[payload.name].consume(binaryStream(context,id,payload,binaryIndexes),payload);
225
+ const derived=await rebuildDerivedStatements(db,config);
219
226
  row.phase='complete';row.metadata.contentHash=digest;
220
227
  if(row.metadata.schemaUnverified)row.metadata.schemaUnverified.archiveHash=archiveHash;
221
228
  await db.batch([db.prepare('PRAGMA defer_foreign_keys=ON'),...emptyGuards(context,row,seeded),...seeded.map(t=>guard(db,...seededCondition(t))),...dependentGuards,...legacyEmptyGuards(db,row),
@@ -224,7 +231,7 @@ async function finalizeLeasedImport(context,id,{contentHash,archiveHash,laterJou
224
231
  ...row.metadata.triggers.map(t=>db.prepare(`DROP TRIGGER ${quote(t.name)}`)),
225
232
  ...replaced.map(t=>db.prepare(`DELETE FROM ${quote(t)}`)),
226
233
  ...row.metadata.targets.flatMap(t=>restoreCopy(db,t,row.metadata.copies[t.name])),save(db,row),...replayStatements(db,row),
227
- ...row.metadata.triggers.map(t=>db.prepare(t.sql)),...mergeJournal(db,manifest,checked),...legacyAuditStatements(db,row),
234
+ ...row.metadata.triggers.map(t=>db.prepare(t.sql)),...derived,...mergeJournal(db,manifest,checked),...legacyAuditStatements(db,row),
228
235
  // Publication and removal of this import's scratch commit together. A lost
229
236
  // acknowledgement still finds a complete job with no staging left behind.
230
237
  ...dropCopyStatements(db,row),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.85",
3
+ "version": "0.2.87",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -94,7 +94,9 @@
94
94
  "./modules/dependencies": "./modules/dependencies/index.mjs",
95
95
  "./internal/*": "./*",
96
96
  "./package.json": "./package.json",
97
- "./modules/import-kit/door": "./modules/import-kit/src/door/index.ts"
97
+ "./modules/import-kit/door": "./modules/import-kit/src/door/index.ts",
98
+ "./modules/import-kit/receipt": "./modules/import-kit/src/receipt/index.ts",
99
+ "./modules/import-kit/status": "./modules/import-kit/src/status/index.ts"
98
100
  },
99
101
  "engines": {
100
102
  "node": ">=22"
@@ -34,7 +34,9 @@ def copy_pointers(document, read_regular):
34
34
  value = read_regular(name)
35
35
  if (value is None or value[1] != modes[name]
36
36
  or hashlib.sha256(value[0]).hexdigest() != digest):
37
- break
37
+ # An adapted or mismatched file does not invalidate its siblings'
38
+ # proofs. Its own digest and content remain ordinary scan inputs.
39
+ continue
38
40
  pending.add(('copies', index, 'files', name))
39
41
  else:
40
42
  allowed.update(pending)
@@ -51,10 +51,35 @@ CONTEXT_URL = re.compile(r'(?i)(?<![A-Za-z])(?:' + REPOSITORY_CONTEXT + r')'
51
51
  + r'''[`*_~\[\]\s"']*(?:''' + URL.pattern.replace('(?i)', '') + ')')
52
52
  LINK_URL = re.compile(r'(?i)\[(?P<label>[^]\n]+)\]\(\s*(?P<url>' + URL.pattern.replace('(?i)', '') + ')')
53
53
  REPOSITORY_LABEL = re.compile(r'(?i)\b(?:' + REPOSITORY_CONTEXT + r')\b')
54
- # Words that make a nearby `owner/name` a repository rather than an identifier.
55
- # A bare "source" is not one: "source commit/tree" is ordinary prose.
56
- NEARBY_CONTEXT = re.compile(r'(?i)\b(?:github|repositor(?:y|ies)|repos?|forks?|forked|clones?|cloned|upstream|downstream|origin|submodules?)\b')
57
- CONTEXT_WINDOW = 60
54
+ CODE_PREFIX = re.compile(r'(?i)(?<![A-Za-z])(?:origin|submodules?|repositories|repos|forks|clones)' + MARKUP + r'[ \t]*(?:[:=][ \t]*)?$')
55
+ CODE_SUFFIX = re.compile(r'(?i)[ \t]+(?:repositor(?:y|ies)|repos?)\b')
56
+
57
+
58
+ def markdown_repository_context(match, text):
59
+ """A declaration or command must attach to the token, not nearby prose."""
60
+ if match['reference'] is None:
61
+ prefix = text[text.rfind('\n', 0, match.start()) + 1:match.start()]
62
+ return bool(CODE_PREFIX.search(prefix) or CODE_SUFFIX.match(text, match.end()))
63
+ separator = match['separator']
64
+ if '\n' in text[match.start():match.start('reference')] and not re.search(r'[:=]', separator):
65
+ return False
66
+ prefix = text[text.rfind('\n', 0, match.start()) + 1:match.start()]
67
+ if '|' in separator:
68
+ # A table label occupies a whole cell. The last word of an outcome
69
+ # such as "registered against a repository" cannot label the next cell.
70
+ return not prefix.rsplit('|', 1)[-1].strip(' \t`*_~[]')
71
+ if re.search(r'[:=]', separator):
72
+ return True
73
+ # A bare "source" is not a declaration: "source commit/tree" is prose.
74
+ if re.fullmatch(r'(?i)source', match['label']) and not re.search(
75
+ r'(?i)repository|repo', text[match.start():match.start('reference')]):
76
+ return False
77
+ command = re.match(r'(?i)github|gh\s|clone|fork', match['label'])
78
+ end = text.find('\n', match.end())
79
+ tail = text[match.end():end if end != -1 else len(text)]
80
+ declaration = (re.fullmatch(r'[ \t#>*_~`\[\]-]*(?:[0-9]+\.[ \t]+)?', prefix) and
81
+ re.fullmatch(r'[ \t\r`*_~\[\].,;:!)]*', tail))
82
+ return bool(match['markup'] or command or declaration)
58
83
 
59
84
 
60
85
  def explicit_references(text, path):
@@ -109,7 +134,7 @@ def reference_sets(text, path, local_paths=frozenset(), project_identity=None):
109
134
  markdown = URL.sub('', text)
110
135
  markdown = re.sub(r'\]\((?![A-Za-z][A-Za-z0-9+.-]*://)[^)]*\)', ']()', markdown)
111
136
  for match in MARKDOWN_REFERENCE.finditer(markdown):
112
- explicit = match['reference'] is not None
137
+ explicit = markdown_repository_context(match, markdown)
113
138
  value = re.split(r'[?#]', match['reference'] or match['code'], maxsplit=1)[0]
114
139
  # Underscores are also legal slug characters; remove a closing
115
140
  # emphasis marker only when the reference has its matching opener.
@@ -123,17 +148,11 @@ def reference_sets(text, path, local_paths=frozenset(), project_identity=None):
123
148
  continue
124
149
  # A plain multi-segment path is ambiguous; GitHub's repository
125
150
  # routes, a labeled field or a GitHub command disambiguate it.
126
- labeled = explicit and (re.search(r'[:=|]', match['separator']) or re.match(r'(?i)github|gh\s', match['label']))
151
+ labeled = explicit and match['reference'] is not None and (re.search(r'[:=|]', match['separator']) or re.match(r'(?i)github|gh\s', match['label']))
127
152
  if REPOSITORY_ROUTE.match(suffix) or labeled:
128
153
  found.add(normalize(repository))
129
154
  elif not suffix:
130
- if explicit:
131
- weak = re.fullmatch(r'(?i)source', match['label']) and not re.search(r'(?i)repository|repo', markdown[match.start():match.start('reference')])
132
- else:
133
- line_start = markdown.rfind('\n', 0, match.start()) + 1
134
- around = markdown[max(line_start, match.start() - CONTEXT_WINDOW):match.end() + CONTEXT_WINDOW].split('\n', 1)[0]
135
- weak = not NEARBY_CONTEXT.search(around)
136
- (ambiguous if weak else found).add(normalize(repository))
155
+ (found if explicit else ambiguous).add(normalize(repository))
137
156
  elif METADATA.search(path) or SOURCE.search(path):
138
157
  if path.lower().endswith('.json'):
139
158
  try:
@@ -1,37 +0,0 @@
1
- import { installService } from './service.mjs';
2
- import { installPermissions } from './permissions.mjs';
3
- import { saveState } from './state.mjs';
4
- import { carryLive } from './carry.mjs';
5
- import { rerCommand } from './invocation.mjs';
6
-
7
- // The server's field names stay internal; people see the browser's sentences.
8
- export const optIns = {
9
- installPermissions: 'Add rules so Claude Code never reads your secret files',
10
- awakeConsent: 'Keep this computer awake while it works',
11
- installService: 'Install the background service',
12
- };
13
- const optInNames = Object.keys(optIns);
14
-
15
- export async function applyOptIns(api, state, { report = true } = {}) {
16
- let self;
17
- // A server without this route answers a device credential with 403 (or 404):
18
- // nothing is decided yet. This first authenticated request activates the computer.
19
- try { self = await api.get('/api/business/executors/self'); }
20
- catch (error) { if (![403, 404].includes(error.status)) throw error; }
21
- await carryLive(state, self);
22
- const decisions = Object.fromEntries(optInNames.map(name => [name, self?.optIns?.[name] === true ? true : self?.optIns?.[name] === false ? false : null]));
23
- if (decisions.installPermissions === true) await installPermissions({ consent: true });
24
- state.awakeConsent = decisions.awakeConsent === true;
25
- await saveState(state);
26
- if (decisions.installService === true) await installService({ consent: true });
27
- if (!report) return;
28
- process.stdout.write(`This computer is connected to Business at ${state.origin}.\n`);
29
- if (decisions.installService === true) {
30
- process.stdout.write('The background service is installed and works tasks after this chat ends.\n');
31
- }
32
- const undecided = optInNames.filter(name => decisions[name] === null);
33
- if (undecided.length) {
34
- process.stdout.write(`The owner has not chosen yet:\n${undecided.map(name => ` - ${optIns[name]}\n`).join('')}Ask them to choose on this computer's row in ${state.origin}/business/${encodeURIComponent(state.businessId)}/settings.\n`);
35
- }
36
- process.stdout.write(`Run ${rerCommand()} business next to apply the owner's latest choices and see the next task.\n`);
37
- }