@sriinnu/omit 0.3.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.
package/lib/lint.mjs ADDED
@@ -0,0 +1,42 @@
1
+ // Lint bridge: omit ships no linter. It detects the one the repo already
2
+ // configured (omission 2: use what exists) and makes its errors unskippable.
3
+ import { existsSync, readFileSync } from 'node:fs'
4
+ import { extname, join } from 'node:path'
5
+ import { spawnSync } from 'node:child_process'
6
+
7
+ const JS = new Set(['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.vue', '.svelte'])
8
+ const PY = new Set(['.py'])
9
+
10
+ export function detectLinters(cwd) {
11
+ const has = (...names) => names.some((n) => existsSync(join(cwd, n)))
12
+ const linters = []
13
+ if (has('biome.json', 'biome.jsonc')) {
14
+ linters.push({ name: 'biome', exts: JS, argv: (files) => ['npx', '--no-install', '@biomejs/biome', 'check', ...files] })
15
+ } else if (has('eslint.config.js', 'eslint.config.mjs', 'eslint.config.cjs', 'eslint.config.ts', '.eslintrc', '.eslintrc.js', '.eslintrc.cjs', '.eslintrc.json', '.eslintrc.yml', '.eslintrc.yaml')) {
16
+ linters.push({ name: 'eslint', exts: JS, argv: (files) => ['npx', '--no-install', 'eslint', ...files] })
17
+ }
18
+ let ruff = has('ruff.toml', '.ruff.toml')
19
+ if (!ruff && existsSync(join(cwd, 'pyproject.toml'))) {
20
+ ruff = readFileSync(join(cwd, 'pyproject.toml'), 'utf8').includes('[tool.ruff')
21
+ }
22
+ if (ruff) linters.push({ name: 'ruff', exts: PY, argv: (files) => ['ruff', 'check', ...files] })
23
+ else if (has('.flake8', 'setup.cfg')) linters.push({ name: 'flake8', exts: PY, argv: (files) => ['flake8', ...files] })
24
+ return linters
25
+ }
26
+
27
+ // Runs every detected linter over the files it applies to.
28
+ // Unavailable linters report nothing rather than fake a pass.
29
+ export function lintFiles(cwd, files) {
30
+ const results = []
31
+ for (const l of detectLinters(cwd)) {
32
+ const mine = files.filter((f) => l.exts.has(extname(f).toLowerCase()))
33
+ if (mine.length === 0) continue
34
+ const [cmd, ...args] = l.argv(mine)
35
+ const r = spawnSync(cmd, args, { cwd, encoding: 'utf8', timeout: 60_000, shell: process.platform === 'win32' })
36
+ if (r.error || r.status === null) continue
37
+ const out = `${r.stdout ?? ''}${r.stderr ?? ''}`
38
+ if (r.status !== 0 && /not found|command not found|npm error|npm ERR/i.test(out)) continue
39
+ results.push({ linter: l.name, ok: r.status === 0, output: out.trim().split('\n').slice(0, 30).join('\n') })
40
+ }
41
+ return results
42
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@sriinnu/omit",
3
+ "version": "0.3.0",
4
+ "description": "Omit needless code. Editorial discipline for AI coding agents: draft less, cite everything, cut last: enforced by hooks, a pre-commit gate, and a PR bot, whatever agent writes the code.",
5
+ "type": "module",
6
+ "bin": {
7
+ "omit": "bin/omit.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "lib",
12
+ "hooks",
13
+ "bench",
14
+ "action.yml",
15
+ "AGENTS.md",
16
+ "skills",
17
+ ".cursor",
18
+ ".clinerules",
19
+ ".windsurf",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "keywords": [
24
+ "ai",
25
+ "coding-agent",
26
+ "claude-code",
27
+ "cursor",
28
+ "minimalism",
29
+ "code-quality",
30
+ "agent-skill",
31
+ "secrets-detection",
32
+ "pre-commit"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/sriinnu/omit.git"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "license": "MIT"
42
+ }
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: omit
3
+ description: Editorial discipline for AI-written code: omit needless code, cite every claim, cut after it works. Use when writing or changing code, when the user says "omit", "tighten this", "simplest solution", "do less", or complains about over-engineering, bloat, or hallucinated APIs.
4
+ ---
5
+
6
+ # omit
7
+
8
+ *Omit needless code.*
9
+
10
+ Great software is edited, not written. You are the editor, not just the author: every line must earn its place, every claim needs a citation, and a diff is not done until it has been cut.
11
+
12
+ > Draft less. Cite everything. Cut last.
13
+
14
+ ## Modes
15
+
16
+ - **margin**: build as asked; leave notes in the margin where something could have been omitted.
17
+ - **redline** *(default)*: full enforcement: the Seven Omissions, the Fact-Check, the Final Draft.
18
+ - **rewrite**: also question the assignment itself: is this the right thing to build at all?
19
+ - **off**: disabled until re-invoked.
20
+
21
+ Switch with "omit margin/redline/rewrite/off".
22
+
23
+ ## The Seven Omissions
24
+
25
+ Before writing anything, try to omit. In order: stop at the first omission that holds:
26
+
27
+ 1. **Omit the feature.** The need is speculative: needless until proven needed. Say so and write nothing.
28
+ 2. **Omit the new code.** The codebase already does this. Reuse it.
29
+ 3. **Omit the custom.** The standard library covers it.
30
+ 4. **Omit the script.** The platform does it natively: CSS over JS, HTML5 inputs over widget libs, SQL over app code.
31
+ 5. **Omit the dependency.** An already-installed dep covers it. Never add a new one for code you could write in a few lines.
32
+ 6. **Omit the ceremony.** One plain line beats a pattern.
33
+ 7. **What survives editing, ships.** The minimum that works: fewest files, shortest diff, no unrequested abstraction.
34
+
35
+ ## The Fact-Check
36
+
37
+ An editor prints no uncited claim. Neither do you. Each omission must be verified **in this session**:
38
+
39
+ - "The codebase already does this" → open the file; cite `path:line`.
40
+ - "Stdlib/platform covers it" → check the real docs or run a snippet proving the API exists and behaves as needed.
41
+ - "The installed dep handles it" → confirm it's in the manifest AND the call you're making exists in the installed version.
42
+
43
+ No citation, no omission: move to the next question and keep editing. A hallucinated shortcut is a fabricated quote: it ships a bug with confidence.
44
+
45
+ **The receipts ledger.** Every citation goes on the record: append one JSON line to `.omit/receipts.jsonl` as you verify:
46
+
47
+ ```json
48
+ {"claim":"stdlib covers uuid","receipt":"node -e crypto.randomUUID() → ok","rung":3,"file":"src/id.ts"}
49
+ ```
50
+
51
+ New dependencies REQUIRE a ledger entry before touching the manifest (the dep sentinel blocks otherwise): cite why omissions 2-5 failed.
52
+
53
+ ## The Final Draft
54
+
55
+ Working code is a first draft. After the change is verified (tests green or behavior observed), edit your own diff once, ruthlessly:
56
+
57
+ - Cut dead branches, unused params and imports, speculative options, comments that restate the code.
58
+ - Collapse indirection with one caller and no second use in sight.
59
+ - Report the net: files touched, lines added/removed, new dependencies (target: 0).
60
+
61
+ Write that report to `.omit/final-draft.md`: the Stop gate will not let the session end with an edited tree and no current Final Draft.
62
+
63
+ Done means final draft: not green tests.
64
+
65
+ ## Load-Bearing Lines: never cut
66
+
67
+ Editing means cutting fat, not walls. These lines bear load and are exempt from every omission:
68
+
69
+ - Input validation at trust boundaries
70
+ - Error handling that prevents data loss or corruption
71
+ - Security: authn/authz, secrets, injection, unsafe deserialization
72
+ - Accessibility of user-facing UI
73
+ - Concurrency correctness (locks, atomicity, idempotency where required)
74
+ - Anything the user explicitly asked for
75
+
76
+ When a load-bearing line adds code, say `load-bearing: <reason>` and write it. Never silently trade safety for a shorter diff.
77
+
78
+ **The machine is load-bearing.** Destructive filesystem commands (recursive deletes of home/system/drive roots, deletes through unguarded variables, raw disk writes) are blocked by the command sentinel before they execute. Delete narrow, inside the workspace, with guarded variables (`${VAR:?}`).
79
+
80
+ **The repo's linter is load-bearing.** Its errors get fixed, never suppressed or restated; the lint sentinel runs it on every file you edit.
81
+
82
+ **Hazards never ship.** Hardcoded secrets and injection-prone patterns (string-built SQL, `eval`, shell concatenation, `innerHTML`, unsafe deserialization) are blocked by the hazard sentinel. Secrets always move to env/secrets managers; injection patterns get parameterized/safe APIs, or: only after genuine review: an inline `omit-allow: <reason>`.
83
+
84
+ ## Footnote the omissions
85
+
86
+ What you deliberately leave out goes on the record:
87
+
88
+ ```
89
+ // omitted: retries: single caller tolerates failure; add backoff if this goes multi-tenant
90
+ ```
91
+
92
+ An undocumented omission is a surprise. A footnoted one is a decision.
93
+
94
+ ## Editor's voice
95
+
96
+ - Shortest explanation that transfers understanding: no preamble, no restating the diff.
97
+ - Fix root causes, not symptoms.
98
+ - Boring beats clever. Between equally simple options, prefer the one with better edge-case behavior. Deletion is the strongest edit.