etymd 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/README.md +30 -19
  3. package/dist/{approve-YUT43YLC.js → approve-MA4Z3TBT.js} +5 -5
  4. package/dist/audit-YSALDC2L.js +11 -0
  5. package/dist/{brief-Z5S6OY2M.js → brief-DPZYSAMC.js} +5 -5
  6. package/dist/{chunk-PXRLOEN5.js → chunk-2RNQ6OLV.js} +146 -717
  7. package/dist/{chunk-DSAQ5S5D.js → chunk-CEO3BXQB.js} +3 -2
  8. package/dist/{chunk-D3R74TJ2.js → chunk-DBWDMIYO.js} +1 -1
  9. package/dist/{chunk-5BVKFJWM.js → chunk-HI7NWPRA.js} +79 -4
  10. package/dist/{chunk-2VLNI3L2.js → chunk-HOR4M6EC.js} +1 -1
  11. package/dist/chunk-IWG77WV3.js +758 -0
  12. package/dist/{chunk-DWL2IKZH.js → chunk-P6ATKV2R.js} +65 -3
  13. package/dist/{chunk-HRJJQCMT.js → chunk-UFNETE6P.js} +69 -20
  14. package/dist/{chunk-YXOAPMQH.js → chunk-Y6RZRED3.js} +2 -2
  15. package/dist/{chunk-LSZGCKIQ.js → chunk-YQZDYDAK.js} +1 -1
  16. package/dist/cli.js +42 -21
  17. package/dist/{config-XAH6PA5G.js → config-724Y3IOB.js} +1 -2
  18. package/dist/{context-F63RSIBH.js → context-JGKU4M7Z.js} +2 -4
  19. package/dist/doctor-Y3DWDEBT.js +18 -0
  20. package/dist/{fleet-YQ35KGEP.js → fleet-4FYZ3GBK.js} +11 -12
  21. package/dist/{gates-DU6SDH2M.js → gates-IBQ7HCAN.js} +6 -7
  22. package/dist/generate-KEX75XNG.js +5 -0
  23. package/dist/index.d.ts +173 -2
  24. package/dist/index.js +713 -198
  25. package/dist/{init-XJEYU2HC.js → init-H57H2JBE.js} +14 -13
  26. package/dist/ledger-T54JDHGP.js +6 -0
  27. package/dist/premise-VMC3UUIB.js +333 -0
  28. package/dist/scan-W4US23MU.js +5 -0
  29. package/dist/{scan-B24RZAV2.js → scan-XBOHDXAH.js} +5 -5
  30. package/dist/{screen-CS6PSG7U.js → screen-E4FC7W5N.js} +2 -1
  31. package/package.json +2 -2
  32. package/dist/audit-YRT4SWSQ.js +0 -12
  33. package/dist/chunk-F75Q43BC.js +0 -59
  34. package/dist/chunk-JHZ2BN4U.js +0 -67
  35. package/dist/doctor-7YKDXSKM.js +0 -19
  36. package/dist/generate-PMCP37DC.js +0 -6
  37. package/dist/ledger-4FOZ5HAB.js +0 -5
  38. package/dist/scan-QDNN7ER3.js +0 -5
package/dist/index.d.ts CHANGED
@@ -154,6 +154,11 @@ interface ContextFile {
154
154
  role: string;
155
155
  words: number;
156
156
  approxTokens: number;
157
+ /**
158
+ * Other always-loaded names that are THIS SAME FILE — a symlink or hardlink resolving to one
159
+ * inode. Present so output can name every alias while the words are counted once.
160
+ */
161
+ aliases?: string[];
157
162
  }
158
163
  interface ContextBudget {
159
164
  files: ContextFile[];
@@ -681,6 +686,169 @@ declare function sweepFleet(manifest: FleetManifest, opts?: FleetSweepOptions):
681
686
  */
682
687
  declare const instructionTruthLens: Lens;
683
688
 
689
+ /** Everything a truth check needs from the repo, resolved once per run. */
690
+ interface TruthEnv {
691
+ root: string;
692
+ facts: ProjectFacts;
693
+ /** Package scripts across the root and every workspace manifest. */
694
+ knownScripts: Set<string>;
695
+ nodeModulesInstalled: boolean;
696
+ /** A manifest exists somewhere, so a script claim is checkable even without an install. */
697
+ manifestExists: boolean;
698
+ /** The root plus every workspace package dir — where claims are resolved. */
699
+ bases: string[];
700
+ /** A repo-relative claim resolves in the root, any workspace package, or their src/ scripts/. */
701
+ pathResolves(claim: string): Promise<boolean>;
702
+ /** `yarn X` / `pnpm X` may legitimately run an installed node_modules/.bin binary. */
703
+ binResolves(name: string): Promise<boolean>;
704
+ }
705
+ declare function buildTruthEnv(root: string, facts: ProjectFacts): Promise<TruthEnv>;
706
+ /** Skip-class tallies — every class a check declines to accuse is counted, then disclosed. */
707
+ interface ClaimCounters {
708
+ filteredSkipped: number;
709
+ tildeSkipped: number;
710
+ binaryResolved: number;
711
+ unverifiableCommands: number;
712
+ gitignoredSkipped: number;
713
+ prospectiveSkipped: number;
714
+ placeholderSkipped: number;
715
+ /** Decision references naming another record (a fleet-level ledger) — not this repo's. */
716
+ qualifiedRefsSkipped: number;
717
+ /** Decision references with no `## D-NNN` ledger to resolve against. */
718
+ unresolvableRefs: number;
719
+ }
720
+ declare function emptyCounters(): ClaimCounters;
721
+ /**
722
+ * One thing a check looked for, and what it found. `null` = could not be checked from the repo
723
+ * (counted and disclosed), never a guess. The honest-coverage half of a report: what was
724
+ * examined, not only what failed.
725
+ */
726
+ interface ExaminedClaim {
727
+ kind: "script" | "path" | "doc" | "decision";
728
+ value: string;
729
+ exists: boolean | null;
730
+ }
731
+ /** A piece of text making claims about the repo: an instruction file, a state doc, a task. */
732
+ interface ClaimText {
733
+ /** Repo-relative path, or a label such as `task` — becomes part of every finding id. */
734
+ path: string;
735
+ text: string;
736
+ }
737
+ interface TextClaimsOptions {
738
+ /** The lens the findings report under (`instruction-truth`, `premise`). */
739
+ lensId: string;
740
+ /** How the text is named in a claim sentence — a file path, or "The task". */
741
+ subject?: string;
742
+ /**
743
+ * A missing path is `gap` for an instruction file (a dead reference among many) and `risk` for
744
+ * a task (the task is ABOUT the path — an agent acting on it does the wrong thing).
745
+ */
746
+ missingPathTier: FindingTier;
747
+ maxPathFindings: number;
748
+ whyCommand?: string;
749
+ actionCommand?: string;
750
+ whyPath?: string;
751
+ actionPath?: string;
752
+ }
753
+ interface TextClaimsResult {
754
+ findings: Finding[];
755
+ disclosures: string[];
756
+ /** Every script and path claim the text made, found or not. */
757
+ examined: ExaminedClaim[];
758
+ }
759
+ /**
760
+ * Command and path claims in one text, verified against the repo. Precision over recall: every
761
+ * class it declines to accuse is counted in `counters` for the caller to disclose.
762
+ */
763
+ declare function checkTextClaims(env: TruthEnv, file: ClaimText, opts: TextClaimsOptions, counters: ClaimCounters): Promise<TextClaimsResult>;
764
+ interface RefsResult {
765
+ findings: Finding[];
766
+ examined: ExaminedClaim[];
767
+ }
768
+ /** Cross-references to well-known docs (AGENTS.md, CLAUDE.md, …) must resolve to real files. */
769
+ declare function checkDocRefs(env: TruthEnv, file: ClaimText, lensId: string, counters: ClaimCounters, subject?: string): Promise<RefsResult>;
770
+ /** The repo's own decision record: every `## D-NNN` id, and which files carried them. */
771
+ interface DecisionLedger {
772
+ /** Null when no decisions file with parseable `## D-NNN` entries exists. */
773
+ ids: Set<number> | null;
774
+ sources: string[];
775
+ }
776
+ declare function loadDecisionLedger(root: string, facts: ProjectFacts): Promise<DecisionLedger>;
777
+ interface DecisionRefsOptions {
778
+ lensId: string;
779
+ /** How the text is named in a claim sentence — a file path, or "The task". */
780
+ subject?: string;
781
+ why?: string;
782
+ action?: string;
783
+ }
784
+ /**
785
+ * `D-NNN` references in one text, resolved against the repo's own decision record. A citation
786
+ * the record cannot back is stale in a way age cannot reveal. Qualified refs (another record's)
787
+ * and refs with no ledger to resolve against are counted, never accused.
788
+ */
789
+ declare function checkDecisionRefs(file: ClaimText, ledger: DecisionLedger, opts: DecisionRefsOptions, counters: ClaimCounters): RefsResult;
790
+
791
+ declare const PREMISE_LENS = "premise";
792
+ declare const PREMISE_BRIEF_FILE: string;
793
+ /** One thing the task named, found or not — the checked half of the brief. */
794
+ type PremiseEntity = ExaminedClaim;
795
+ interface PremiseResult {
796
+ /** The `--json` schema version. */
797
+ schema: "premise/1";
798
+ task: string;
799
+ /** Where the task came from: `argument`, `stdin`, or the file path it was read from. */
800
+ source: string;
801
+ /** The project name from the reckoning. */
802
+ name: string;
803
+ findings: Finding[];
804
+ disclosures: string[];
805
+ /** Everything the task named that etymd could look for — found or not. */
806
+ entities: PremiseEntity[];
807
+ brief: string;
808
+ /** Repo-relative path the brief was written to, or `null` when the repo never opted in. */
809
+ briefPath: string | null;
810
+ }
811
+ interface PremiseOptions {
812
+ root: string;
813
+ task: string;
814
+ source?: string;
815
+ /** Write the brief under `.etymd/` when that directory exists (default true). */
816
+ writeBrief?: boolean;
817
+ }
818
+ /** What the prose promotion declined to read as a claim — counted, then disclosed. */
819
+ interface PromotionSkips {
820
+ /** `pnpm X` / `yarn X` / `bun X` in prose without `run` — a phrase as often as an invocation. */
821
+ bareInvocations: number;
822
+ /** `… run the`, `… run X` — a function word or a one-letter stand-in where a script would be. */
823
+ proseScripts: number;
824
+ /** `github.com/org/repo/…` — a scheme-less URL, not a repo path. */
825
+ hostnameLike: number;
826
+ /** `input/output/` — a slash-joined phrase whose first segment is no directory here. */
827
+ unrootedDirs: number;
828
+ }
829
+ interface PromotionContext {
830
+ /** Directory names that exist at the root, in a workspace package, or under their src/ scripts/. */
831
+ rootedDirs: ReadonlySet<string>;
832
+ }
833
+ interface PromotedText {
834
+ text: string;
835
+ skips: PromotionSkips;
836
+ }
837
+ /**
838
+ * People do not backtick paths in a prompt. Promote the bare mentions the claim extractors would
839
+ * otherwise treat as prose — `src/x.ts`, `docs/design/`, `npm run lint` — into code spans, leaving
840
+ * anything already in a code span untouched. Precision over recall: only what an instruction
841
+ * file's extractor would accept is promoted, and every class left as prose is counted.
842
+ */
843
+ declare function promoteBareTokens(text: string, ctx: PromotionContext): PromotedText;
844
+ declare function runPremise(opts: PremiseOptions): Promise<PremiseResult>;
845
+ /**
846
+ * The half of the premise check only an agent can do, written as a brief it reads before acting.
847
+ * Deterministic: it lists what etymd verified and hands over the three questions reading files
848
+ * cannot answer. It never speculates about what the task "really" means.
849
+ */
850
+ declare function renderBrief(task: string, findings: Finding[], entities: PremiseEntity[]): string;
851
+
684
852
  interface InstructionFile {
685
853
  /** Repo-relative path. */
686
854
  path: string;
@@ -811,10 +979,13 @@ declare const gateIntegrityLens: Lens;
811
979
  * The knowledge-pack version — bumped whenever templates, the rubric, or the encoded rules
812
980
  * change meaning. Stamped into facts, baselines, and generated artifacts so drift against the
813
981
  * pack is computable and `harvest` has something to diff.
982
+ *
983
+ * Gaps in the sequence are deliberate: a number stays retired even when the change that took it
984
+ * never shipped, so a version cited in a baseline or a record means exactly one pack, ever.
814
985
  */
815
- declare const PACK_VERSION = "8";
986
+ declare const PACK_VERSION = "12";
816
987
 
817
988
  declare const VERSION: string;
818
989
  declare const NAME: string;
819
990
 
820
- export { type ApplyResult, type ArtifactFreshness, type AuditOptions, type AuditResult, type Baseline, CONFIG_FILE, type ContextBudget, type ContextBudgets, type ContextFile, DECISIONS_FORMAT_MARKER, DEFAULT_CONFIG, type DetectedArtifact, type DiscoveredCommands, EXTRACTION_THRESHOLD, type EtymdConfig, FLEET_JSON_SCHEMA, FLEET_LENS, type Finding, type FleetContract, type FleetEntry, type FleetManifest, type FleetProfile, type FleetProjectSweep, type FleetSweepOptions, type FleetSweepResult, type FreshnessFacts, type GateInventory, type GateTool, type GeneratedFile, type HookFacts, type InstructionFileSet, type InstructionScope, LENSES, type Ledger, type LedgerDiff, type LedgerEntry, type Lens, type LensReport, type LoadedConfig, type ManifestProblem, NAME, PACK_VERSION, type PackageManager, type PathClaims, type PlanOptions, type ProjectFacts, type StateBudgets, TOTAL_BUDGET_WORDS, VERSION, type WorkflowProfile, type WorkspaceKind, applyFiles, baselineCarriesMachinePath, baselinePath, buildGateInventory, cacheFactsPath, checkManifest, collectWallFindings, configPath, contextEconomyLens, corpPersistenceRoot, deriveProfile, expandTilde, extractCommandClaims, extractPathClaims, gateIntegrityLens, instructionTruthLens, isAlwaysAppliedCursorRule, listInstructionFiles, loadFleetManifest, measureContext, planWorkflow, rankFindings, readBaseline, readCachedFacts, readConfig, readLedger, reconcileLedger, runAudit, scanProject, stateFreshnessLens, sweepFleet, withoutMachinePath, writeBaseline, writeCachedFacts, writeLedger };
991
+ export { type ApplyResult, type ArtifactFreshness, type AuditOptions, type AuditResult, type Baseline, CONFIG_FILE, type ClaimCounters, type ClaimText, type ContextBudget, type ContextBudgets, type ContextFile, DECISIONS_FORMAT_MARKER, DEFAULT_CONFIG, type DecisionLedger, type DecisionRefsOptions, type DetectedArtifact, type DiscoveredCommands, EXTRACTION_THRESHOLD, type EtymdConfig, type ExaminedClaim, FLEET_JSON_SCHEMA, FLEET_LENS, type Finding, type FleetContract, type FleetEntry, type FleetManifest, type FleetProfile, type FleetProjectSweep, type FleetSweepOptions, type FleetSweepResult, type FreshnessFacts, type GateInventory, type GateTool, type GeneratedFile, type HookFacts, type InstructionFileSet, type InstructionScope, LENSES, type Ledger, type LedgerDiff, type LedgerEntry, type Lens, type LensReport, type LoadedConfig, type ManifestProblem, NAME, PACK_VERSION, PREMISE_BRIEF_FILE, PREMISE_LENS, type PackageManager, type PathClaims, type PlanOptions, type PremiseEntity, type PremiseOptions, type PremiseResult, type ProjectFacts, type PromotedText, type PromotionContext, type PromotionSkips, type RefsResult, type StateBudgets, TOTAL_BUDGET_WORDS, type TextClaimsOptions, type TextClaimsResult, type TruthEnv, VERSION, type WorkflowProfile, type WorkspaceKind, applyFiles, baselineCarriesMachinePath, baselinePath, buildGateInventory, buildTruthEnv, cacheFactsPath, checkDecisionRefs, checkDocRefs, checkManifest, checkTextClaims, collectWallFindings, configPath, contextEconomyLens, corpPersistenceRoot, deriveProfile, emptyCounters, expandTilde, extractCommandClaims, extractPathClaims, gateIntegrityLens, instructionTruthLens, isAlwaysAppliedCursorRule, listInstructionFiles, loadDecisionLedger, loadFleetManifest, measureContext, planWorkflow, promoteBareTokens, rankFindings, readBaseline, readCachedFacts, readConfig, readLedger, reconcileLedger, renderBrief, runAudit, runPremise, scanProject, stateFreshnessLens, sweepFleet, withoutMachinePath, writeBaseline, writeCachedFacts, writeLedger };