@bongos/core 1.21.176 → 1.21.178
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/.bongos-core.json +186 -496
- package/.claude/skills/planning-session/SKILL.md +2 -2
- package/clients/bongos-client/README.md +1 -1
- package/clients/bongos-client/bongos-client.global.js +0 -6
- package/clients/bongos-client/index.cjs +0 -6
- package/clients/bongos-client/index.d.ts +0 -6
- package/clients/bongos-client/index.mjs +0 -6
- package/config/scheduled-routines.json +3 -8
- package/docs/adr/0042-builder-self-deploy-ci-auto-merge.md +3 -2
- package/docs/adr/0091-bounding-the-kernel-and-db-carve.md +1 -1
- package/docs/adr/0093-tranche-2-core-carve-sequence.md +1 -1
- package/docs/api/openapi.json +1 -87
- package/docs/api-reference.md +1 -8
- package/docs/canonical-permissions.md +4 -4
- package/docs/copy-inventory.md +25 -39
- package/docs/copy-registry.json +73 -200
- package/docs/file-map.md +6 -11
- package/docs/handoff-template.md +1 -1
- package/docs/module-api-changelog.md +4 -0
- package/docs/modules-contract.md +2 -2
- package/docs/onboarding/diagrams/README.md +3 -7
- package/docs/onboarding/diagrams/assertions.json +3 -3
- package/docs/page-inventory.json +4 -7
- package/docs/page-readings.json +1520 -1569
- package/docs/recipes/ops-gotchas.md +3 -1
- package/modules/autonomy/db.js +9 -0
- package/modules/autonomy/module.json +2 -2
- package/modules/autonomy/pollers/daily-checks.js +262 -0
- package/modules/autonomy/pollers/routine-timers.js +7 -5
- package/modules/autonomy/rank-roles.js +64 -0
- package/modules/autonomy/server-schedule.js +37 -0
- package/modules/government/catalog.js +10 -7
- package/modules/government/decision-board.js +0 -1
- package/modules/government/decision-rules.js +0 -1
- package/modules/government/docket.js +0 -1
- package/modules/government/protected-surfaces.js +1 -1
- package/modules/government/protected-surfaces.json +2 -3
- package/modules/hall-ui/public/atlas.html +1 -1
- package/modules/hall-ui/public/blockers.html +1 -1
- package/modules/hall-ui/public/board-room.html +1 -1
- package/modules/hall-ui/public/city.html +1 -1
- package/modules/hall-ui/public/collab.html +1 -1
- package/modules/hall-ui/public/commands.html +1 -1
- package/modules/hall-ui/public/copy-desk.html +1 -1
- package/modules/hall-ui/public/deploy.html +1 -1
- package/modules/hall-ui/public/diagrams.html +1 -1
- package/modules/hall-ui/public/drachmae.html +1 -1
- package/modules/hall-ui/public/fleet.html +1 -1
- package/modules/hall-ui/public/gate.css +4 -26
- package/modules/hall-ui/public/gate.html +12 -27
- package/modules/hall-ui/public/gate.js +26 -176
- package/modules/hall-ui/public/gate.states.json +4 -22
- package/modules/hall-ui/public/goal-map.html +1 -1
- package/modules/hall-ui/public/goals.html +1 -1
- package/modules/hall-ui/public/government.html +1 -1
- package/modules/hall-ui/public/idea.html +1 -1
- package/modules/hall-ui/public/ideas.html +1 -1
- package/modules/hall-ui/public/index.html +1 -1
- package/modules/hall-ui/public/modules.html +1 -1
- package/modules/hall-ui/public/my-agents.html +1 -1
- package/modules/hall-ui/public/primer.html +1 -1
- package/modules/hall-ui/public/profile.html +1 -1
- package/modules/hall-ui/public/project-settings.html +1 -1
- package/modules/hall-ui/public/ranks.html +1 -1
- package/modules/hall-ui/public/roadmap.html +1 -1
- package/modules/hall-ui/public/roster.html +1 -1
- package/modules/hall-ui/public/sessions.html +1 -1
- package/modules/hall-ui/public/settings.html +1 -1
- package/modules/hall-ui/public/shell.js +1 -1
- package/modules/hall-ui/public/street-card.js +5 -9
- package/modules/hall-ui/public/street-desk.js +2 -2
- package/modules/hall-ui/public/street-inside.js +1 -1
- package/modules/hall-ui/public/street.html +1 -1
- package/modules/hall-ui/public/studio.html +1 -1
- package/modules/hall-ui/public/task.html +1 -1
- package/modules/hall-ui/public/thinking.html +1 -1
- package/modules/hall-ui/public/tweak-editor.html +1 -1
- package/modules/hall-ui/public/watch.html +1 -1
- package/modules/hall-ui/public/work.html +1 -1
- package/modules/lifecycle/matter-acts.js +0 -6
- package/modules/lifecycle/module.json +0 -1
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/release-notes.json +36 -0
- package/scripts/bongos/adopt-preflight.js +3 -3
- package/scripts/bongos/api-alias-caller-scan.js +2 -2
- package/scripts/bongos/audit-authorship.sh +1 -8
- package/scripts/bongos/audit-rank-roles.js +15 -56
- package/scripts/bongos/bump-version.js +46 -9
- package/scripts/bongos/codemod-rename-scripts-gds.js +0 -1
- package/scripts/bongos/diagram-facts.js +1 -1
- package/scripts/bongos/do-api.js +1 -1
- package/scripts/bongos/doc-cli-guard.js +2 -0
- package/scripts/bongos/doc-control-claims.js +2 -2
- package/scripts/bongos/fitness-checks-identity.js +4 -15
- package/scripts/bongos/gen-diagrams.js +3 -3
- package/scripts/bongos/government-walk.js +3 -9
- package/scripts/bongos/hard-floor.js +52 -0
- package/scripts/bongos/publish-manifest.js +3 -3
- package/scripts/bongos/pulse.js +5 -3
- package/scripts/bongos/routine-schedule.js +38 -3
- package/scripts/bongos/run-unit-tests.js +17 -5
- package/scripts/bongos/ship-regen.js +2 -3
- package/scripts/gds/{goal-names.js → hard-floor.js} +3 -4
- package/scripts/security/dep-audit.js +50 -124
- package/src/bongos/module-scope-map.js +2 -2
- package/src/bongos/permission-path-check.js +1 -1
- package/src/bongos/route-rank-check.js +1 -8
- package/src/bongos/routes.js +1 -2
- package/src/module-api.js +1 -1
- package/src/modules.js +1 -1
- package/tests/acclaim_feed_evidence_db.mjs +42 -23
- package/tests/adr_0089_scope.mjs +7 -5
- package/tests/autonomy_daily_checks.mjs +201 -0
- package/tests/bump_version.mjs +52 -18
- package/tests/claude_materialize.mjs +12 -12
- package/tests/copy_desk_flags_db.mjs +22 -14
- package/tests/effective_visibility_predicate.mjs +0 -18
- package/tests/gating_review_retired.mjs +1 -1
- package/tests/government_act_alone_buildings.mjs +1 -3
- package/tests/government_board_membership_db.mjs +35 -22
- package/tests/government_protected_surfaces.mjs +29 -13
- package/tests/governor_docket.mjs +0 -2
- package/tests/governor_matter_acts.mjs +6 -8
- package/tests/hall_city.mjs +1 -1
- package/tests/hall_matter_card.mjs +2 -2
- package/tests/hall_oversight_world.mjs +16 -12
- package/tests/hall_street_desk.mjs +4 -3
- package/tests/hall_street_inside.mjs +1 -1
- package/tests/helpers.mjs +34 -0
- package/tests/howto_state.mjs +33 -56
- package/tests/howto_state_db.mjs +68 -0
- package/tests/idea_credit_streams_db.mjs +11 -3
- package/tests/integration_parked_ratchet.mjs +7 -1
- package/tests/nav_permission_atoms.mjs +1 -1
- package/tests/page_notes_db.mjs +12 -8
- package/tests/page_tweak_no_rearm.mjs +50 -0
- package/tests/publish_manifest.mjs +64 -0
- package/tests/routine_capture_kind.mjs +18 -7
- package/tests/routine_schedule.mjs +42 -0
- package/tests/search_isolation.mjs +5 -103
- package/tests/search_isolation_db.mjs +140 -0
- package/tests/session_earnings_mirror_db.mjs +2 -0
- package/tests/workflow_exec_paths.mjs +9 -11
- package/modules/lifecycle/routes/gate-approvals.js +0 -299
- package/scripts/bongos/artifact-staleness.js +0 -267
- package/scripts/bongos/ci-grade.js +0 -82
- package/scripts/bongos/classify-discipline.js +0 -153
- package/scripts/bongos/codemod-rename-src-gds.js +0 -145
- package/scripts/bongos/coreB-carve-proof.sh +0 -725
- package/scripts/bongos/gate-review.js +0 -330
- package/scripts/bongos/goal-names.js +0 -102
- package/scripts/bongos/rename-goals.js +0 -109
- package/scripts/bongos/seed-adopt-tasks.js +0 -75
- package/scripts/bongos/seed-api-contract-goal-tasks.js +0 -141
- package/scripts/bongos/seed-board-room-tasks.js +0 -196
- package/scripts/bongos/seed-bongos-app-tasks.js +0 -294
- package/scripts/bongos/seed-bongos-coreB-tranche1-tasks.js +0 -81
- package/scripts/bongos/seed-bongos-coreB-tranche2-tasks.js +0 -100
- package/scripts/bongos/seed-bongos-goal-hierarchy-tasks.js +0 -307
- package/scripts/bongos/seed-bongos-module-system-tasks.js +0 -346
- package/scripts/bongos/seed-bongos-tasks.js +0 -214
- package/scripts/bongos/seed-bongos-v1-seo-tasks.js +0 -104
- package/scripts/bongos/seed-bv1-community-tasks.js +0 -131
- package/scripts/bongos/seed-bv1-privacy-invites-tasks.js +0 -133
- package/scripts/bongos/seed-bv1-profile-page-tasks.js +0 -161
- package/scripts/bongos/seed-bv1-r01-delta-tasks.js +0 -154
- package/scripts/bongos/seed-bv2-tweak-mode-tasks.js +0 -277
- package/scripts/bongos/seed-gds-v4-tasks.js +0 -624
- package/scripts/bongos/seed-governance-tasks.js +0 -340
- package/scripts/bongos/seed-medusa-tasks.js +0 -440
- package/scripts/bongos/seed-module-upstreaming.js +0 -219
- package/scripts/bongos/seed-productization-tasks.js +0 -235
- package/scripts/bongos/seed-project-admin-console-tasks.js +0 -88
- package/scripts/bongos/seed-provisioning-tasks.js +0 -83
- package/scripts/bongos/seed-strict-versioning-tasks.js +0 -275
- package/scripts/bongos/seed-v2-world-tasks.js +0 -283
- package/scripts/gds/artifact-staleness.js +0 -7
- package/scripts/gds/ci-grade.js +0 -7
- package/scripts/gds/classify-discipline.js +0 -7
- package/scripts/gds/codemod-rename-src-gds.js +0 -7
- package/scripts/gds/coreB-carve-proof.sh +0 -8
- package/scripts/gds/gate-review.js +0 -7
- package/scripts/gds/rename-goals.js +0 -7
- package/scripts/gds/seed-adopt-tasks.js +0 -7
- package/scripts/gds/seed-api-contract-goal-tasks.js +0 -7
- package/scripts/gds/seed-board-room-tasks.js +0 -6
- package/scripts/gds/seed-bongos-app-tasks.js +0 -7
- package/scripts/gds/seed-bongos-coreB-tranche1-tasks.js +0 -7
- package/scripts/gds/seed-bongos-coreB-tranche2-tasks.js +0 -7
- package/scripts/gds/seed-bongos-goal-hierarchy-tasks.js +0 -7
- package/scripts/gds/seed-bongos-module-system-tasks.js +0 -7
- package/scripts/gds/seed-bongos-tasks.js +0 -7
- package/scripts/gds/seed-bongos-v1-seo-tasks.js +0 -6
- package/scripts/gds/seed-bv1-community-tasks.js +0 -6
- package/scripts/gds/seed-bv1-privacy-invites-tasks.js +0 -6
- package/scripts/gds/seed-bv1-profile-page-tasks.js +0 -6
- package/scripts/gds/seed-bv1-r01-delta-tasks.js +0 -6
- package/scripts/gds/seed-bv2-tweak-mode-tasks.js +0 -6
- package/scripts/gds/seed-gds-v4-tasks.js +0 -7
- package/scripts/gds/seed-governance-tasks.js +0 -7
- package/scripts/gds/seed-medusa-tasks.js +0 -7
- package/scripts/gds/seed-module-upstreaming.js +0 -7
- package/scripts/gds/seed-productization-tasks.js +0 -7
- package/scripts/gds/seed-project-admin-console-tasks.js +0 -6
- package/scripts/gds/seed-provisioning-tasks.js +0 -7
- package/scripts/gds/seed-strict-versioning-tasks.js +0 -7
- package/scripts/gds/seed-v2-world-tasks.js +0 -7
- package/scripts/migrate_cost_ledger.sh +0 -178
- package/tests/artifact_staleness.mjs +0 -207
- package/tests/gate_approvals.mjs +0 -611
- package/tests/gate_review.mjs +0 -152
- package/tests/goal_names.mjs +0 -120
- package/tests/newcomer_generator.mjs +0 -48
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// classify-discipline — bulk-classify tasks.discipline via the heuristic
|
|
3
|
-
// classifier in src/bongos/task-classifier.js.
|
|
4
|
-
//
|
|
5
|
-
// Usage:
|
|
6
|
-
// node scripts/bongos/classify-discipline.js [--commit] [--all] [--limit N]
|
|
7
|
-
//
|
|
8
|
-
// Default mode: dry-run. Walks every task whose discipline is currently
|
|
9
|
-
// 'unclassified', runs classifyTaskDiscipline() over title + description +
|
|
10
|
-
// touches, and prints a table of proposed classifications. Nothing is
|
|
11
|
-
// written to the DB.
|
|
12
|
-
//
|
|
13
|
-
// With --commit: same walk, but PATCH /tasks/:id for every proposal that
|
|
14
|
-
// came back as engineer, artist, or ideator. Tasks the classifier leaves as
|
|
15
|
-
// 'unclassified' are skipped (left for hand-triage).
|
|
16
|
-
//
|
|
17
|
-
// With --all: include tasks that already have a non-unclassified
|
|
18
|
-
// discipline. Useful for re-running after tweaking the classifier rules;
|
|
19
|
-
// will overwrite existing classifications. NOT the default.
|
|
20
|
-
//
|
|
21
|
-
// Idempotent without --all: re-running after a successful --commit is a
|
|
22
|
-
// no-op because every previously-classified row falls outside the filter.
|
|
23
|
-
|
|
24
|
-
const { cliClient, requireSession } = require('./cli-lib');
|
|
25
|
-
// task-classifier carved to modules/lifecycle/ (BV1.R86); a CLI may require a
|
|
26
|
-
// module directly (outside the kernel boundary — the grading/economy precedent).
|
|
27
|
-
const { classifyTaskDiscipline } = require('../../modules/lifecycle/task-classifier');
|
|
28
|
-
|
|
29
|
-
function pad(s, n) {
|
|
30
|
-
s = String(s);
|
|
31
|
-
return s.length >= n ? s.slice(0, n) : s + ' '.repeat(n - s.length);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function emoji(d) {
|
|
35
|
-
if (d === 'artist') return '🎨';
|
|
36
|
-
if (d === 'ideator') return '💡';
|
|
37
|
-
if (d === 'engineer') return '🔧';
|
|
38
|
-
return '· ';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
(async () => {
|
|
42
|
-
await requireSession();
|
|
43
|
-
const args = process.argv.slice(2);
|
|
44
|
-
const commit = args.includes('--commit');
|
|
45
|
-
const all = args.includes('--all');
|
|
46
|
-
const limitIdx = args.indexOf('--limit');
|
|
47
|
-
const limit = limitIdx >= 0 ? Number(args[limitIdx + 1]) : Infinity;
|
|
48
|
-
|
|
49
|
-
// Fetch tasks. Without --all we ask the API for only unclassified rows
|
|
50
|
-
// so we don't have to pull every shipped task to triage them later.
|
|
51
|
-
const api = await cliClient();
|
|
52
|
-
const r = await api.tasks.getTasks(all ? {} : { query: { discipline: 'unclassified' } });
|
|
53
|
-
if (!r.ok) {
|
|
54
|
-
console.error(`failed (${r.status}):`, r.data);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
const rawTasks = (r.data?.tasks || []).slice(0, limit);
|
|
58
|
-
// Skip __smoke__ test debris — these aren't real work, classifying them
|
|
59
|
-
// would just pollute the discipline filter. Mig 005 already filters them
|
|
60
|
-
// from claimable_tasks / version_progress on the public side.
|
|
61
|
-
const smokeFiltered = rawTasks.filter((t) => /^__smoke__/.test(t.title || ''));
|
|
62
|
-
const tasks = rawTasks.filter((t) => !/^__smoke__/.test(t.title || ''));
|
|
63
|
-
if (tasks.length === 0) {
|
|
64
|
-
console.log('nothing to classify — every task already has a discipline.');
|
|
65
|
-
if (smokeFiltered.length) {
|
|
66
|
-
console.log(`(skipped ${smokeFiltered.length} __smoke__ debris rows)`);
|
|
67
|
-
}
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Run classifier locally — no API round-trip per task.
|
|
72
|
-
const proposals = tasks.map((t) => {
|
|
73
|
-
const result = classifyTaskDiscipline(t.title, t.description, t.touches);
|
|
74
|
-
return { task: t, ...result };
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Print summary table grouped by discipline.
|
|
78
|
-
const buckets = {
|
|
79
|
-
engineer: proposals.filter((p) => p.discipline === 'engineer'),
|
|
80
|
-
artist: proposals.filter((p) => p.discipline === 'artist'),
|
|
81
|
-
ideator: proposals.filter((p) => p.discipline === 'ideator'),
|
|
82
|
-
unclassified: proposals.filter((p) => p.discipline === 'unclassified'),
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
console.log('');
|
|
86
|
-
console.log(`Proposed classifications across ${proposals.length} tasks:`);
|
|
87
|
-
console.log(` ${emoji('engineer')} engineer ${buckets.engineer.length}`);
|
|
88
|
-
console.log(` ${emoji('artist')} artist ${buckets.artist.length}`);
|
|
89
|
-
console.log(` ${emoji('ideator')} ideator ${buckets.ideator.length}`);
|
|
90
|
-
console.log(` ${emoji('unclassified')} unclassified ${buckets.unclassified.length} (will be skipped)`);
|
|
91
|
-
if (smokeFiltered.length) {
|
|
92
|
-
console.log(` 🧪 __smoke__ ${smokeFiltered.length} (filtered as test debris, not classified)`);
|
|
93
|
-
}
|
|
94
|
-
console.log('');
|
|
95
|
-
|
|
96
|
-
// Detail by bucket. Within each bucket: highest-confidence first so
|
|
97
|
-
// the strong signals are at the top — easy to spot the weakest.
|
|
98
|
-
for (const bucket of ['engineer', 'artist', 'ideator']) {
|
|
99
|
-
if (!buckets[bucket].length) continue;
|
|
100
|
-
console.log(`--- ${bucket} ---`);
|
|
101
|
-
const sorted = buckets[bucket].slice().sort((a, b) => b.confidence - a.confidence);
|
|
102
|
-
for (const p of sorted) {
|
|
103
|
-
const { task: t } = p;
|
|
104
|
-
const version = pad(`[${t.version_id || '?'}]`, 10);
|
|
105
|
-
const conf = `(${p.confidence.toFixed(2)})`;
|
|
106
|
-
const title = (t.title || '').slice(0, 80);
|
|
107
|
-
console.log(` #${pad(t.id, 4)} ${conf} ${version} ${title}`);
|
|
108
|
-
}
|
|
109
|
-
console.log('');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (buckets.unclassified.length) {
|
|
113
|
-
console.log('--- unclassified (signals too weak / balanced) ---');
|
|
114
|
-
for (const p of buckets.unclassified.slice(0, 20)) {
|
|
115
|
-
const { task: t } = p;
|
|
116
|
-
const version = pad(`[${t.version_id || '?'}]`, 10);
|
|
117
|
-
const title = (t.title || '').slice(0, 80);
|
|
118
|
-
console.log(` #${pad(t.id, 4)} ${version} ${title}`);
|
|
119
|
-
}
|
|
120
|
-
if (buckets.unclassified.length > 20) {
|
|
121
|
-
console.log(` ... ${buckets.unclassified.length - 20} more`);
|
|
122
|
-
}
|
|
123
|
-
console.log('');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!commit) {
|
|
127
|
-
console.log('Dry-run only. Re-run with --commit to write classifications via PATCH.');
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Commit: PATCH each non-unclassified proposal.
|
|
132
|
-
const toWrite = [...buckets.engineer, ...buckets.artist, ...buckets.ideator];
|
|
133
|
-
console.log(`Committing ${toWrite.length} classifications...`);
|
|
134
|
-
let ok = 0;
|
|
135
|
-
let failed = 0;
|
|
136
|
-
for (const p of toWrite) {
|
|
137
|
-
const res = await api.tasks.patchTasksId({
|
|
138
|
-
id: p.task.id,
|
|
139
|
-
body: { discipline: p.discipline },
|
|
140
|
-
});
|
|
141
|
-
if (res.ok) {
|
|
142
|
-
ok++;
|
|
143
|
-
} else {
|
|
144
|
-
failed++;
|
|
145
|
-
console.error(` PATCH #${p.task.id} failed (${res.status}):`, res.data?.error || res.data);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
console.log('');
|
|
149
|
-
console.log(`Done. ${ok} updated, ${failed} failed.`);
|
|
150
|
-
})().catch((err) => {
|
|
151
|
-
console.error('fatal:', err);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
});
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// scripts/gds/codemod-rename-src-gds.js
|
|
3
|
-
//
|
|
4
|
-
// One-shot, auditable codemod for task 2004 (BV1.R124): rename the core source
|
|
5
|
-
// directory src/gds/ -> src/bongos/ and rewrite EVERY in-repo reference to it.
|
|
6
|
-
// Committed so the approach is reproducible and reviewable (task done-when).
|
|
7
|
-
//
|
|
8
|
-
// Deterministic by construction:
|
|
9
|
-
// 1. `git mv src/gds src/bongos` (idempotent -- skipped if already moved).
|
|
10
|
-
// 2. Over every TRACKED text file, rewrite the literal path token `src/gds`
|
|
11
|
-
// -> `src/bongos`, guarded by a TRAILING boundary so look-alike tokens are
|
|
12
|
-
// never clobbered:
|
|
13
|
-
// src/gds/... -> src/bongos/... (directory refs)
|
|
14
|
-
// "src/gds" -> "src/bongos" (bare, at a boundary)
|
|
15
|
-
// src/gds-client -> src/gds-client (UNCHANGED: a look-alike file name)
|
|
16
|
-
// src/gdsx -> src/gdsx (UNCHANGED here: prefix-edge fixture)
|
|
17
|
-
//
|
|
18
|
-
// Regex: /src\/gds(?![A-Za-z0-9_-])/g -- trailing guard only. No LEADING guard:
|
|
19
|
-
// `scripts/gds` contains no `src/gds` substring, and the two real leading-glue
|
|
20
|
-
// sites (`keyed-to-src/gds` in an audit, `\tsrc/gds/auth.js` in a mirror-export
|
|
21
|
-
// fixture) are genuine directory refs we DO want rewritten.
|
|
22
|
-
//
|
|
23
|
-
// Excluded from the sweep (see EXCLUDE):
|
|
24
|
-
// - this script (its own source contains the search literal),
|
|
25
|
-
// - tests/path_match.mjs + tests/touches_overlap.mjs -- they assert the
|
|
26
|
-
// "src/gdsx must NOT match src/gds/" boundary edge; a mechanical half-rewrite
|
|
27
|
-
// (which leaves `src/gdsx` but changes `src/gds/`) would silently gut the
|
|
28
|
-
// test. Those two are hand-edited to src/bongos / src/bongosx so the edge
|
|
29
|
-
// stays meaningful.
|
|
30
|
-
//
|
|
31
|
-
// git ls-files is the file source, so gitignored generated docs
|
|
32
|
-
// (docs/repo-map.md, docs/session-log-index.md) are excluded -- they regenerate.
|
|
33
|
-
// Binary files are skipped via a NUL-byte sniff.
|
|
34
|
-
//
|
|
35
|
-
// Idempotent: a second run moves nothing and rewrites nothing (0 replacements).
|
|
36
|
-
|
|
37
|
-
const { execSync } = require('node:child_process');
|
|
38
|
-
const fs = require('node:fs');
|
|
39
|
-
const path = require('node:path');
|
|
40
|
-
|
|
41
|
-
const REPO_ROOT = execSync('git rev-parse --show-toplevel').toString().trim();
|
|
42
|
-
|
|
43
|
-
// (a) The slash form: `src/gds`, `src/gds/routes`, `"src/gds"` ... Trailing guard
|
|
44
|
-
// only (see header) so `src/gds-client` and `src/gdsx` are left alone.
|
|
45
|
-
const NEEDLE = /src\/gds(?![A-Za-z0-9_-])/g;
|
|
46
|
-
const REPLACEMENT = 'src/bongos';
|
|
47
|
-
|
|
48
|
-
// (b) The SPLIT-SEGMENT form: `path.join(root, 'src', 'gds', ...)` -- the segments
|
|
49
|
-
// are separate string args, so there is no literal `src/gds` substring for (a) to
|
|
50
|
-
// catch. Anchored on a PRECEDING quoted `'src'` segment so it rewrites only the
|
|
51
|
-
// `'gds'` that follows `'src'` -- NEVER `'scripts', 'gds'` (scripts/gds is not
|
|
52
|
-
// renamed). \s between segments tolerates a newline-split path.join. The `gds`
|
|
53
|
-
// quote must close immediately, so `'gdsx'` / `'gds-client'` never match.
|
|
54
|
-
const SEG = /(['"])src\1(\s*,\s*)(['"])gds\3/g;
|
|
55
|
-
const segReplace = (s) => s.replace(SEG, (_m, q1, sep, q2) => `${q1}src${q1}${sep}${q2}bongos${q2}`);
|
|
56
|
-
|
|
57
|
-
// (c) RELATIVE requires into the moved dir. A file DIRECTLY under src/ addresses
|
|
58
|
-
// its former sibling as `require('./gds/x')` -- no `src/` prefix, so (a) misses it,
|
|
59
|
-
// and after the move it dangles. `./gds` resolves to src/gds ONLY from a src-top-
|
|
60
|
-
// level file; a `./gds` in scripts/* means scripts/gds (NOT renamed) and a deeper
|
|
61
|
-
// src/**/* file resolves elsewhere -- so this pass is gated to `src/<file>` and
|
|
62
|
-
// never fires elsewhere. (Verified: the only matches are src/module-api.js +
|
|
63
|
-
// src/platform-server.js; no `../gds` relative forms exist.) `(?=\/|['"])` keeps
|
|
64
|
-
// `./gds-client` / `./gdsx` safe.
|
|
65
|
-
const isSrcTopLevel = (rel) => /^src\/[^/]+\.(?:js|mjs|cjs)$/.test(rel);
|
|
66
|
-
const REL = /(\.\/)gds(?=\/|['"])/g;
|
|
67
|
-
|
|
68
|
-
// (d) REGEX-ESCAPED slash form: `src\/gds` (backslash-slash) as written inside a
|
|
69
|
-
// RegExp literal -- e.g. route-rank-check.js's ROUTE_FILE_RE and the tests that
|
|
70
|
-
// match against it. `\/` is not the plain `/` (a) scans for, so (a) misses it.
|
|
71
|
-
const ESC = /src\\\/gds(?![A-Za-z0-9_-])/g;
|
|
72
|
-
|
|
73
|
-
// (e) WINDOWS double-backslash form: `src\\gds` in JS source (one backslash on
|
|
74
|
-
// disk-per-escape, two chars) -- Windows-path fixtures the matchers normalize
|
|
75
|
-
// (permission_path / publish_manifest). Trailing guard keeps `src\\gdsx` safe.
|
|
76
|
-
const WIN = /src\\\\gds(?![A-Za-z0-9_-])/g;
|
|
77
|
-
|
|
78
|
-
const EXCLUDE = new Set([
|
|
79
|
-
'scripts/gds/codemod-rename-src-gds.js',
|
|
80
|
-
'tests/path_match.mjs',
|
|
81
|
-
'tests/touches_overlap.mjs',
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
|
-
function gitMv() {
|
|
85
|
-
const oldDir = path.join(REPO_ROOT, 'src', 'gds');
|
|
86
|
-
const newDir = path.join(REPO_ROOT, 'src', 'bongos');
|
|
87
|
-
if (fs.existsSync(newDir)) {
|
|
88
|
-
console.log('git mv: src/bongos already exists -- skipping move (idempotent).');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (!fs.existsSync(oldDir)) {
|
|
92
|
-
console.log('git mv: neither src/gds nor src/bongos present -- nothing to move.');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
execSync('git mv src/gds src/bongos', { cwd: REPO_ROOT, stdio: 'inherit' });
|
|
96
|
-
console.log('git mv: src/gds -> src/bongos');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function isBinary(buf) {
|
|
100
|
-
const n = Math.min(buf.length, 8192);
|
|
101
|
-
for (let i = 0; i < n; i++) if (buf[i] === 0) return true;
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function main() {
|
|
106
|
-
gitMv();
|
|
107
|
-
|
|
108
|
-
const tracked = execSync('git ls-files', { cwd: REPO_ROOT, maxBuffer: 128 * 1024 * 1024 })
|
|
109
|
-
.toString().split('\n').filter(Boolean);
|
|
110
|
-
|
|
111
|
-
let filesChanged = 0;
|
|
112
|
-
let totalReplacements = 0;
|
|
113
|
-
const changed = [];
|
|
114
|
-
|
|
115
|
-
for (const rel of tracked) {
|
|
116
|
-
if (EXCLUDE.has(rel)) continue;
|
|
117
|
-
const abs = path.join(REPO_ROOT, rel);
|
|
118
|
-
let buf;
|
|
119
|
-
try { buf = fs.readFileSync(abs); } catch { continue; } // e.g. deleted-in-index
|
|
120
|
-
if (isBinary(buf)) continue;
|
|
121
|
-
const before = buf.toString('utf8');
|
|
122
|
-
const slashN = (before.match(NEEDLE) || []).length;
|
|
123
|
-
const segN = (before.match(SEG) || []).length;
|
|
124
|
-
const escN = (before.match(ESC) || []).length;
|
|
125
|
-
const winN = (before.match(WIN) || []).length;
|
|
126
|
-
const relN = isSrcTopLevel(rel) ? (before.match(REL) || []).length : 0;
|
|
127
|
-
if (slashN === 0 && segN === 0 && escN === 0 && winN === 0 && relN === 0) continue;
|
|
128
|
-
let after = segReplace(before.replace(NEEDLE, REPLACEMENT));
|
|
129
|
-
after = after.replace(ESC, 'src\\/bongos').replace(WIN, 'src\\\\bongos');
|
|
130
|
-
if (relN > 0) after = after.replace(REL, '$1bongos');
|
|
131
|
-
if (after === before) continue;
|
|
132
|
-
fs.writeFileSync(abs, after);
|
|
133
|
-
filesChanged++;
|
|
134
|
-
const n = slashN + segN + escN + winN + relN;
|
|
135
|
-
totalReplacements += n;
|
|
136
|
-
changed.push({ rel, n });
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
changed.sort((a, b) => b.n - a.n);
|
|
140
|
-
console.log(`\ncodemod: rewrote ${totalReplacements} reference(s) across ${filesChanged} file(s).`);
|
|
141
|
-
for (const c of changed) console.log(` ${String(c.n).padStart(4)} ${c.rel}`);
|
|
142
|
-
console.log('\nExcluded (hand-edited or self): ' + [...EXCLUDE].join(', '));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
main();
|