@webpieces/rules-config 0.4.950 → 0.4.952
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/package.json +5 -5
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/policy-tracking.d.ts +12 -0
- package/src/policy-tracking.js +47 -9
- package/src/policy-tracking.js.map +1 -1
- package/src/rule-pack-sync.js +12 -3
- package/src/rule-pack-sync.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/rules-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.952",
|
|
4
4
|
"description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"inversify": "7.10.4",
|
|
20
20
|
"reflect-metadata": "0.2.2",
|
|
21
21
|
"minimatch": "10.0.1",
|
|
22
|
-
"@webpieces/tooling-common": "0.4.
|
|
23
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
24
|
-
"@webpieces/rules-sdk": "0.4.
|
|
22
|
+
"@webpieces/tooling-common": "0.4.952",
|
|
23
|
+
"@webpieces/repo-workflow-core": "0.4.952",
|
|
24
|
+
"@webpieces/rules-sdk": "0.4.952"
|
|
25
25
|
},
|
|
26
26
|
"author": "Dean Hiller",
|
|
27
27
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.952"
|
|
38
38
|
},
|
|
39
39
|
"types": "./src/index.d.ts",
|
|
40
40
|
"bin": {
|
package/src/index.d.ts
CHANGED
|
@@ -70,5 +70,6 @@ export { RulePackSync } from './rule-pack-sync';
|
|
|
70
70
|
export { ConfigRepairAccess } from './config-repair-access';
|
|
71
71
|
export { ConfigRepairBootstrap } from './config-repair-probe';
|
|
72
72
|
export { ConfigRepairCure, ConfigRepairError, EditFileCure, RunCommandCure, RepositoryLayoutRepair, } from './config-repair-error';
|
|
73
|
+
export { UntrackedPolicyError } from './policy-tracking';
|
|
73
74
|
export { RuleRuntimeModules, RuleRuntimeModuleLoader, NodeRuleRuntimeModuleLoader, RuntimeContributionGroup, } from './rule-runtime-modules';
|
|
74
75
|
export { FirstPathMatch, FirstPathMatchResult, PathMatchCandidate } from './first-path-match';
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.HOME_CONFIG_DIR = exports.RETIRED_HOME_CONFIG_KEYS = exports.RetiredHome
|
|
|
5
5
|
exports.resolveBase = exports.detectBase = exports.SkipRuleResult = exports.HOTFIX_AUDIT_BANNER = exports.HOTFIX_BUILD_COMMAND = exports.shouldSkipRule = exports.sectionForRule = exports.isHookGuard = exports.schemaFieldNames = exports.DEFAULT_MATCH_RULES = exports.renderMatchRuleMessage = exports.compileMatchRulePatterns = exports.isMatchRuleAllowedPath = exports.findMatchRuleViolations = exports.MatchRuleViolation = exports.MatchRuleConfig = exports.OrphanSweepReport = exports.OrphanDirSweeper = exports.TRASH_RETENTION_DAYS = exports.TRASH_MANIFEST_FILE = exports.TRASH_STATE_DIR = exports.OrphanSweepManifest = exports.OrphanSweepResult = exports.FailedOrphan = exports.ArchivedOrphan = exports.OrphanDirArchiver = exports.OrphanCandidate = exports.OrphanDirScanner = exports.MAX_ROW_BYTES = exports.BUILDS_LOG_GENERATIONS = exports.MAX_BUILDS_LOG_BYTES = exports.BUILD_DONE_FAIL = exports.BUILD_DONE_SUCCESS = exports.BUILD_START = exports.BUILDS_LOCK_FILE = exports.BUILDS_LOG_FILE = exports.RunningBuild = exports.BuildTermination = exports.BuildTicket = exports.BuildsLog = exports.DOCUMENTATION_KEYS = exports.HOME_KEY_AI_DOC = exports.HOME_KEY_DOC = exports.DEFAULT_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_TURN_OFF_ALL_REVIEWERS = exports.HOME_KEY_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_WHOLE_REPO_BUILD_GUARD = exports.HOME_KEY_ORPHAN_DIR_SWEEP = exports.HOME_EXPERIMENTAL_SECTION = exports.HOME_CONFIG_FILE = void 0;
|
|
6
6
|
exports.normalizeChecklistDoc = exports.toChecklist = exports.DEFAULT_REVIEWER_AGENT_NAME = exports.REVIEWER_AGENTS_PLACEHOLDER = exports.ReviewerAgentPolicy = exports.ChecklistDefinition = exports.MERGE_MODES = exports.MERGE_MODE_NONE = exports.MERGE_MODE_AUTO = exports.buildDevDeployConfig = exports.buildLandPrConfig = exports.buildPrGateConfig = exports.defaultDevDeployConfig = exports.defaultLandPrConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.ReviewContextEntry = exports.DEFAULT_DEV_BRANCH = exports.DEFAULT_DEV_BRANCH_NAMESPACE = exports.DevDeployConfig = exports.LandPrConfig = exports.DEFAULT_BUILD_COMMAND = exports.PrGateConfig = exports.GateDefinition = exports.WP_FINISH_PUSH_DEV = exports.WP_PUSH_DEV = exports.WP_FINISH_UPSERT_PR = exports.WP_START_UPSERT_PR = exports.WP_FINISH_UPDATE = exports.WP_START_UPDATE = exports.SyncFlowGuidance = exports.WebpiecesRulesConfig = exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.PUSH_DEV_STATE_FILE = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.MERGE_INFO_DIR = exports.hasDisable = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.ChangedFilesOptions = exports.DiffRange = exports.DiffScope = exports.isNewOrModified = exports.hasChangesInRange = exports.findNewMethodSignaturesInDiff = exports.getChangedLineNumbers = exports.getFileDiff = exports.getChangedFiles = void 0;
|
|
7
7
|
exports.VERDICT_RED = exports.VERDICT_ORANGE = exports.VERDICT_YELLOW = exports.VERDICT_GREEN = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_ORANGE = exports.CK_ORANGE_FIXED = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.checklistOverrideService = exports.ChecklistOverrideService = exports.ChecklistOverride = exports.ChecklistVerdict = exports.ChecklistResult = exports.PrContext = exports.AddressedIssue = exports.PrSummary = exports.DEFAULT_RETENTION_DAYS = exports.ProvenanceWriteRequest = exports.OfferedContext = exports.ReviewerPaths = exports.ReviewerTranscript = exports.ReviewProvenance = exports.ReviewProvenanceService = exports.PROVENANCE_SKIPPED = exports.PROVENANCE_MISSING = exports.PROVENANCE_OK = exports.ProvenanceResult = exports.TranscriptScan = exports.ExpectedReviewer = exports.ReviewerContext = exports.ReviewerEvidence = exports.SubagentProvenanceService = exports.verifyGateToken = exports.extractGateToken = exports.gateTokenMarker = exports.computeGateToken = exports.GateTokenService = exports.ALL_DIFF_ONE_READ_LINES = exports.READ_TRUNCATION_LINES = exports.ContextEntry = exports.BriefedFile = exports.ReviewerBriefing = exports.ReviewerInstructionsService = exports.ChecklistInstructionsService = exports.ChecklistValidator = exports.formatFileList = void 0;
|
|
8
|
-
exports.PathMatchCandidate = exports.FirstPathMatchResult = exports.FirstPathMatch = exports.RuntimeContributionGroup = exports.NodeRuleRuntimeModuleLoader = exports.RuleRuntimeModuleLoader = exports.RuleRuntimeModules = exports.RepositoryLayoutRepair = exports.RunCommandCure = exports.EditFileCure = exports.ConfigRepairError = exports.ConfigRepairCure = exports.ConfigRepairBootstrap = exports.ConfigRepairAccess = exports.RulePackSync = exports.PackPolicyFiles = exports.PackPolicyFilesResult = exports.SelectedPolicyPack = exports.PackPolicyDeclaration = exports.LegacyUpgradeResult = exports.LegacyConfigDocument = exports.prepareLegacyUpgrade = exports.RulePackModuleLoader = exports.RulePackDiscovery = exports.NodeRulePackModuleLoader = exports.RulePackRegistry = exports.TMP_SCRATCH_PREFIX = exports.TMP_SCRATCH_RETENTION_DAYS = exports.TmpScratchSweeper = exports.SCRATCH_DIR_NAME = exports.RepoScratchDirs = exports.staleBinSweeper = exports.StaleBinSweeper = exports.StaleBinRemoval = exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.summaryJsonSchemaHint = exports.summaryJsonPath = exports.prDirFor = exports.ReviewJsonService = exports.ChecklistReviewContext = exports.RequiredChecklist = exports.VERDICT_STATUSES = void 0;
|
|
8
|
+
exports.PathMatchCandidate = exports.FirstPathMatchResult = exports.FirstPathMatch = exports.RuntimeContributionGroup = exports.NodeRuleRuntimeModuleLoader = exports.RuleRuntimeModuleLoader = exports.RuleRuntimeModules = exports.UntrackedPolicyError = exports.RepositoryLayoutRepair = exports.RunCommandCure = exports.EditFileCure = exports.ConfigRepairError = exports.ConfigRepairCure = exports.ConfigRepairBootstrap = exports.ConfigRepairAccess = exports.RulePackSync = exports.PackPolicyFiles = exports.PackPolicyFilesResult = exports.SelectedPolicyPack = exports.PackPolicyDeclaration = exports.LegacyUpgradeResult = exports.LegacyConfigDocument = exports.prepareLegacyUpgrade = exports.RulePackModuleLoader = exports.RulePackDiscovery = exports.NodeRulePackModuleLoader = exports.RulePackRegistry = exports.TMP_SCRATCH_PREFIX = exports.TMP_SCRATCH_RETENTION_DAYS = exports.TmpScratchSweeper = exports.SCRATCH_DIR_NAME = exports.RepoScratchDirs = exports.staleBinSweeper = exports.StaleBinSweeper = exports.StaleBinRemoval = exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.summaryJsonSchemaHint = exports.summaryJsonPath = exports.prDirFor = exports.ReviewJsonService = exports.ChecklistReviewContext = exports.RequiredChecklist = exports.VERDICT_STATUSES = void 0;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
var types_1 = require("./types");
|
|
11
11
|
Object.defineProperty(exports, "ResolvedConfig", { enumerable: true, get: function () { return types_1.ResolvedConfig; } });
|
|
@@ -414,6 +414,8 @@ Object.defineProperty(exports, "ConfigRepairError", { enumerable: true, get: fun
|
|
|
414
414
|
Object.defineProperty(exports, "EditFileCure", { enumerable: true, get: function () { return config_repair_error_1.EditFileCure; } });
|
|
415
415
|
Object.defineProperty(exports, "RunCommandCure", { enumerable: true, get: function () { return config_repair_error_1.RunCommandCure; } });
|
|
416
416
|
Object.defineProperty(exports, "RepositoryLayoutRepair", { enumerable: true, get: function () { return config_repair_error_1.RepositoryLayoutRepair; } });
|
|
417
|
+
var policy_tracking_1 = require("./policy-tracking");
|
|
418
|
+
Object.defineProperty(exports, "UntrackedPolicyError", { enumerable: true, get: function () { return policy_tracking_1.UntrackedPolicyError; } });
|
|
417
419
|
var rule_runtime_modules_1 = require("./rule-runtime-modules");
|
|
418
420
|
Object.defineProperty(exports, "RuleRuntimeModules", { enumerable: true, get: function () { return rule_runtime_modules_1.RuleRuntimeModules; } });
|
|
419
421
|
Object.defineProperty(exports, "RuleRuntimeModuleLoader", { enumerable: true, get: function () { return rule_runtime_modules_1.RuleRuntimeModuleLoader; } });
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAE3C,qDAA+F;AAAtF,gHAAA,aAAa,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AACnE,uGAAuG;AACvG,sFAAsF;AACtF,2CAAwD;AAA/C,oGAAA,MAAM,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACjC,2DAAqF;AAA5E,qHAA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AA,iBAAiB,OAAA;AACjB,0HAAA,oBAAoB,OAAA;AAGxB,iEAIiC;AAH7B,6HAAA,oBAAoB,OAAA;AACpB,6HAAA,oBAAoB,OAAA;AACpB,4HAAA,mBAAmB,OAAA;AAEvB,yDAK6B;AAJzB,0HAAA,qBAAqB,OAAA;AACrB,uHAAA,kBAAkB,OAAA;AAClB,0HAAA,qBAAqB,OAAA;AACrB,oHAAA,eAAe,OAAA;AAEnB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,6DAA8D;AAArD,4HAAA,qBAAqB,OAAA;AAC9B,6DAM+B;AAL3B,uHAAA,gBAAgB,OAAA;AAChB,wHAAA,iBAAiB,OAAA;AACjB,mHAAA,YAAY,OAAA;AACZ,qHAAA,cAAc,OAAA;AACd,6HAAA,sBAAsB,OAAA;AAE1B,+DAKgC;AAJ5B,0HAAA,kBAAkB,OAAA;AAClB,+HAAA,uBAAuB,OAAA;AACvB,mIAAA,2BAA2B,OAAA;AAC3B,gIAAA,wBAAwB,OAAA;AAG5B,uDAA8F;AAArF,kHAAA,cAAc,OAAA;AAAE,wHAAA,oBAAoB,OAAA;AAAE,sHAAA,kBAAkB,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\n\nexport { RuleFailError, renderRuleFailForAi, renderRuleFailForHuman } from './rule-fail-error';\n// THE one representation of a cure, shared by RuleFailError (build-time) and FixHint (edit-time), plus\n// the one renderer that owns the \"Fix Option N:\" numbering and the \"(preferred)\" tag.\nexport { Option, formatFixOptions } from './fix-option';\nexport { TurnOffRuleCure, LAST_RESORT_TURN_OFF_SECONDS } from './turn-off-rule-cure';\nexport { CliExitError } from './cli-exit-error';\nexport { CliUsage, CliFlag, CliArgSet, CliArgsCheck, CliArgs } from './cli-args';\nexport { runMain } from './run-main';\n\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\n// The validation-failure banner: ONE cure (edit the file), plus the marker phrases the validator\n// messages embed rather than re-type.\nexport {\n formatConfigErrorsBanner,\n CONFIG_POLICY_DOC,\n RETIRED_KEY_MARKER,\n RETIRED_TOP_LEVEL_MARKER,\n} from './config-error-banner';\nexport {\n findConfigFile,\n CONFIG_FILENAME,\n ConfigFile,\n ConfigParseAttempt,\n CONFIG_PARSE_ATTEMPTS,\n CONFIG_PARSE_RETRY_MILLIS,\n} from './config-file';\n// The PARSED-BUT-UNVALIDATED config shape. Exported for readers that walk the file generically rather\n// than through the typed config (the pr-gate active-hatch dashboard section reads every rule's hatches).\nexport { RawConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR, INSTRUCT_AI_LEAF } from './repo-root';\n// The scoped `.webpieces` resolver. EVERY reader/writer of `.webpieces/...` goes through one of its two\n// named methods so the call site declares whether the state is repo-wide or worktree-private.\n\n// There is NO machine-global state root. `MachineStateHome`/`StateHome`/`WEBPIECES_STATE_HOME` and the\n// `PrBodyStore` that used them are DELETED: the one artifact that needed a scope above the clone was the\n// gated squash body, and GitHub holds it now (it IS the PR description). Every `.webpieces` path a\n// webpieces tool writes is `{repo}/.webpieces`, resolved through `DotWebpieces` above. See\n// `decisions/0005-the-pr-description-is-the-merge-body.md`.\nexport { AgedTreeSweeper, SweepCount, RETENTION_DAYS } from './aged-tree-sweep';\nexport {\n ClaudeEnv,\n claudeEnv,\n CLAUDE_PROJECT_DIR_ENV,\n CLAUDE_PROJECT_DIR_UNSET,\n} from './claude-env';\n\n// The ONE formatter for a remedy that must run in a named directory: `cd '<root>' && <command>`.\n// Single-quoted so a repo path containing a space is still runnable (and still un-smuggleable).\nexport { atRoot } from './at-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './di';\nexport { ExcludePaths, isWebpiecesStateDir } from './exclude-hook-paths';\nexport { isPathExcluded, matchesAnyGlob } from './exclude-paths';\nexport { globMatches } from './glob-matches';\n// Framework-applied path exclusions for a rule run (#1253): the dispatcher enters the scope, DiffScope's\n// file listings honour it, so no rule filters its own files.\nexport { RuleFileScope, RuleFileExclusions } from './rule-file-scope';\n// The machine-generated trees a line-count rule never fires on. A FLOOR, not a default value:\n// `max-file-lines.excludePaths` adds to it, so configuring your own tree cannot lose it.\nexport { GENERATED_CODE_PATHS } from './generated-code-paths';\n// THE one `no-custom-css` path exemption. Both engines that enforce the rule (the edit-time hook and the\n// CI validator) consult this class, so `allowGlobs` cannot be honoured by one half and ignored by the other.\nexport { NoCustomCssScope, PathScopeConfig } from './no-custom-css-scope';\nexport {\n loadTemplate,\n writeTemplateIfMissing,\n writeTemplate,\n TemplateWriter,\n} from './load-template';\n// The instruct-ai docs are delivered as a SET: writing one writes the transitive closure of the docs it\n// links to, so a doc and everything it points at always land together. See instruct-ai-docs.ts.\nexport {\n GIT_WORKFLOW_DOC,\n GitWorkflowDoc,\n InstructAiDoc,\n InstructAiDocSet,\n MergeProcessDoc,\n} from './instruct-ai-docs';\nexport {\n MERGE_PROCESS_DOC,\n MergeProcessText,\n MergeRun,\n ReferenceMergeRun,\n} from './merge-process-doc';\nexport { BUILD_LOG_DOC } from './build-log-doc';\nexport {\n validateWebpiecesConfig,\n validatePrGateSection,\n validateChecklistsSection,\n validateExcludePaths,\n validateMatchRulesSection,\n allRuleNames,\n recommendedSeedMode,\n recommendedSeedModeFor,\n seedEntryForRule,\n} from './validate-config';\nexport { validateCommandsSection } from './commands-section-validators';\nexport {\n unknownKeyErrors,\n isCommentKey,\n validateTopLevelKeys,\n COMMENT_KEY_SUFFIX,\n} from './config-key-rules';\n// The retired-key table + the no-back-compat policy it enforces. Exported so the installer can migrate\n// what the errors instruct, and so consumers can enumerate retirements.\nexport {\n RETIRED_CONFIG_KEYS,\n RETIRED_SCOPE_KEY,\n RETIRED_SCOPE_RULE,\n isRetiredKey,\n retiredEntry,\n retiredKeyError,\n retiredKeyErrorsIn,\n retiredRuleFor,\n} from './retired-config-keys';\n// The MECHANICAL cure the unknown-rule error and the banner both name: strip every key no validator has a\n// schema for, so cleanliness is one command rather than a judgement call made while every Bash call is\n// blocked. `PRUNE_UNKNOWN_COMMAND` (constants.ts) is the single spelling of that command.\nexport { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';\nexport { validateChecklistDocs } from './checklist-docs-validator';\n// The OPTIONAL machine-local `~/.webpieces/config.json`: absent (the normal state for every consumer) means\n// each key's declared default, silently; present means STRICT about what it understands and FORWARD-COMPATIBLE\n// about what it does not. A retired key (its own retirement table), a known key of the wrong TYPE and an\n// unparseable document all REJECT; a key this release simply does not recognise is IGNORED with a warning,\n// because the file is machine-global and the repos reading it pin different releases — rejecting a newer\n// release's key would hard-block every repo on the machine that is not yet on it. See home-config.ts.\n// `isHomeConfigPath` is what grants the file its unconditional Write/Edit PASS in the hook guards, which is\n// what keeps a rejection repairable. Every `experimental.*` key is an OPT-IN that defaults OFF, including\n// `whole-repo-build-guard`: ON requires an explicit `true`, and there is no per-key default to export.\nexport {\n HomeConfig,\n HomeConfigService,\n RetiredHomeConfigKey,\n RETIRED_HOME_CONFIG_KEYS,\n HOME_CONFIG_DIR,\n HOME_CONFIG_FILE,\n HOME_EXPERIMENTAL_SECTION,\n HOME_KEY_ORPHAN_DIR_SWEEP,\n HOME_KEY_WHOLE_REPO_BUILD_GUARD,\n HOME_KEY_MAX_CONCURRENT_BUILDS,\n HOME_KEY_TURN_OFF_ALL_REVIEWERS,\n DEFAULT_MAX_CONCURRENT_BUILDS,\n HOME_KEY_DOC,\n HOME_KEY_AI_DOC,\n DOCUMENTATION_KEYS,\n} from './home-config';\n// The MACHINE-WIDE build ledger, `~/.webpieces/builds.log`. THE one carve-out from\n// `no-machine-global-state.spec.ts`'s rule that webpieces writes only under `{repo}/.webpieces` — the\n// argument is in `decisions/0006-the-build-ledger-is-machine-global.md`, and the short form is that \"how\n// many builds are burning this box's CPU\" is a fact about the MACHINE, is not a cache of anything a\n// remote owns, and cannot be answered from a per-repo file because every linked worktree has its own\n// `.webpieces/` and would be blind to the sibling it is contending with. See builds-log.ts.\nexport {\n BuildsLog,\n BuildTicket,\n BuildTermination,\n RunningBuild,\n BUILDS_LOG_FILE,\n BUILDS_LOCK_FILE,\n BUILD_START,\n BUILD_DONE_SUCCESS,\n BUILD_DONE_FAIL,\n MAX_BUILDS_LOG_BYTES,\n BUILDS_LOG_GENERATIONS,\n MAX_ROW_BYTES,\n} from './builds-log';\n// The orphan-directory sweep: the corpse an `nx g move` leaves on every clone, which git cannot remove\n// because an ignored dist/ or node_modules/ outlives every tracked file under it. See orphan-dir-scan.ts\n// for why the predicate is git's own `clean -Xdn` answer rather than a hand-rolled ignore walk.\nexport { OrphanDirScanner, OrphanCandidate } from './orphan-dir-scan';\nexport {\n OrphanDirArchiver,\n ArchivedOrphan,\n FailedOrphan,\n OrphanSweepResult,\n OrphanSweepManifest,\n TRASH_STATE_DIR,\n TRASH_MANIFEST_FILE,\n TRASH_RETENTION_DAYS,\n} from './orphan-dir-archive';\nexport { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { schemaFieldNames } from './rule-schemas';\nexport { isHookGuard, sectionForRule } from './sections';\nexport { shouldSkipRule, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';\nexport { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n DiffScope,\n DiffRange,\n ChangedFilesOptions,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n hasDisable,\n MERGE_INFO_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n PUSH_DEV_STATE_FILE,\n PRUNE_UNKNOWN_COMMAND,\n UPGRADE_SHIM_COMMAND,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n SyncFlowGuidance,\n WP_START_UPDATE,\n WP_FINISH_UPDATE,\n WP_START_UPSERT_PR,\n WP_FINISH_UPSERT_PR,\n WP_PUSH_DEV,\n WP_FINISH_PUSH_DEV,\n} from './sync-flow-guidance';\n\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\n\n// The `no-state-paths-in-templates` config, in its own module for the same reason no-client-creation is:\n// rule-configs.ts is at its file-size cap and a rule that carries real defaults belongs beside them.\n\nexport {\n GateDefinition,\n PrGateConfig,\n DEFAULT_BUILD_COMMAND,\n LandPrConfig,\n DevDeployConfig,\n DEFAULT_DEV_BRANCH_NAMESPACE,\n DEFAULT_DEV_BRANCH,\n ReviewContextEntry,\n defaultGates,\n defaultPrGateConfig,\n defaultLandPrConfig,\n defaultDevDeployConfig,\n buildPrGateConfig,\n buildLandPrConfig,\n buildDevDeployConfig,\n MERGE_MODE_AUTO,\n MERGE_MODE_NONE,\n MERGE_MODES,\n} from './pr-gate-config';\nexport {\n ChecklistDefinition,\n ReviewerAgentPolicy,\n REVIEWER_AGENTS_PLACEHOLDER,\n DEFAULT_REVIEWER_AGENT_NAME,\n toChecklist,\n normalizeChecklistDoc,\n formatFileList,\n} from './checklist-config';\nexport type { RawChecklistItem } from './checklist-config';\nexport { ChecklistValidator } from './checklist-validator';\nexport { ChecklistInstructionsService } from './checklist-instructions';\nexport {\n ReviewerInstructionsService,\n ReviewerBriefing,\n BriefedFile,\n ContextEntry,\n READ_TRUNCATION_LINES,\n ALL_DIFF_ONE_READ_LINES,\n} from './reviewer-instructions';\nexport {\n GateTokenService,\n computeGateToken,\n gateTokenMarker,\n extractGateToken,\n verifyGateToken,\n} from './gate-token';\nexport {\n SubagentProvenanceService,\n ReviewerEvidence,\n ReviewerContext,\n ExpectedReviewer,\n TranscriptScan,\n ProvenanceResult,\n PROVENANCE_OK,\n PROVENANCE_MISSING,\n PROVENANCE_SKIPPED,\n} from './subagent-provenance';\n\nexport {\n ReviewProvenanceService,\n ReviewProvenance,\n ReviewerTranscript,\n ReviewerPaths,\n OfferedContext,\n ProvenanceWriteRequest,\n DEFAULT_RETENTION_DAYS,\n} from './review-provenance';\nexport {\n PrSummary,\n AddressedIssue,\n PrContext,\n ChecklistResult,\n ChecklistVerdict,\n ChecklistOverride,\n ChecklistOverrideService,\n checklistOverrideService,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n RequiredChecklist,\n ChecklistReviewContext,\n ReviewJsonService,\n prDirFor,\n summaryJsonPath,\n summaryJsonSchemaHint,\n} from './review-json';\n\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\nexport { StaleBinRemoval, StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';\nexport { RepoScratchDirs, SCRATCH_DIR_NAME } from './repo-scratch-dirs';\nexport {\n TmpScratchSweeper,\n TMP_SCRATCH_RETENTION_DAYS,\n TMP_SCRATCH_PREFIX,\n} from './tmp-scratch-sweep';\n\nexport * from './hook-fault-codes';\nexport * from './hook-config-diagnostics';\nexport {\n RulePackRegistry,\n NodeRulePackModuleLoader,\n RulePackDiscovery,\n RulePackModuleLoader,\n} from './rule-pack-registry';\n\nexport {\n prepareLegacyUpgrade,\n LegacyConfigDocument,\n LegacyUpgradeResult,\n} from './legacy-config-upgrade';\nexport {\n PackPolicyDeclaration,\n SelectedPolicyPack,\n PackPolicyFilesResult,\n PackPolicyFiles,\n} from './pack-policy-files';\nexport { RulePackSync } from './rule-pack-sync';\nexport { ConfigRepairAccess } from './config-repair-access';\nexport { ConfigRepairBootstrap } from './config-repair-probe';\nexport {\n ConfigRepairCure,\n ConfigRepairError,\n EditFileCure,\n RunCommandCure,\n RepositoryLayoutRepair,\n} from './config-repair-error';\nexport {\n RuleRuntimeModules,\n RuleRuntimeModuleLoader,\n NodeRuleRuntimeModuleLoader,\n RuntimeContributionGroup,\n} from './rule-runtime-modules';\n\nexport { FirstPathMatch, FirstPathMatchResult, PathMatchCandidate } from './first-path-match';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAE3C,qDAA+F;AAAtF,gHAAA,aAAa,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AACnE,uGAAuG;AACvG,sFAAsF;AACtF,2CAAwD;AAA/C,oGAAA,MAAM,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACjC,2DAAqF;AAA5E,qHAAA,eAAe,OAAA;AAAE,kIAAA,4BAA4B,OAAA;AACtD,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,uCAAiF;AAAxE,oGAAA,QAAQ,OAAA;AAAE,mGAAA,OAAO,OAAA;AAAE,qGAAA,SAAS,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,mGAAA,OAAO,OAAA;AAC5D,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAEhB,6CAA4E;AAAnE,8GAAA,eAAe,OAAA;AAAE,2GAAA,YAAY,OAAA;AAAE,2GAAA,YAAY,OAAA;AACpD,iGAAiG;AACjG,sCAAsC;AACtC,6DAK+B;AAJ3B,+HAAA,wBAAwB,OAAA;AACxB,wHAAA,iBAAiB,OAAA;AACjB,yHAAA,kBAAkB,OAAA;AAClB,+HAAA,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qHAAA,cAAc,OAAA;AACd,6HAAA,sBAAsB,OAAA;AAE1B,qDAAyD;AAAhD,uHAAA,oBAAoB,OAAA;AAC7B,+DAKgC;AAJ5B,0HAAA,kBAAkB,OAAA;AAClB,+HAAA,uBAAuB,OAAA;AACvB,mIAAA,2BAA2B,OAAA;AAC3B,gIAAA,wBAAwB,OAAA;AAG5B,uDAA8F;AAArF,kHAAA,cAAc,OAAA;AAAE,wHAAA,oBAAoB,OAAA;AAAE,sHAAA,kBAAkB,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\n\nexport { RuleFailError, renderRuleFailForAi, renderRuleFailForHuman } from './rule-fail-error';\n// THE one representation of a cure, shared by RuleFailError (build-time) and FixHint (edit-time), plus\n// the one renderer that owns the \"Fix Option N:\" numbering and the \"(preferred)\" tag.\nexport { Option, formatFixOptions } from './fix-option';\nexport { TurnOffRuleCure, LAST_RESORT_TURN_OFF_SECONDS } from './turn-off-rule-cure';\nexport { CliExitError } from './cli-exit-error';\nexport { CliUsage, CliFlag, CliArgSet, CliArgsCheck, CliArgs } from './cli-args';\nexport { runMain } from './run-main';\n\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\n// The validation-failure banner: ONE cure (edit the file), plus the marker phrases the validator\n// messages embed rather than re-type.\nexport {\n formatConfigErrorsBanner,\n CONFIG_POLICY_DOC,\n RETIRED_KEY_MARKER,\n RETIRED_TOP_LEVEL_MARKER,\n} from './config-error-banner';\nexport {\n findConfigFile,\n CONFIG_FILENAME,\n ConfigFile,\n ConfigParseAttempt,\n CONFIG_PARSE_ATTEMPTS,\n CONFIG_PARSE_RETRY_MILLIS,\n} from './config-file';\n// The PARSED-BUT-UNVALIDATED config shape. Exported for readers that walk the file generically rather\n// than through the typed config (the pr-gate active-hatch dashboard section reads every rule's hatches).\nexport { RawConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR, INSTRUCT_AI_LEAF } from './repo-root';\n// The scoped `.webpieces` resolver. EVERY reader/writer of `.webpieces/...` goes through one of its two\n// named methods so the call site declares whether the state is repo-wide or worktree-private.\n\n// There is NO machine-global state root. `MachineStateHome`/`StateHome`/`WEBPIECES_STATE_HOME` and the\n// `PrBodyStore` that used them are DELETED: the one artifact that needed a scope above the clone was the\n// gated squash body, and GitHub holds it now (it IS the PR description). Every `.webpieces` path a\n// webpieces tool writes is `{repo}/.webpieces`, resolved through `DotWebpieces` above. See\n// `decisions/0005-the-pr-description-is-the-merge-body.md`.\nexport { AgedTreeSweeper, SweepCount, RETENTION_DAYS } from './aged-tree-sweep';\nexport {\n ClaudeEnv,\n claudeEnv,\n CLAUDE_PROJECT_DIR_ENV,\n CLAUDE_PROJECT_DIR_UNSET,\n} from './claude-env';\n\n// The ONE formatter for a remedy that must run in a named directory: `cd '<root>' && <command>`.\n// Single-quoted so a repo path containing a space is still runnable (and still un-smuggleable).\nexport { atRoot } from './at-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './di';\nexport { ExcludePaths, isWebpiecesStateDir } from './exclude-hook-paths';\nexport { isPathExcluded, matchesAnyGlob } from './exclude-paths';\nexport { globMatches } from './glob-matches';\n// Framework-applied path exclusions for a rule run (#1253): the dispatcher enters the scope, DiffScope's\n// file listings honour it, so no rule filters its own files.\nexport { RuleFileScope, RuleFileExclusions } from './rule-file-scope';\n// The machine-generated trees a line-count rule never fires on. A FLOOR, not a default value:\n// `max-file-lines.excludePaths` adds to it, so configuring your own tree cannot lose it.\nexport { GENERATED_CODE_PATHS } from './generated-code-paths';\n// THE one `no-custom-css` path exemption. Both engines that enforce the rule (the edit-time hook and the\n// CI validator) consult this class, so `allowGlobs` cannot be honoured by one half and ignored by the other.\nexport { NoCustomCssScope, PathScopeConfig } from './no-custom-css-scope';\nexport {\n loadTemplate,\n writeTemplateIfMissing,\n writeTemplate,\n TemplateWriter,\n} from './load-template';\n// The instruct-ai docs are delivered as a SET: writing one writes the transitive closure of the docs it\n// links to, so a doc and everything it points at always land together. See instruct-ai-docs.ts.\nexport {\n GIT_WORKFLOW_DOC,\n GitWorkflowDoc,\n InstructAiDoc,\n InstructAiDocSet,\n MergeProcessDoc,\n} from './instruct-ai-docs';\nexport {\n MERGE_PROCESS_DOC,\n MergeProcessText,\n MergeRun,\n ReferenceMergeRun,\n} from './merge-process-doc';\nexport { BUILD_LOG_DOC } from './build-log-doc';\nexport {\n validateWebpiecesConfig,\n validatePrGateSection,\n validateChecklistsSection,\n validateExcludePaths,\n validateMatchRulesSection,\n allRuleNames,\n recommendedSeedMode,\n recommendedSeedModeFor,\n seedEntryForRule,\n} from './validate-config';\nexport { validateCommandsSection } from './commands-section-validators';\nexport {\n unknownKeyErrors,\n isCommentKey,\n validateTopLevelKeys,\n COMMENT_KEY_SUFFIX,\n} from './config-key-rules';\n// The retired-key table + the no-back-compat policy it enforces. Exported so the installer can migrate\n// what the errors instruct, and so consumers can enumerate retirements.\nexport {\n RETIRED_CONFIG_KEYS,\n RETIRED_SCOPE_KEY,\n RETIRED_SCOPE_RULE,\n isRetiredKey,\n retiredEntry,\n retiredKeyError,\n retiredKeyErrorsIn,\n retiredRuleFor,\n} from './retired-config-keys';\n// The MECHANICAL cure the unknown-rule error and the banner both name: strip every key no validator has a\n// schema for, so cleanliness is one command rather than a judgement call made while every Bash call is\n// blocked. `PRUNE_UNKNOWN_COMMAND` (constants.ts) is the single spelling of that command.\nexport { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';\nexport { validateChecklistDocs } from './checklist-docs-validator';\n// The OPTIONAL machine-local `~/.webpieces/config.json`: absent (the normal state for every consumer) means\n// each key's declared default, silently; present means STRICT about what it understands and FORWARD-COMPATIBLE\n// about what it does not. A retired key (its own retirement table), a known key of the wrong TYPE and an\n// unparseable document all REJECT; a key this release simply does not recognise is IGNORED with a warning,\n// because the file is machine-global and the repos reading it pin different releases — rejecting a newer\n// release's key would hard-block every repo on the machine that is not yet on it. See home-config.ts.\n// `isHomeConfigPath` is what grants the file its unconditional Write/Edit PASS in the hook guards, which is\n// what keeps a rejection repairable. Every `experimental.*` key is an OPT-IN that defaults OFF, including\n// `whole-repo-build-guard`: ON requires an explicit `true`, and there is no per-key default to export.\nexport {\n HomeConfig,\n HomeConfigService,\n RetiredHomeConfigKey,\n RETIRED_HOME_CONFIG_KEYS,\n HOME_CONFIG_DIR,\n HOME_CONFIG_FILE,\n HOME_EXPERIMENTAL_SECTION,\n HOME_KEY_ORPHAN_DIR_SWEEP,\n HOME_KEY_WHOLE_REPO_BUILD_GUARD,\n HOME_KEY_MAX_CONCURRENT_BUILDS,\n HOME_KEY_TURN_OFF_ALL_REVIEWERS,\n DEFAULT_MAX_CONCURRENT_BUILDS,\n HOME_KEY_DOC,\n HOME_KEY_AI_DOC,\n DOCUMENTATION_KEYS,\n} from './home-config';\n// The MACHINE-WIDE build ledger, `~/.webpieces/builds.log`. THE one carve-out from\n// `no-machine-global-state.spec.ts`'s rule that webpieces writes only under `{repo}/.webpieces` — the\n// argument is in `decisions/0006-the-build-ledger-is-machine-global.md`, and the short form is that \"how\n// many builds are burning this box's CPU\" is a fact about the MACHINE, is not a cache of anything a\n// remote owns, and cannot be answered from a per-repo file because every linked worktree has its own\n// `.webpieces/` and would be blind to the sibling it is contending with. See builds-log.ts.\nexport {\n BuildsLog,\n BuildTicket,\n BuildTermination,\n RunningBuild,\n BUILDS_LOG_FILE,\n BUILDS_LOCK_FILE,\n BUILD_START,\n BUILD_DONE_SUCCESS,\n BUILD_DONE_FAIL,\n MAX_BUILDS_LOG_BYTES,\n BUILDS_LOG_GENERATIONS,\n MAX_ROW_BYTES,\n} from './builds-log';\n// The orphan-directory sweep: the corpse an `nx g move` leaves on every clone, which git cannot remove\n// because an ignored dist/ or node_modules/ outlives every tracked file under it. See orphan-dir-scan.ts\n// for why the predicate is git's own `clean -Xdn` answer rather than a hand-rolled ignore walk.\nexport { OrphanDirScanner, OrphanCandidate } from './orphan-dir-scan';\nexport {\n OrphanDirArchiver,\n ArchivedOrphan,\n FailedOrphan,\n OrphanSweepResult,\n OrphanSweepManifest,\n TRASH_STATE_DIR,\n TRASH_MANIFEST_FILE,\n TRASH_RETENTION_DAYS,\n} from './orphan-dir-archive';\nexport { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { schemaFieldNames } from './rule-schemas';\nexport { isHookGuard, sectionForRule } from './sections';\nexport { shouldSkipRule, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';\nexport { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n DiffScope,\n DiffRange,\n ChangedFilesOptions,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n hasDisable,\n MERGE_INFO_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n PUSH_DEV_STATE_FILE,\n PRUNE_UNKNOWN_COMMAND,\n UPGRADE_SHIM_COMMAND,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n SyncFlowGuidance,\n WP_START_UPDATE,\n WP_FINISH_UPDATE,\n WP_START_UPSERT_PR,\n WP_FINISH_UPSERT_PR,\n WP_PUSH_DEV,\n WP_FINISH_PUSH_DEV,\n} from './sync-flow-guidance';\n\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\n\n// The `no-state-paths-in-templates` config, in its own module for the same reason no-client-creation is:\n// rule-configs.ts is at its file-size cap and a rule that carries real defaults belongs beside them.\n\nexport {\n GateDefinition,\n PrGateConfig,\n DEFAULT_BUILD_COMMAND,\n LandPrConfig,\n DevDeployConfig,\n DEFAULT_DEV_BRANCH_NAMESPACE,\n DEFAULT_DEV_BRANCH,\n ReviewContextEntry,\n defaultGates,\n defaultPrGateConfig,\n defaultLandPrConfig,\n defaultDevDeployConfig,\n buildPrGateConfig,\n buildLandPrConfig,\n buildDevDeployConfig,\n MERGE_MODE_AUTO,\n MERGE_MODE_NONE,\n MERGE_MODES,\n} from './pr-gate-config';\nexport {\n ChecklistDefinition,\n ReviewerAgentPolicy,\n REVIEWER_AGENTS_PLACEHOLDER,\n DEFAULT_REVIEWER_AGENT_NAME,\n toChecklist,\n normalizeChecklistDoc,\n formatFileList,\n} from './checklist-config';\nexport type { RawChecklistItem } from './checklist-config';\nexport { ChecklistValidator } from './checklist-validator';\nexport { ChecklistInstructionsService } from './checklist-instructions';\nexport {\n ReviewerInstructionsService,\n ReviewerBriefing,\n BriefedFile,\n ContextEntry,\n READ_TRUNCATION_LINES,\n ALL_DIFF_ONE_READ_LINES,\n} from './reviewer-instructions';\nexport {\n GateTokenService,\n computeGateToken,\n gateTokenMarker,\n extractGateToken,\n verifyGateToken,\n} from './gate-token';\nexport {\n SubagentProvenanceService,\n ReviewerEvidence,\n ReviewerContext,\n ExpectedReviewer,\n TranscriptScan,\n ProvenanceResult,\n PROVENANCE_OK,\n PROVENANCE_MISSING,\n PROVENANCE_SKIPPED,\n} from './subagent-provenance';\n\nexport {\n ReviewProvenanceService,\n ReviewProvenance,\n ReviewerTranscript,\n ReviewerPaths,\n OfferedContext,\n ProvenanceWriteRequest,\n DEFAULT_RETENTION_DAYS,\n} from './review-provenance';\nexport {\n PrSummary,\n AddressedIssue,\n PrContext,\n ChecklistResult,\n ChecklistVerdict,\n ChecklistOverride,\n ChecklistOverrideService,\n checklistOverrideService,\n CK_PASS,\n CK_WARN,\n CK_OVERRIDDEN,\n CK_ORANGE_FIXED,\n CK_ORANGE,\n CK_FAIL,\n CK_MISSING,\n CK_BAD_FORMAT,\n VERDICT_GREEN,\n VERDICT_YELLOW,\n VERDICT_ORANGE,\n VERDICT_RED,\n VERDICT_STATUSES,\n RequiredChecklist,\n ChecklistReviewContext,\n ReviewJsonService,\n prDirFor,\n summaryJsonPath,\n summaryJsonSchemaHint,\n} from './review-json';\n\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\nexport { StaleBinRemoval, StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';\nexport { RepoScratchDirs, SCRATCH_DIR_NAME } from './repo-scratch-dirs';\nexport {\n TmpScratchSweeper,\n TMP_SCRATCH_RETENTION_DAYS,\n TMP_SCRATCH_PREFIX,\n} from './tmp-scratch-sweep';\n\nexport * from './hook-fault-codes';\nexport * from './hook-config-diagnostics';\nexport {\n RulePackRegistry,\n NodeRulePackModuleLoader,\n RulePackDiscovery,\n RulePackModuleLoader,\n} from './rule-pack-registry';\n\nexport {\n prepareLegacyUpgrade,\n LegacyConfigDocument,\n LegacyUpgradeResult,\n} from './legacy-config-upgrade';\nexport {\n PackPolicyDeclaration,\n SelectedPolicyPack,\n PackPolicyFilesResult,\n PackPolicyFiles,\n} from './pack-policy-files';\nexport { RulePackSync } from './rule-pack-sync';\nexport { ConfigRepairAccess } from './config-repair-access';\nexport { ConfigRepairBootstrap } from './config-repair-probe';\nexport {\n ConfigRepairCure,\n ConfigRepairError,\n EditFileCure,\n RunCommandCure,\n RepositoryLayoutRepair,\n} from './config-repair-error';\nexport { UntrackedPolicyError } from './policy-tracking';\nexport {\n RuleRuntimeModules,\n RuleRuntimeModuleLoader,\n NodeRuleRuntimeModuleLoader,\n RuntimeContributionGroup,\n} from './rule-runtime-modules';\n\nexport { FirstPathMatch, FirstPathMatchResult, PathMatchCandidate } from './first-path-match';\n"]}
|
package/src/policy-tracking.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import type { PackPolicyDeclaration } from './pack-policy-files';
|
|
2
|
+
import { ConfigRepairError } from './config-repair-error';
|
|
3
|
+
/**
|
|
4
|
+
* Declared policy files git's index does not hold (#1327). Its own type because the guard hook treats it
|
|
5
|
+
* specially: while THIS refusal is why the config will not load, a plain `git add` is let through
|
|
6
|
+
* (agent-workflow-rules `PolicyStagingCommand`) — staging is literally the cure, so refusing it was a loop.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UntrackedPolicyError extends ConfigRepairError {
|
|
9
|
+
readonly untracked: readonly string[];
|
|
10
|
+
constructor(untracked: readonly string[]);
|
|
11
|
+
}
|
|
2
12
|
/** Git repositories must share policy through their index, including rules switched OFF. */
|
|
3
13
|
export declare class PolicyTracking {
|
|
4
14
|
check(root: string, declarations: readonly PackPolicyDeclaration[]): void;
|
|
5
15
|
stage(root: string, declarations: readonly PackPolicyDeclaration[]): void;
|
|
16
|
+
/** Which of `files` git's index does not hold — each one named, never git's own pathspec advice. */
|
|
17
|
+
private untracked;
|
|
6
18
|
private files;
|
|
7
19
|
}
|
package/src/policy-tracking.js
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PolicyTracking = void 0;
|
|
3
|
+
exports.PolicyTracking = exports.UntrackedPolicyError = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("node:path"));
|
|
7
7
|
const node_child_process_1 = require("node:child_process");
|
|
8
8
|
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
9
9
|
const config_repair_error_1 = require("./config-repair-error");
|
|
10
|
+
/** POSIX single-quoting for a path printed inside a command the reader will paste. */
|
|
11
|
+
class ShellQuote {
|
|
12
|
+
quote(value) {
|
|
13
|
+
return /^[A-Za-z0-9_./@:+-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Declared policy files git's index does not hold (#1327). Its own type because the guard hook treats it
|
|
18
|
+
* specially: while THIS refusal is why the config will not load, a plain `git add` is let through
|
|
19
|
+
* (agent-workflow-rules `PolicyStagingCommand`) — staging is literally the cure, so refusing it was a loop.
|
|
20
|
+
*/
|
|
21
|
+
class UntrackedPolicyError extends config_repair_error_1.ConfigRepairError {
|
|
22
|
+
untracked;
|
|
23
|
+
constructor(untracked) {
|
|
24
|
+
const quoted = untracked.map((file) => new ShellQuote().quote(file)).join(' ');
|
|
25
|
+
super([
|
|
26
|
+
'Webpieces policy files are not tracked by git. Policy is shared through the git index, so every',
|
|
27
|
+
'declared owner file must be staged and committed with your change. Untracked:',
|
|
28
|
+
...untracked.map((file) => ` ${file}`),
|
|
29
|
+
'A plain `git add` is permitted while this refusal is active.',
|
|
30
|
+
].join('\n'), [
|
|
31
|
+
new config_repair_error_1.RunCommandCure(`git add -- ${quoted}`, `git add -- ${quoted} — stages exactly the untracked files listed above.`),
|
|
32
|
+
new config_repair_error_1.RunCommandCure(`${tooling_common_1.MIGRATE_DIRS_COMMAND} --stage`, `${tooling_common_1.MIGRATE_DIRS_COMMAND} --stage — stages webpieces.config.json, .gitignore and every declared owner file.`),
|
|
33
|
+
]);
|
|
34
|
+
this.name = 'UntrackedPolicyError';
|
|
35
|
+
this.untracked = untracked;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.UntrackedPolicyError = UntrackedPolicyError;
|
|
10
39
|
/** Git repositories must share policy through their index, including rules switched OFF. */
|
|
11
40
|
class PolicyTracking {
|
|
12
41
|
check(root, declarations) {
|
|
@@ -24,14 +53,9 @@ class PolicyTracking {
|
|
|
24
53
|
throw new config_repair_error_1.ConfigRepairError(`Committed Webpieces policy is gitignored:\n${ignored.stdout}Only .webpieces/ belongs in .gitignore; .webpieces-config/ must be tracked.`, [
|
|
25
54
|
new config_repair_error_1.EditFileCure(path.join(root, '.gitignore'), `Delete the .gitignore patterns that match the files listed above.`),
|
|
26
55
|
]);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
if (tracked.status !== 0)
|
|
32
|
-
throw new config_repair_error_1.ConfigRepairError(`Webpieces policy must be tracked by git: ${tracked.stderr}\nReview the policy files, stage them, and commit them with your change.`, [
|
|
33
|
-
new config_repair_error_1.RunCommandCure(`${tooling_common_1.MIGRATE_DIRS_COMMAND} --stage`, `${tooling_common_1.MIGRATE_DIRS_COMMAND} --stage — stages the declaration and the owner files.`),
|
|
34
|
-
]);
|
|
56
|
+
const untracked = this.untracked(root, files);
|
|
57
|
+
if (untracked.length)
|
|
58
|
+
throw new UntrackedPolicyError(untracked);
|
|
35
59
|
}
|
|
36
60
|
stage(root, declarations) {
|
|
37
61
|
// `.webpieces/` is the gitignored state directory, so `git add` refuses its paths. Untrack whatever
|
|
@@ -51,6 +75,20 @@ class PolicyTracking {
|
|
|
51
75
|
if (result.status !== 0)
|
|
52
76
|
throw new tooling_common_1.InformAiError(`Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`);
|
|
53
77
|
}
|
|
78
|
+
/** Which of `files` git's index does not hold — each one named, never git's own pathspec advice. */
|
|
79
|
+
untracked(root, files) {
|
|
80
|
+
const listed = (0, node_child_process_1.spawnSync)('git', ['--literal-pathspecs', 'ls-files', '-z', '--', ...files], {
|
|
81
|
+
cwd: root,
|
|
82
|
+
encoding: 'utf8',
|
|
83
|
+
});
|
|
84
|
+
if (listed.status !== 0)
|
|
85
|
+
throw new tooling_common_1.InformAiError(`Cannot verify policy tracking status: ${listed.stderr}. Repair git access, then retry.`);
|
|
86
|
+
const tracked = new Set(listed.stdout
|
|
87
|
+
.split('\0')
|
|
88
|
+
.filter((entry) => entry !== '')
|
|
89
|
+
.map((entry) => path.normalize(entry)));
|
|
90
|
+
return files.filter((file) => !tracked.has(path.normalize(file)));
|
|
91
|
+
}
|
|
54
92
|
files(root, declarations) {
|
|
55
93
|
const declared = declarations.map((declaration) => declaration.config);
|
|
56
94
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-tracking.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/policy-tracking.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,2DAA+C;AAC/C,8DAAgF;AAEhF,+DAAwF;AAExF,4FAA4F;AAC5F,MAAa,cAAc;IACvB,KAAK,CAAC,IAAY,EAAE,YAA8C;QAC9D,0FAA0F;QAC1F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,IAAA,8BAAS,EAAC,KAAK,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE;YAC7E,GAAG,EAAE,IAAI;YACT,QAAQ,EAAE,MAAM;SACnB,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAC5C,MAAM,IAAI,8BAAa,CACnB,uCAAuC,OAAO,CAAC,MAAM,kCAAkC,CAC1F,CAAC;QACN,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;YACrB,MAAM,IAAI,uCAAiB,CACvB,8CAA8C,OAAO,CAAC,MAAM,6EAA6E,EACzI;gBACI,IAAI,kCAAY,CACZ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAC7B,mEAAmE,CACtE;aACJ,CACJ,CAAC;QACN,MAAM,OAAO,GAAG,IAAA,8BAAS,EACrB,KAAK,EACL,CAAC,qBAAqB,EAAE,UAAU,EAAE,iBAAiB,EAAE,IAAI,EAAE,G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WAAW,CAAC,MAAM,CAAC,CAAC;QACvE,OAAO;YACH,GAAG,IAAI,GAAG,CACN,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC3B,QAAQ;gBACR,IAAI,CAAC,QAAQ,CACT,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACrB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAC7C;aACJ,CAAC,CACL;SACJ,CAAC;IACN,CAAC;CACJ;AAxFD,wCAwFC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { InformAiError, MIGRATE_DIRS_COMMAND } from '@webpieces/tooling-common';\nimport type { PackPolicyDeclaration } from './pack-policy-files';\nimport { ConfigRepairError, EditFileCure, RunCommandCure } from './config-repair-error';\n\n/** Git repositories must share policy through their index, including rules switched OFF. */\nexport class PolicyTracking {\n check(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // Standalone non-git schema validation is supported; CI and governed checkouts have .git.\n if (!fs.existsSync(path.join(root, '.git'))) return;\n const files = this.files(root, declarations);\n const ignored = spawnSync('git', ['check-ignore', '--no-index', '--', ...files], {\n cwd: root,\n encoding: 'utf8',\n });\n if (ignored.status !== 0 && ignored.status !== 1)\n throw new InformAiError(\n `Cannot verify policy ignore status: ${ignored.stderr}. Repair git access, then retry.`,\n );\n if (ignored.stdout.trim())\n throw new ConfigRepairError(\n `Committed Webpieces policy is gitignored:\\n${ignored.stdout}Only .webpieces/ belongs in .gitignore; .webpieces-config/ must be tracked.`,\n [\n new EditFileCure(\n path.join(root, '.gitignore'),\n `Delete the .gitignore patterns that match the files listed above.`,\n ),\n ],\n );\n const tracked = spawnSync(\n 'git',\n ['--literal-pathspecs', 'ls-files', '--error-unmatch', '--', ...files],\n {\n cwd: root,\n encoding: 'utf8',\n },\n );\n if (tracked.status !== 0)\n throw new ConfigRepairError(\n `Webpieces policy must be tracked by git: ${tracked.stderr}\\nReview the policy files, stage them, and commit them with your change.`,\n [\n new RunCommandCure(\n `${MIGRATE_DIRS_COMMAND} --stage`,\n `${MIGRATE_DIRS_COMMAND} --stage — stages the declaration and the owner files.`,\n ),\n ],\n );\n }\n\n stage(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // `.webpieces/` is the gitignored state directory, so `git add` refuses its paths. Untrack whatever\n // policy older releases committed there with `rm --cached`, which keeps every file on disk.\n const retired = spawnSync(\n 'git',\n ['rm', '-r', '-q', '--cached', '--ignore-unmatch', '--', '.webpieces'],\n { cwd: root, encoding: 'utf8' },\n );\n if (retired.status !== 0)\n throw new InformAiError(\n `Cannot untrack retired policy paths in .webpieces/: ${retired.stderr}. Verify git access before retrying.`,\n );\n const result = spawnSync(\n 'git',\n [\n '--literal-pathspecs',\n 'add',\n '-A',\n '--',\n 'webpieces.config.json',\n '.gitignore',\n ...this.files(root, declarations),\n ],\n { cwd: root, encoding: 'utf8' },\n );\n if (result.status !== 0)\n throw new InformAiError(\n `Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`,\n );\n }\n\n private files(root: string, declarations: readonly PackPolicyDeclaration[]): string[] {\n const declared = declarations.map((declaration) => declaration.config);\n return [\n ...new Set(\n declared.flatMap((filename) => [\n filename,\n path.relative(\n fs.realpathSync(root),\n fs.realpathSync(path.join(root, filename)),\n ),\n ]),\n ),\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"policy-tracking.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/policy-tracking.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,2DAA+C;AAC/C,8DAAgF;AAEhF,+DAAwF;AAExF,sFAAsF;AACtF,MAAM,UAAU;IACZ,KAAK,CAAC,KAAa;QACf,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,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AAE,CAAC;gBAC3B,QAAQ;gBACR,IAAI,CAAC,QAAQ,CACT,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACrB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAC7C;aACJ,CAAC,CACL;SACJ,CAAC;IACN,CAAC;CACJ;AA3FD,wCA2FC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { InformAiError, MIGRATE_DIRS_COMMAND } from '@webpieces/tooling-common';\nimport type { PackPolicyDeclaration } from './pack-policy-files';\nimport { ConfigRepairError, EditFileCure, RunCommandCure } from './config-repair-error';\n\n/** POSIX single-quoting for a path printed inside a command the reader will paste. */\nclass ShellQuote {\n quote(value: string): string {\n return /^[A-Za-z0-9_./@:+-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\\\''`)}'`;\n }\n}\n\n/**\n * Declared policy files git's index does not hold (#1327). Its own type because the guard hook treats it\n * specially: while THIS refusal is why the config will not load, a plain `git add` is let through\n * (agent-workflow-rules `PolicyStagingCommand`) — staging is literally the cure, so refusing it was a loop.\n */\nexport class UntrackedPolicyError extends ConfigRepairError {\n readonly untracked: readonly string[];\n\n constructor(untracked: readonly string[]) {\n const quoted = untracked.map((file: string) => new ShellQuote().quote(file)).join(' ');\n super(\n [\n 'Webpieces policy files are not tracked by git. Policy is shared through the git index, so every',\n 'declared owner file must be staged and committed with your change. Untracked:',\n ...untracked.map((file: string) => ` ${file}`),\n 'A plain `git add` is permitted while this refusal is active.',\n ].join('\\n'),\n [\n new RunCommandCure(\n `git add -- ${quoted}`,\n `git add -- ${quoted} — stages exactly the untracked files listed above.`,\n ),\n new RunCommandCure(\n `${MIGRATE_DIRS_COMMAND} --stage`,\n `${MIGRATE_DIRS_COMMAND} --stage — stages webpieces.config.json, .gitignore and every declared owner file.`,\n ),\n ],\n );\n this.name = 'UntrackedPolicyError';\n this.untracked = untracked;\n }\n}\n\n/** Git repositories must share policy through their index, including rules switched OFF. */\nexport class PolicyTracking {\n check(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // Standalone non-git schema validation is supported; CI and governed checkouts have .git.\n if (!fs.existsSync(path.join(root, '.git'))) return;\n const files = this.files(root, declarations);\n const ignored = spawnSync('git', ['check-ignore', '--no-index', '--', ...files], {\n cwd: root,\n encoding: 'utf8',\n });\n if (ignored.status !== 0 && ignored.status !== 1)\n throw new InformAiError(\n `Cannot verify policy ignore status: ${ignored.stderr}. Repair git access, then retry.`,\n );\n if (ignored.stdout.trim())\n throw new ConfigRepairError(\n `Committed Webpieces policy is gitignored:\\n${ignored.stdout}Only .webpieces/ belongs in .gitignore; .webpieces-config/ must be tracked.`,\n [\n new EditFileCure(\n path.join(root, '.gitignore'),\n `Delete the .gitignore patterns that match the files listed above.`,\n ),\n ],\n );\n const untracked = this.untracked(root, files);\n if (untracked.length) throw new UntrackedPolicyError(untracked);\n }\n\n stage(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // `.webpieces/` is the gitignored state directory, so `git add` refuses its paths. Untrack whatever\n // policy older releases committed there with `rm --cached`, which keeps every file on disk.\n const retired = spawnSync(\n 'git',\n ['rm', '-r', '-q', '--cached', '--ignore-unmatch', '--', '.webpieces'],\n { cwd: root, encoding: 'utf8' },\n );\n if (retired.status !== 0)\n throw new InformAiError(\n `Cannot untrack retired policy paths in .webpieces/: ${retired.stderr}. Verify git access before retrying.`,\n );\n const result = spawnSync(\n 'git',\n [\n '--literal-pathspecs',\n 'add',\n '-A',\n '--',\n 'webpieces.config.json',\n '.gitignore',\n ...this.files(root, declarations),\n ],\n { cwd: root, encoding: 'utf8' },\n );\n if (result.status !== 0)\n throw new InformAiError(\n `Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`,\n );\n }\n\n /** Which of `files` git's index does not hold — each one named, never git's own pathspec advice. */\n private untracked(root: string, files: readonly string[]): string[] {\n const listed = spawnSync('git', ['--literal-pathspecs', 'ls-files', '-z', '--', ...files], {\n cwd: root,\n encoding: 'utf8',\n });\n if (listed.status !== 0)\n throw new InformAiError(\n `Cannot verify policy tracking status: ${listed.stderr}. Repair git access, then retry.`,\n );\n const tracked = new Set(\n listed.stdout\n .split('\\0')\n .filter((entry: string) => entry !== '')\n .map((entry: string) => path.normalize(entry)),\n );\n return files.filter((file: string) => !tracked.has(path.normalize(file)));\n }\n\n private files(root: string, declarations: readonly PackPolicyDeclaration[]): string[] {\n const declared = declarations.map((declaration) => declaration.config);\n return [\n ...new Set(\n declared.flatMap((filename) => [\n filename,\n path.relative(\n fs.realpathSync(root),\n fs.realpathSync(path.join(root, filename)),\n ),\n ]),\n ),\n ];\n }\n}\n"]}
|
package/src/rule-pack-sync.js
CHANGED
|
@@ -16,9 +16,13 @@ const validate_config_1 = require("./validate-config");
|
|
|
16
16
|
class OwnerFilePlan {
|
|
17
17
|
filename;
|
|
18
18
|
entries;
|
|
19
|
-
|
|
19
|
+
unchanged;
|
|
20
|
+
constructor(filename, entries,
|
|
21
|
+
/** The sync added nothing: the file is left byte-for-byte as its author formatted it (#1327). */
|
|
22
|
+
unchanged) {
|
|
20
23
|
this.filename = filename;
|
|
21
24
|
this.entries = entries;
|
|
25
|
+
this.unchanged = unchanged;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
@@ -48,6 +52,8 @@ let RulePackSync = class RulePackSync {
|
|
|
48
52
|
const plans = this.prepare(root, selected, registry);
|
|
49
53
|
const changed = [...layoutChanges];
|
|
50
54
|
for (const plan of plans) {
|
|
55
|
+
if (plan.unchanged)
|
|
56
|
+
continue;
|
|
51
57
|
if (this.atomic.writeIfChanged(plan.filename, JSON.stringify(plan.entries, null, 2) + '\n'))
|
|
52
58
|
changed.push(plan.filename);
|
|
53
59
|
}
|
|
@@ -58,7 +64,9 @@ let RulePackSync = class RulePackSync {
|
|
|
58
64
|
const errors = [];
|
|
59
65
|
for (const pack of selected) {
|
|
60
66
|
const filename = this.files.configPath(root, pack.declaration.config);
|
|
61
|
-
const
|
|
67
|
+
const exists = fs.existsSync(filename);
|
|
68
|
+
const entries = exists ? this.files.read(filename) : {};
|
|
69
|
+
const before = JSON.stringify(entries);
|
|
62
70
|
for (const id of Object.keys(entries)) {
|
|
63
71
|
if (!registry.hasRule(id) || registry.ownerOf(id) !== pack.manifest.packageName) {
|
|
64
72
|
errors.push(`${filename}: ${id} has another owner or is unknown. Move or remove it explicitly before sync.`);
|
|
@@ -71,7 +79,8 @@ let RulePackSync = class RulePackSync {
|
|
|
71
79
|
.map((error) => `${filename}: ${error}`));
|
|
72
80
|
entries[definition.id] = value;
|
|
73
81
|
}
|
|
74
|
-
|
|
82
|
+
// Compared as CONTENT, not bytes: a re-serialization of the same entries would only reformat.
|
|
83
|
+
plans.push(new OwnerFilePlan(filename, entries, exists && JSON.stringify(entries) === before));
|
|
75
84
|
}
|
|
76
85
|
if (errors.length)
|
|
77
86
|
throw new tooling_common_1.InformAiError(`Sync made no changes:\n${errors.join('\n')}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-pack-sync.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-sync.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAmF;AACnF,8DAAwF;AACxF,+CAA4D;AAC5D,2DAA0E;AAC1E,6DAAwD;AACxD,yDAA0D;AAC1D,+EAAwE;AACxE,uDAAoF;AAEpF,MAAM,aAAa;IAEF;IACA;IAFb,YACa,QAAgB,EAChB,OAAqC;QADrC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAA8B;IAC/C,CAAC;CACP;AAED;;;;GAIG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEA;IACA;IACA;IAHrB,YACqB,UAAsB,EACtB,KAAsB,EACtB,MAAkB;QAFlB,eAAU,GAAV,UAAU,CAAY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qDAAuB,EAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;YAC3E,GAAG,IAAA,sCAAoB,EAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;YACjD,GAAG,IAAA,2CAAyB,EAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SACxD,CAAC;QACF,IAAI,MAAM,CAAC,MAAM;YAAE,MAAM,IAAI,8BAAa,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED,uHAAuH;IAC/G,MAAM,CAAC,KAAc,EAAE,KAAa;QACxC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAC3D,MAAM,IAAI,8BAAa,CAAC,GAAG,KAAK,gDAAgD,CAAC,CAAC;QACtF,6GAA6G;QAC7G,OAAO,KAAgC,CAAC;IAC5C,CAAC;CACJ,CAAA;AArGY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,wBAAU;QACf,mCAAe;QACd,2BAAU;GAJ9B,YAAY,CAqGxB","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject, FieldDef, OwnedRuleDefinition } from '@webpieces/rules-sdk';\nimport { AtomicFile, InformAiError, RepositoryLayout } from '@webpieces/tooling-common';\nimport { ConfigFile, CONFIG_FILENAME } from './config-file';\nimport { PackPolicyFiles, SelectedPolicyPack } from './pack-policy-files';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\n\nclass OwnerFilePlan {\n constructor(\n readonly filename: string,\n readonly entries: Record<string, ConfigObject>,\n ) {}\n}\n\n/**\n * Writes the owners' recommended seeds into the declared owner files, for review — the installer's and\n * `wp-migrate-dirs`' explicit file mutation. Normal configuration loading never calls this service: a\n * missing entry is a deny naming the file and the entry to paste, not something loading supplies.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RulePackSync {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n private readonly atomic: AtomicFile,\n ) {}\n\n run(root: string): readonly string[] {\n const layoutChanges = new RepositoryLayout().migrate(root);\n const filename = path.join(root, CONFIG_FILENAME);\n // webpieces-disable no-any-unknown -- the sync reads opaque JSON only at this explicit command boundary\n const document = this.configFile.readRawConfig(filename) as Record<string, unknown>;\n const selected = this.files.select(root, this.files.declarations(document['rulePacks'], root));\n const registry = new RulePackRegistry(\n selected.map((pack: SelectedPolicyPack) => pack.manifest),\n );\n for (const pack of selected)\n registry.recordModuleLocation(pack.manifest.packageName, pack.declaration.moduleName());\n this.validateRoot(document, root);\n const plans = this.prepare(root, selected, registry);\n const changed: string[] = [...layoutChanges];\n for (const plan of plans) {\n if (\n this.atomic.writeIfChanged(\n plan.filename,\n JSON.stringify(plan.entries, null, 2) + '\\n',\n )\n )\n changed.push(plan.filename);\n }\n return changed;\n }\n\n private prepare(\n root: string,\n selected: readonly SelectedPolicyPack[],\n registry: RulePackRegistry,\n ): readonly OwnerFilePlan[] {\n const plans: OwnerFilePlan[] = [];\n const errors: string[] = [];\n for (const pack of selected) {\n const filename = this.files.configPath(root, pack.declaration.config);\n const entries = fs.existsSync(filename) ? this.files.read(filename) : {};\n for (const id of Object.keys(entries)) {\n if (!registry.hasRule(id) || registry.ownerOf(id) !== pack.manifest.packageName) {\n errors.push(\n `${filename}: ${id} has another owner or is unknown. Move or remove it explicitly before sync.`,\n );\n }\n }\n for (const definition of pack.manifest.ownedRules) {\n const value = this.seedMissing(entries[definition.id], definition, registry.schemaFor(definition.id));\n errors.push(\n ...registry\n .validateRuleConfig(definition.id, value)\n .map((error: string) => `${filename}: ${error}`),\n );\n entries[definition.id] = value;\n }\n plans.push(new OwnerFilePlan(filename, entries));\n }\n if (errors.length) throw new InformAiError(`Sync made no changes:\\n${errors.join('\\n')}`);\n return plans;\n }\n\n private seedMissing(\n previous: ConfigObject | undefined,\n definition: OwnedRuleDefinition,\n // The registry's MERGED schema (owner fields + framework-owned universal fields).\n schema: Readonly<Record<string, FieldDef>>,\n ): ConfigObject {\n const value =\n previous === undefined\n ? structuredClone(definition.recommendedSeed)\n : Object.assign(new ConfigObject(), this.object(previous, definition.id));\n for (const field of Object.keys(schema)) {\n if (!schema[field].optional && !Object.hasOwn(value, field)) {\n value[field] = structuredClone(definition.recommendedSeed[field]);\n }\n }\n return value;\n }\n\n // webpieces-disable no-any-unknown -- the same generic-root validators run before any write\n private validateRoot(document: Record<string, unknown>, root: string): void {\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(document['commands'], document['pr-gate'], root),\n ...validateExcludePaths(document['excludePaths']),\n ...validateMatchRulesSection(document['match-rules']),\n ];\n if (errors.length) throw new InformAiError(`Sync made no changes:\\n${errors.join('\\n')}`);\n }\n\n // webpieces-disable no-any-unknown -- JSON object narrowing preserves explicit values for subsequent schema validation\n private object(value: unknown, label: string): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new InformAiError(`${label} must be a JSON object. Repair it before sync.`);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return value as Record<string, unknown>;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rule-pack-sync.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rule-pack-sync.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAmF;AACnF,8DAAwF;AACxF,+CAA4D;AAC5D,2DAA0E;AAC1E,6DAAwD;AACxD,yDAA0D;AAC1D,+EAAwE;AACxE,uDAAoF;AAEpF,MAAM,aAAa;IAEF;IACA;IAEA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A,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,wBAAU;QACf,mCAAe;QACd,2BAAU;GAJ9B,YAAY,CAyGxB","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject, FieldDef, OwnedRuleDefinition } from '@webpieces/rules-sdk';\nimport { AtomicFile, InformAiError, RepositoryLayout } from '@webpieces/tooling-common';\nimport { ConfigFile, CONFIG_FILENAME } from './config-file';\nimport { PackPolicyFiles, SelectedPolicyPack } from './pack-policy-files';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\n\nclass OwnerFilePlan {\n constructor(\n readonly filename: string,\n readonly entries: Record<string, ConfigObject>,\n /** The sync added nothing: the file is left byte-for-byte as its author formatted it (#1327). */\n readonly unchanged: boolean,\n ) {}\n}\n\n/**\n * Writes the owners' recommended seeds into the declared owner files, for review — the installer's and\n * `wp-migrate-dirs`' explicit file mutation. Normal configuration loading never calls this service: a\n * missing entry is a deny naming the file and the entry to paste, not something loading supplies.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RulePackSync {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n private readonly atomic: AtomicFile,\n ) {}\n\n run(root: string): readonly string[] {\n const layoutChanges = new RepositoryLayout().migrate(root);\n const filename = path.join(root, CONFIG_FILENAME);\n // webpieces-disable no-any-unknown -- the sync reads opaque JSON only at this explicit command boundary\n const document = this.configFile.readRawConfig(filename) as Record<string, unknown>;\n const selected = this.files.select(root, this.files.declarations(document['rulePacks'], root));\n const registry = new RulePackRegistry(\n selected.map((pack: SelectedPolicyPack) => pack.manifest),\n );\n for (const pack of selected)\n registry.recordModuleLocation(pack.manifest.packageName, pack.declaration.moduleName());\n this.validateRoot(document, root);\n const plans = this.prepare(root, selected, registry);\n const changed: string[] = [...layoutChanges];\n for (const plan of plans) {\n if (plan.unchanged) continue;\n if (\n this.atomic.writeIfChanged(\n plan.filename,\n JSON.stringify(plan.entries, null, 2) + '\\n',\n )\n )\n changed.push(plan.filename);\n }\n return changed;\n }\n\n private prepare(\n root: string,\n selected: readonly SelectedPolicyPack[],\n registry: RulePackRegistry,\n ): readonly OwnerFilePlan[] {\n const plans: OwnerFilePlan[] = [];\n const errors: string[] = [];\n for (const pack of selected) {\n const filename = this.files.configPath(root, pack.declaration.config);\n const exists = fs.existsSync(filename);\n const entries = exists ? this.files.read(filename) : {};\n const before = JSON.stringify(entries);\n for (const id of Object.keys(entries)) {\n if (!registry.hasRule(id) || registry.ownerOf(id) !== pack.manifest.packageName) {\n errors.push(\n `${filename}: ${id} has another owner or is unknown. Move or remove it explicitly before sync.`,\n );\n }\n }\n for (const definition of pack.manifest.ownedRules) {\n const value = this.seedMissing(entries[definition.id], definition, registry.schemaFor(definition.id));\n errors.push(\n ...registry\n .validateRuleConfig(definition.id, value)\n .map((error: string) => `${filename}: ${error}`),\n );\n entries[definition.id] = value;\n }\n // Compared as CONTENT, not bytes: a re-serialization of the same entries would only reformat.\n plans.push(new OwnerFilePlan(filename, entries, exists && JSON.stringify(entries) === before));\n }\n if (errors.length) throw new InformAiError(`Sync made no changes:\\n${errors.join('\\n')}`);\n return plans;\n }\n\n private seedMissing(\n previous: ConfigObject | undefined,\n definition: OwnedRuleDefinition,\n // The registry's MERGED schema (owner fields + framework-owned universal fields).\n schema: Readonly<Record<string, FieldDef>>,\n ): ConfigObject {\n const value =\n previous === undefined\n ? structuredClone(definition.recommendedSeed)\n : Object.assign(new ConfigObject(), this.object(previous, definition.id));\n for (const field of Object.keys(schema)) {\n if (!schema[field].optional && !Object.hasOwn(value, field)) {\n value[field] = structuredClone(definition.recommendedSeed[field]);\n }\n }\n return value;\n }\n\n // webpieces-disable no-any-unknown -- the same generic-root validators run before any write\n private validateRoot(document: Record<string, unknown>, root: string): void {\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(document['commands'], document['pr-gate'], root),\n ...validateExcludePaths(document['excludePaths']),\n ...validateMatchRulesSection(document['match-rules']),\n ];\n if (errors.length) throw new InformAiError(`Sync made no changes:\\n${errors.join('\\n')}`);\n }\n\n // webpieces-disable no-any-unknown -- JSON object narrowing preserves explicit values for subsequent schema validation\n private object(value: unknown, label: string): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new InformAiError(`${label} must be a JSON object. Repair it before sync.`);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n return value as Record<string, unknown>;\n }\n}\n"]}
|