@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.
- package/README.md +138 -29
- package/cli/README.md +61 -1
- package/cli/agent-bindings.mjs +25 -0
- package/cli/agent-door.mjs +145 -0
- package/cli/agent-fixtures.mjs +16 -0
- package/cli/agent-journey-fixtures.mjs +17 -0
- package/cli/agent-mail.mjs +54 -0
- package/cli/agent-network.mjs +64 -0
- package/cli/agent-reviewers.mjs +110 -0
- package/cli/agent-rpc.mjs +23 -0
- package/cli/agent-secrets.mjs +23 -0
- package/cli/agent-sponsors.mjs +43 -0
- package/cli/agent-surface.mjs +34 -0
- package/cli/agent-verifier.mjs +31 -0
- package/cli/agent-webhooks.mjs +19 -0
- package/cli/authoring.mjs +2 -1
- package/cli/business/archive-task.mjs +32 -0
- package/cli/business/carry.mjs +3 -1
- package/cli/business/catchup-task.mjs +42 -0
- package/cli/business/choices.mjs +97 -0
- package/cli/business/command.mjs +23 -5
- package/cli/business/connect.mjs +19 -7
- package/cli/business/detector.mjs +4 -1
- package/cli/business/device.mjs +13 -0
- package/cli/business/export-inputs.mjs +69 -0
- package/cli/business/export-task.mjs +17 -0
- package/cli/business/invocation.mjs +8 -1
- package/cli/business/keychain.mjs +8 -1
- package/cli/business/lease.mjs +11 -1
- package/cli/business/local-commands.mjs +79 -31
- package/cli/business/outbound.mjs +9 -4
- package/cli/business/parsers-config.mjs +8 -7
- package/cli/business/parsers-syntax.mjs +7 -3
- package/cli/business/permissions.mjs +2 -0
- package/cli/business/questions.mjs +89 -9
- package/cli/business/setup-command.mjs +49 -0
- package/cli/business/setup-company.json +15 -0
- package/cli/business/setup-demo.mjs +95 -0
- package/cli/business/state.mjs +44 -10
- package/cli/business/supervisor.mjs +94 -35
- package/cli/business/vendor-door.mjs +230 -0
- package/cli/business/vendors/README.md +29 -3
- package/cli/business/vendors/common.mjs +8 -6
- package/cli/business/vendors/index.mjs +22 -11
- package/cli/business/vendors/sorry.mjs +106 -0
- package/cli/contract.mjs +2 -2
- package/cli/demo-deploy-error.mjs +14 -0
- package/cli/demo-native.mjs +4 -1
- package/cli/deploy-config.mjs +1 -1
- package/cli/deploy-owner-input.mjs +3 -1
- package/cli/deploy-variables.mjs +89 -0
- package/cli/door-clauses.mjs +157 -0
- package/cli/export.mjs +17 -4
- package/cli/hosted-output.mjs +31 -8
- package/cli/inspect.mjs +4 -0
- package/cli/jsonc.mjs +8 -4
- package/cli/lifecycle.mjs +3 -1
- package/cli/main.mjs +1 -0
- package/cli/managed-data-schema.mjs +14 -1
- package/cli/managed-data.mjs +8 -4
- package/cli/portability-empty.mjs +6 -0
- package/cli/portability-migrations.mjs +26 -4
- package/cli/portability-worker.mjs +2 -1
- package/cli/portability.mjs +1 -0
- package/cli/production-auth.mjs +2 -2
- package/cli/production-mail.mjs +19 -3
- package/cli/server-registry.mjs +2 -0
- package/edition-authoring/archive-source.mjs +65 -0
- package/edition-authoring/base-copies.mjs +108 -21
- package/edition-authoring/cli.mjs +1 -1
- package/edition-authoring/copy-namespaces.mjs +28 -0
- package/edition-authoring/edition-migrations.mjs +7 -3
- package/edition-authoring/files.mjs +2 -1
- package/edition-authoring/module-closure.mjs +58 -27
- package/edition-authoring/module-edges.mjs +13 -2
- package/edition-authoring/workflow-copies.mjs +1 -1
- package/edition-authoring/workflow-scripts.mjs +12 -3
- package/foundation/runtime/contract-docs.mjs +220 -32
- package/foundation/runtime/contract-prose-patterns.mjs +14 -0
- package/foundation/runtime/contract-prose.mjs +88 -0
- package/global/CHANGELOG.md +151 -0
- package/global/README.md +138 -29
- package/global/door/command.mjs +3 -1
- package/global/main.mjs +1 -1
- package/modules/agent-door/CLAUSES.md +215 -0
- package/modules/agent-door/conformance/audit-pages.mjs +11 -0
- package/modules/agent-door/conformance/audit-rows.mjs +20 -0
- package/modules/agent-door/conformance/audit.mjs +63 -0
- package/modules/agent-door/conformance/authority.d.mts +2 -0
- package/modules/agent-door/conformance/authority.mjs +17 -0
- package/modules/agent-door/conformance/crypto.mjs +36 -0
- package/modules/agent-door/conformance/discovery.mjs +61 -0
- package/modules/agent-door/conformance/fixtures.mjs +41 -0
- package/modules/agent-door/conformance/index.mjs +41 -0
- package/modules/agent-door/conformance/injection.mjs +24 -0
- package/modules/agent-door/conformance/invocation.mjs +33 -0
- package/modules/agent-door/conformance/journey.mjs +117 -0
- package/modules/agent-door/conformance/narrowing.d.mts +2 -0
- package/modules/agent-door/conformance/narrowing.mjs +29 -0
- package/modules/agent-door/conformance/negative.mjs +48 -0
- package/modules/agent-door/conformance/network-modules.mjs +86 -0
- package/modules/agent-door/conformance/network-runtime.mjs +46 -0
- package/modules/agent-door/conformance/policy-phases.mjs +83 -0
- package/modules/agent-door/conformance/protocol.mjs +153 -0
- package/modules/agent-door/conformance/replay.mjs +39 -0
- package/modules/agent-door/conformance/schema.mjs +71 -0
- package/modules/agent-door/conformance/security.mjs +34 -0
- package/modules/agent-door/conformance/sponsors.mjs +68 -0
- package/modules/agent-door/conformance/step-hooks.mjs +4 -0
- package/modules/agent-door/conformance/surface.mjs +92 -0
- package/modules/agent-door/conformance/target.mjs +19 -0
- package/modules/agent-door/conformance/tool-name.d.mts +1 -0
- package/modules/agent-door/conformance/tool-name.mjs +7 -0
- package/modules/agent-door/conformance/webhooks.mjs +31 -0
- package/modules/container/image-variables.mjs +8 -2
- package/modules/delivery-producer/mail.mjs +20 -0
- package/modules/demo-host/README.md +6 -0
- package/modules/demo-host/ownership.mjs +39 -0
- package/modules/demo-host/plan.mjs +2 -1
- package/modules/demo-host/remove.mjs +6 -1
- package/modules/import-kit/schema/importer-verification-receipt.schema.json +171 -0
- package/modules/import-kit/schema/importers.schema.json +107 -0
- package/modules/import-kit/src/door/ADOPTING.md +20 -0
- package/modules/import-kit/src/door/README.md +2 -1
- package/modules/import-kit/src/door/admission.ts +5 -3
- package/modules/import-kit/src/door/archive.ts +5 -2
- package/modules/import-kit/src/door/authority.ts +1 -0
- package/modules/import-kit/src/door/grants.ts +1 -1
- package/modules/import-kit/src/door/handler.ts +14 -8
- package/modules/import-kit/src/door/index.ts +1 -1
- package/modules/import-kit/src/door/jobs.ts +40 -0
- package/modules/import-kit/src/door/operator.ts +3 -3
- package/modules/import-kit/src/door/planning.ts +10 -6
- package/modules/import-kit/src/door/protocol.ts +2 -2
- package/modules/import-kit/src/door/raw.ts +25 -0
- package/modules/import-kit/src/door/refusals.ts +1 -0
- package/modules/import-kit/src/door/types.ts +26 -6
- package/modules/import-kit/src/receipt/encoding.ts +37 -0
- package/modules/import-kit/src/receipt/index.ts +69 -0
- package/modules/import-kit/src/receipt/policy.ts +24 -0
- package/modules/import-kit/src/receipt/types.ts +64 -0
- package/modules/import-kit/src/receipt/uri.ts +45 -0
- package/modules/import-kit/src/receipt/validation.ts +87 -0
- package/modules/import-kit/src/status/encoding.ts +13 -0
- package/modules/import-kit/src/status/evidence.ts +218 -0
- package/modules/import-kit/src/status/index.ts +56 -0
- package/modules/import-kit/src/status/schema.ts +208 -0
- package/modules/import-kit/src/status/types.ts +86 -0
- package/modules/operator-auth/accounts/delegated.mjs +48 -0
- package/modules/operator-auth/index.d.mts +7 -0
- package/modules/operator-auth/service.mjs +2 -0
- package/modules/portability/README.md +37 -13
- package/modules/portability/bridge.mjs +22 -2
- package/modules/portability/catalogue.mjs +12 -2
- package/modules/portability/copies.mjs +8 -1
- package/modules/portability/derived.mjs +33 -0
- package/modules/portability/http-errors.mjs +1 -1
- package/modules/portability/import.mjs +14 -7
- package/package.json +4 -2
- package/scripts/publish-check/copy_identities.py +3 -1
- package/scripts/publish-check/github_refs.py +32 -13
- 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
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
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:
|
package/cli/business/opt-ins.mjs
DELETED
|
@@ -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
|
-
}
|