circle-ir-ai 4.41.0 → 4.43.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/CHANGELOG.md +28 -0
- package/dist/command-module/contract.d.ts +121 -0
- package/dist/command-module/contract.d.ts.map +1 -0
- package/dist/command-module/contract.js +40 -0
- package/dist/command-module/contract.js.map +1 -0
- package/dist/command-module/findings-commands.d.ts +56 -0
- package/dist/command-module/findings-commands.d.ts.map +1 -0
- package/dist/command-module/findings-commands.js +178 -0
- package/dist/command-module/findings-commands.js.map +1 -0
- package/dist/command-module/index.d.ts +46 -0
- package/dist/command-module/index.d.ts.map +1 -0
- package/dist/command-module/index.js +136 -0
- package/dist/command-module/index.js.map +1 -0
- package/dist/command-module/legacy/args.d.ts +263 -0
- package/dist/command-module/legacy/args.d.ts.map +1 -0
- package/dist/command-module/legacy/args.js +5 -0
- package/dist/command-module/legacy/args.js.map +1 -0
- package/dist/command-module/legacy/cache-telemetry.d.ts +45 -0
- package/dist/command-module/legacy/cache-telemetry.d.ts.map +1 -0
- package/dist/command-module/legacy/cache-telemetry.js +74 -0
- package/dist/command-module/legacy/cache-telemetry.js.map +1 -0
- package/dist/command-module/legacy/cluster-policies.d.ts +73 -0
- package/dist/command-module/legacy/cluster-policies.d.ts.map +1 -0
- package/dist/command-module/legacy/cluster-policies.js +91 -0
- package/dist/command-module/legacy/cluster-policies.js.map +1 -0
- package/dist/command-module/legacy/commands/analyze-skill.d.ts +57 -0
- package/dist/command-module/legacy/commands/analyze-skill.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/analyze-skill.js +251 -0
- package/dist/command-module/legacy/commands/analyze-skill.js.map +1 -0
- package/dist/command-module/legacy/commands/bom.d.ts +12 -0
- package/dist/command-module/legacy/commands/bom.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/bom.js +92 -0
- package/dist/command-module/legacy/commands/bom.js.map +1 -0
- package/dist/command-module/legacy/commands/cluster.d.ts +12 -0
- package/dist/command-module/legacy/commands/cluster.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/cluster.js +295 -0
- package/dist/command-module/legacy/commands/cluster.js.map +1 -0
- package/dist/command-module/legacy/commands/generate-spec.d.ts +22 -0
- package/dist/command-module/legacy/commands/generate-spec.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/generate-spec.js +216 -0
- package/dist/command-module/legacy/commands/generate-spec.js.map +1 -0
- package/dist/command-module/legacy/commands/init.d.ts +69 -0
- package/dist/command-module/legacy/commands/init.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/init.js +134 -0
- package/dist/command-module/legacy/commands/init.js.map +1 -0
- package/dist/command-module/legacy/commands/quality.d.ts +21 -0
- package/dist/command-module/legacy/commands/quality.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/quality.js +136 -0
- package/dist/command-module/legacy/commands/quality.js.map +1 -0
- package/dist/command-module/legacy/commands/scan.d.ts +33 -0
- package/dist/command-module/legacy/commands/scan.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/scan.js +556 -0
- package/dist/command-module/legacy/commands/scan.js.map +1 -0
- package/dist/command-module/legacy/commands/secrets.d.ts +25 -0
- package/dist/command-module/legacy/commands/secrets.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/secrets.js +211 -0
- package/dist/command-module/legacy/commands/secrets.js.map +1 -0
- package/dist/command-module/legacy/commands/spec-diff.d.ts +12 -0
- package/dist/command-module/legacy/commands/spec-diff.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/spec-diff.js +199 -0
- package/dist/command-module/legacy/commands/spec-diff.js.map +1 -0
- package/dist/command-module/legacy/commands/understand.d.ts +12 -0
- package/dist/command-module/legacy/commands/understand.d.ts.map +1 -0
- package/dist/command-module/legacy/commands/understand.js +195 -0
- package/dist/command-module/legacy/commands/understand.js.map +1 -0
- package/dist/command-module/legacy/config.d.ts +340 -0
- package/dist/command-module/legacy/config.d.ts.map +1 -0
- package/dist/command-module/legacy/config.js +383 -0
- package/dist/command-module/legacy/config.js.map +1 -0
- package/dist/command-module/legacy/effective-options.d.ts +355 -0
- package/dist/command-module/legacy/effective-options.d.ts.map +1 -0
- package/dist/command-module/legacy/effective-options.js +717 -0
- package/dist/command-module/legacy/effective-options.js.map +1 -0
- package/dist/command-module/legacy/file-collection.d.ts +89 -0
- package/dist/command-module/legacy/file-collection.d.ts.map +1 -0
- package/dist/command-module/legacy/file-collection.js +282 -0
- package/dist/command-module/legacy/file-collection.js.map +1 -0
- package/dist/command-module/legacy/finding-paths.d.ts +7 -0
- package/dist/command-module/legacy/finding-paths.d.ts.map +1 -0
- package/dist/command-module/legacy/finding-paths.js +48 -0
- package/dist/command-module/legacy/finding-paths.js.map +1 -0
- package/dist/command-module/legacy/findings-cap.d.ts +65 -0
- package/dist/command-module/legacy/findings-cap.d.ts.map +1 -0
- package/dist/command-module/legacy/findings-cap.js +188 -0
- package/dist/command-module/legacy/findings-cap.js.map +1 -0
- package/dist/command-module/legacy/flow-backed.d.ts +36 -0
- package/dist/command-module/legacy/flow-backed.d.ts.map +1 -0
- package/dist/command-module/legacy/flow-backed.js +58 -0
- package/dist/command-module/legacy/flow-backed.js.map +1 -0
- package/dist/command-module/legacy/formatters/scan-sarif-enrich.d.ts +27 -0
- package/dist/command-module/legacy/formatters/scan-sarif-enrich.d.ts.map +1 -0
- package/dist/command-module/legacy/formatters/scan-sarif-enrich.js +64 -0
- package/dist/command-module/legacy/formatters/scan-sarif-enrich.js.map +1 -0
- package/dist/command-module/legacy/inner-scan-options.d.ts +82 -0
- package/dist/command-module/legacy/inner-scan-options.d.ts.map +1 -0
- package/dist/command-module/legacy/inner-scan-options.js +100 -0
- package/dist/command-module/legacy/inner-scan-options.js.map +1 -0
- package/dist/command-module/legacy/llm-degraded.d.ts +34 -0
- package/dist/command-module/legacy/llm-degraded.d.ts.map +1 -0
- package/dist/command-module/legacy/llm-degraded.js +12 -0
- package/dist/command-module/legacy/llm-degraded.js.map +1 -0
- package/dist/command-module/legacy/parse-failure-gate.d.ts +68 -0
- package/dist/command-module/legacy/parse-failure-gate.d.ts.map +1 -0
- package/dist/command-module/legacy/parse-failure-gate.js +87 -0
- package/dist/command-module/legacy/parse-failure-gate.js.map +1 -0
- package/dist/command-module/legacy/product-scope.d.ts +25 -0
- package/dist/command-module/legacy/product-scope.d.ts.map +1 -0
- package/dist/command-module/legacy/product-scope.js +67 -0
- package/dist/command-module/legacy/product-scope.js.map +1 -0
- package/dist/command-module/legacy/program.d.ts +222 -0
- package/dist/command-module/legacy/program.d.ts.map +1 -0
- package/dist/command-module/legacy/program.js +707 -0
- package/dist/command-module/legacy/program.js.map +1 -0
- package/dist/command-module/legacy/progress.d.ts +76 -0
- package/dist/command-module/legacy/progress.d.ts.map +1 -0
- package/dist/command-module/legacy/progress.js +135 -0
- package/dist/command-module/legacy/progress.js.map +1 -0
- package/dist/command-module/legacy/project-profile.d.ts +41 -0
- package/dist/command-module/legacy/project-profile.d.ts.map +1 -0
- package/dist/command-module/legacy/project-profile.js +27 -0
- package/dist/command-module/legacy/project-profile.js.map +1 -0
- package/dist/command-module/legacy/scan-watchdog.d.ts +68 -0
- package/dist/command-module/legacy/scan-watchdog.d.ts.map +1 -0
- package/dist/command-module/legacy/scan-watchdog.js +127 -0
- package/dist/command-module/legacy/scan-watchdog.js.map +1 -0
- package/dist/command-module/legacy/severity-policy.d.ts +92 -0
- package/dist/command-module/legacy/severity-policy.d.ts.map +1 -0
- package/dist/command-module/legacy/severity-policy.js +190 -0
- package/dist/command-module/legacy/severity-policy.js.map +1 -0
- package/dist/command-module/legacy/source-check.d.ts +291 -0
- package/dist/command-module/legacy/source-check.d.ts.map +1 -0
- package/dist/command-module/legacy/source-check.js +762 -0
- package/dist/command-module/legacy/source-check.js.map +1 -0
- package/dist/command-module/legacy/test-tree-excludes.d.ts +6 -0
- package/dist/command-module/legacy/test-tree-excludes.d.ts.map +1 -0
- package/dist/command-module/legacy/test-tree-excludes.js +38 -0
- package/dist/command-module/legacy/test-tree-excludes.js.map +1 -0
- package/dist/command-module/register.d.ts +23 -0
- package/dist/command-module/register.d.ts.map +1 -0
- package/dist/command-module/register.js +384 -0
- package/dist/command-module/register.js.map +1 -0
- package/dist/specifica/evidence-extractor.d.ts.map +1 -1
- package/dist/specifica/evidence-extractor.js +14 -0
- package/dist/specifica/evidence-extractor.js.map +1 -1
- package/dist/specifica/generator.d.ts +4 -0
- package/dist/specifica/generator.d.ts.map +1 -1
- package/dist/specifica/generator.js +136 -5
- package/dist/specifica/generator.js.map +1 -1
- package/dist/specifica/spec-tree.d.ts +24 -0
- package/dist/specifica/spec-tree.d.ts.map +1 -1
- package/dist/specifica/spec-tree.js +12 -4
- package/dist/specifica/spec-tree.js.map +1 -1
- package/dist/specifica/ts-rule-sources.d.ts +3 -0
- package/dist/specifica/ts-rule-sources.d.ts.map +1 -1
- package/dist/specifica/ts-rule-sources.js +119 -9
- package/dist/specifica/ts-rule-sources.js.map +1 -1
- package/dist/specifica/types.d.ts +27 -1
- package/dist/specifica/types.d.ts.map +1 -1
- package/dist/specifica/use-cases.d.ts.map +1 -1
- package/dist/specifica/use-cases.js +5 -1
- package/dist/specifica/use-cases.js.map +1 -1
- package/dist/utils/file-skip.d.ts +93 -0
- package/dist/utils/file-skip.d.ts.map +1 -1
- package/dist/utils/file-skip.js +321 -0
- package/dist/utils/file-skip.js.map +1 -1
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.43.0] - 2026-11-30
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Java throws and guards are domain rule sources (res-1823).** A Java file's `throw new X(…)` facts, with the `if` that guards each (quoted from its line, as for TypeScript), now reach the static rules and the level's spec.md: OWASP BenchmarkUtils had 5 use cases (its Maven goals) and 0 rules, so its review had nothing to show. A throw with neither a message nor a guard (`throw new RuntimeException(e)`, which passes an error on) is not a rule, nor is an internal error such as `AssertionError`; generic messages stay, as for TypeScript.
|
|
14
|
+
- **A throw's message is quoted only when the code says it literally (res-1823).** A variable or a call passed to an error (`new RuntimeException(e)`, `new IOException(versionNumError)`, `new RuntimeException(finding.toString())`, `new Error(msg)`) was quoted as if it were the message (`RuntimeException("e")`); it is now no message, so the rule names the error type alone (and an unguarded generic one is no domain rule). A concatenation keeps its literal parts, with `…` for each other operand (`"ZipFile does not contain " + zipPath` → `ZipFile does not contain …`), where the doubled quotes showed before. The object form (`new TRPCError({ code, message: '…' })`) is kept whole for its `message:`; template literals are unchanged. TypeScript, JavaScript, Java and Python throws; a rule whose text changes gets a new rule key.
|
|
15
|
+
- **A Python format string keeps its literal text (cognium-ai#1213 review).** `raise ValueError("bad order %s" % y)` and `raise ValueError("bad order {}".format(y))` now read `ValueError("bad order …")`, as a concatenation does (`%%`, `{{` and `}}` read as the character); the literal-only rule above had dropped their message, leaving a bare "may throw ValueError". f-strings are kept as written, as template literals are; a name, a call or a constant (`msg`, `str(y)`, `errors.BAD_ORDER`) is still no message.
|
|
16
|
+
- **No "0 export(s)" public-surface row (res-1823).** A barrel that only re-exports packages (`export * from '@repo/db/schema'`) gave a use case titled "0 export(s): @repo/db/schema"; such a group now gives no row (6 on controldeck, 1 on cognium-dev).
|
|
17
|
+
- **A Maven goal's use case reads "Maven goal create-scorecard"** (was "goal create-scorecard"). The title only; the entry (`kind: cli`, `method: GOAL`, `path`) and the use-case id are unchanged.
|
|
18
|
+
|
|
19
|
+
On circle-ir **4.26.0** (exact). No API or output-schema changes in this package. Pair it with `@cognium/mcp-server` 1.0.1 and `cognium` 5.0.1, which pin the same circle-ir; the loaders refuse a module on another circle-ir minor.
|
|
20
|
+
|
|
21
|
+
- **`circle-ir` 4.25.0 → 4.26.0.** The Python log value-shape check reads the whole logging call and keeps a flow when any name other than a shape (`len(...)`, `json.dumps(...)`, `**kwargs` keys, a key-loop variable) is used as a value (cogniumhq/cognium-dev#1508). Typecheck, build and the full suite are green on 4.26.0 from npm with no expectation changes.
|
|
22
|
+
|
|
23
|
+
## [4.42.0] - 2026-11-29
|
|
24
|
+
|
|
25
|
+
The first release with `circle-ir-ai/cli`, the AI commands as a module for the one CLI, `cognium` 5. On circle-ir 4.25.0, like 4.41.0. Install it next to `cognium`: `npm i -g cognium circle-ir-ai`.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- **`circle-ir-ai/cli`: this package's commands as a module for the one CLI, `cognium` 5 (one-CLI plan, techspec `services/cognium-engine/plans/one-cli/`, design §2, spec §3).** A new export, `circle-ir-ai/cli`, gives a `CommandModule` (`id`, `version`, `licence`, `circleIrRange`, `commands`, `gaps`, `register(program, ctx)`, `scanLlm`) that the `cognium` CLI loads the same way `@cognium/mcp-server` loads `circle-ir-ai/mcp`. It is structural (`src/command-module/contract.ts`, a copy of cognium-mcp's `packages/cli/src/module-contract.ts`); the package still ships no `bin`. It registers the AI commands of spec §3: `secrets`, `bom`, `understand`, `spec-diff`, `analyze-skill`, `quality`, `health`, `generate-spec`, `cluster`, with cognium-ai's options and help, and serves `cognium scan --llm [--llm-verify]` through `scanLlm.run`. Not carried: `trust` and `compare` (their score goes, P4), cognium-ai's own `scan`, `metrics` and `dead-code` (the `circle-ir` commands serve them, OD1), `benchmark` and `analyze-llm-log`.
|
|
29
|
+
- **`quality` and `health` return findings, no scores (OC3).** One finding shape (`id`, `category`, `severity`, `file`, `line_start`, `line_end?`, `message`, `rule_id`, `source`, `related_cwe?`), sorted and de-duplicated by id, with counts by severity and category. No score, tier, colour, weights or badge in any format, and no `--threshold`: `--severity <level>` (or `-e`, floor `high`) exits 1 when a finding is at or above it (CLI contract, spec §4).
|
|
30
|
+
- **Licence states (design §3, OC5/OC6).** Installed is enough for the deterministic commands: one notice on stderr the first time one runs, naming the PolyForm Noncommercial terms (not with `-q`, not with a commercial licence). The LLM is off unless `--llm` is given, and `--llm` needs an endpoint: `COGNIUM_ENDPOINT` (the CLI's enablement), `--llm-base-url` / `LLM_BASE_URL`, or a commercial licence; without one the command prints one line and exits 2, having sent nothing.
|
|
31
|
+
- **Refused on another `circle-ir` minor.** `register()` throws when the CLI's `circle-ir` differs in `major.minor` from this package's pin (the CLI's loader checks first; this is the module's own guard).
|
|
32
|
+
- **Recorded gap (design §2, "wrap only"):** every command still parses the project itself; none reads `ctx.analysis` yet, so `gaps` lists all nine. Not a 5.0 gate.
|
|
33
|
+
- The command code is a copy of cognium-ai's under `src/command-module/legacy/`, so `cognium-ai` keeps working unchanged until its forwarding release; its own copy goes one release after `cognium` 5.0.0 (T-OC5.3). `commander` is a dev dependency only (types); at run time the CLI passes its own program in.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- **The learned spec skips vendored, minified, bundled and generated files (controldeck#717 follow-up).** A script bundled under `src/main/resources/` sits in a source set the product scope keeps, so a Bootstrap copy with no `.min.js` twin beside it still gave a Java repository's spec its only use cases (`on click.bs.button.data-api`). `generateSpecificaForDirectory` now leaves out, whatever the product scope: files in vendor or build-output folders (`vendor/`, `third_party/`, `external/`, `webjars/`, `generated/` …, beside the walk's own `node_modules`/`dist`/`build`/`target`); `*.min.js` and other minified names; `*.bundle.js`, `*.chunk.js`, `*.generated.*` and protobuf outputs; scripts, styles and pages under a JVM source set's `src/<set>/resources/` with no `package.json`, `deno.json` or `jsr.json` between them and the root (a project's own `static/`, `assets/`, `public/` and `wwwroot/` code is kept); paths marked `linguist-vendored` or `linguist-generated` in any `.gitattributes`; files that open with a library licence banner (a licence or copyright plus a library signature in the first comment: a name and its version on one line such as `Bootstrap v3.3.7` or `@license React v18.2.0`, a well-known library with a version, or `(c) <library> contributors`; a plain licence header such as "Licensed under the Apache License, Version 2.0" is never one, nor is a foundation header with an SPDX line (the Apache Software Foundation or Eclipse Foundation header with `SPDX-License-Identifier: Apache-2.0` / `EPL-2.0`): SPDX lines and licence ids and versions are removed before the signature is read, and a licence steward such as a foundation is never a library name; a banner naming the repository's own package is kept); files with a recognised generator stamp at the start of a comment line in their first 20 lines (Go's `// Code generated … DO NOT EDIT.`, `@generated`, `<auto-generated>`, `This file is generated`, `Generated by` protoc, OpenAPI, Swagger, jOOQ, MapStruct, Thrift and other known tools, `@Generated("…")` with a value) or delombok output; a bare "DO NOT EDIT" or "auto-generated" in a comment is not a stamp; and minified content (at most 3 lines over 2 000 chars, or a line over 5 000 chars at 300 chars a line on average). The rules are in `src/utils/file-skip.ts` (`notOwnCodeByPath`, `notOwnCodeByContent`, `readLinguistAttributes`), beside the vendored and minified skips `preFlightSkip` already applies for every walker. Each directory output carries `notOwnCode` (count, reasons, the first 20 files) when any file was left out. When every file found is such a copy, the answer is an empty spec whose repository level carries `plainReason` ("Only vendored or generated files found (N files: …); no spec was learned from them"), also written in its spec.md, instead of a spec learned from the copies. When own files also failed to analyse (an analyser error, or too large to read), that reason is not given: the run fails with "Failed to analyze any files: N files could not be analysed; the rest were vendored or generated (…)", and the error carries `plainReason`, `notOwnCode` and `notAnalysedCount`. `SKIP_VENDORED=0` turns the rules off. Additive output only; scans are unchanged. OWASP BenchmarkUtils (a52d37e), static spec: the plugin module reads 5 use cases (its Maven goals) and 0 rules, and 8 files are left out (7 bundled assets, 1 minified).
|
|
37
|
+
|
|
10
38
|
## [4.41.0] - 2026-11-29
|
|
11
39
|
|
|
12
40
|
Minor, on circle-ir **4.25.0** (was 4.24.0, exact). No change to circle-ir-ai's own code; what moves is what circle-ir finds, so scan, quality, trust and spec results can move.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-module seam (one-CLI design §2).
|
|
3
|
+
*
|
|
4
|
+
* An optional package registers extra commands on the `cognium` CLI. The
|
|
5
|
+
* default specifier is `circle-ir-ai/cli` (PolyForm-NC). The seam mirrors the
|
|
6
|
+
* server's `ToolModule` (`@cognium/mcp-server` `modules.ts`): the same five
|
|
7
|
+
* fields, the same `major.minor` rule against the installed `circle-ir`, and
|
|
8
|
+
* the same enablement, so "which state am I in" has one answer on both doors.
|
|
9
|
+
*
|
|
10
|
+
* This file is the contract. It describes the seam structurally and imports
|
|
11
|
+
* nothing: a module implements it without depending on `cognium` or on
|
|
12
|
+
* commander. A module that is absent loads nothing; one that is present but
|
|
13
|
+
* wrong (shape, `circle-ir` minor, failed import) is refused with one line on
|
|
14
|
+
* stderr, and each AI command name then prints one refusal line naming the
|
|
15
|
+
* install. The CLI's base commands run either way.
|
|
16
|
+
*
|
|
17
|
+
* Contract version: 1 (cognium 5.0.0).
|
|
18
|
+
*/
|
|
19
|
+
/** The licence state, identical to the server's `LicenceState`. */
|
|
20
|
+
export type CommandLicenceState = 'floor' | 'extended' | 'commercial';
|
|
21
|
+
/** The verdict on a configured licence token, identical to the server's. */
|
|
22
|
+
export interface CommandLicenceVerdict {
|
|
23
|
+
readonly status: string;
|
|
24
|
+
readonly detail?: string;
|
|
25
|
+
readonly [key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
/** What this install may offer: the server's `Enablement`, unchanged. */
|
|
28
|
+
export interface CommandEnablement {
|
|
29
|
+
/** At least one optional module resolved and loaded. */
|
|
30
|
+
readonly installed: boolean;
|
|
31
|
+
/** A configured endpoint (`COGNIUM_ENDPOINT`), verbatim and opaque. */
|
|
32
|
+
readonly endpoint?: string;
|
|
33
|
+
readonly licence: CommandLicenceVerdict;
|
|
34
|
+
readonly state: CommandLicenceState;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A handle on the base's `circle-ir` analysis of a project (design §2).
|
|
38
|
+
*
|
|
39
|
+
* `project(root)` resolves to the result of `circle-ir`'s `analyzeProject`
|
|
40
|
+
* over the files the base would scan under `root` (same skip rules, same
|
|
41
|
+
* language detection), computed once per root per process and shared with
|
|
42
|
+
* any other command in the same run. A command whose operation accepts an
|
|
43
|
+
* injected analysis reads it instead of parsing again; one that does not yet
|
|
44
|
+
* parses as today, and says so in its module's `gaps` list.
|
|
45
|
+
*/
|
|
46
|
+
export interface CommandAnalysis {
|
|
47
|
+
/** The installed `circle-ir` version, e.g. `4.23.0`. */
|
|
48
|
+
readonly circleIrVersion: string;
|
|
49
|
+
/** Analyse (or reuse) the project under `root`. The value is circle-ir's `ProjectAnalysis`. */
|
|
50
|
+
project(root: string, opts?: {
|
|
51
|
+
readonly language?: string;
|
|
52
|
+
readonly excludeTests?: boolean;
|
|
53
|
+
}): Promise<unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface CommandContext {
|
|
56
|
+
readonly enablement: CommandEnablement;
|
|
57
|
+
readonly analysis: CommandAnalysis;
|
|
58
|
+
/** Directories commands may read, as real paths; `undefined` means unconfined (the CLI default). */
|
|
59
|
+
readonly allowedRoots?: readonly string[];
|
|
60
|
+
/** Exit codes of the CLI contract (spec §4), so module commands use the same ones. */
|
|
61
|
+
readonly exitCodes: {
|
|
62
|
+
/** Ran; nothing at or above `--severity`. */
|
|
63
|
+
readonly ok: 0;
|
|
64
|
+
/** Findings at or above `--severity`. */
|
|
65
|
+
readonly findings: 1;
|
|
66
|
+
/** Usage or config error. */
|
|
67
|
+
readonly usage: 2;
|
|
68
|
+
/** Analysis incomplete; only with `--fail-on-partial`. */
|
|
69
|
+
readonly partial: 3;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The subset of a commander `Command` a module may use. It is structural so a
|
|
74
|
+
* module can type against it without importing commander; at run time it is
|
|
75
|
+
* commander's own object (commander ^15).
|
|
76
|
+
*/
|
|
77
|
+
export interface CommandRegistrar {
|
|
78
|
+
command(nameAndArgs: string): CommandRegistrar;
|
|
79
|
+
description(text: string): CommandRegistrar;
|
|
80
|
+
option(flags: string, description?: string, defaultValue?: unknown): CommandRegistrar;
|
|
81
|
+
requiredOption(flags: string, description?: string, defaultValue?: unknown): CommandRegistrar;
|
|
82
|
+
alias(name: string): CommandRegistrar;
|
|
83
|
+
action(fn: (...args: any[]) => void | Promise<void>): CommandRegistrar;
|
|
84
|
+
}
|
|
85
|
+
export interface CommandModule {
|
|
86
|
+
/** Stable identifier, used in `version`, `doctor` and refusal lines. */
|
|
87
|
+
readonly id: string;
|
|
88
|
+
/** The module's own version. */
|
|
89
|
+
readonly version: string;
|
|
90
|
+
/** SPDX-style licence identifier of the module's terms. */
|
|
91
|
+
readonly licence: string;
|
|
92
|
+
/** The `circle-ir` it was built against, `major.minor` (a full version is accepted; only `major.minor` is compared). */
|
|
93
|
+
readonly circleIrRange: string;
|
|
94
|
+
/**
|
|
95
|
+
* The top-level command names this module registers. The CLI reserves them
|
|
96
|
+
* and, when the module is absent or refused, registers a stub per name that
|
|
97
|
+
* prints one refusal line and exits 2. Must match what `register` adds.
|
|
98
|
+
*/
|
|
99
|
+
readonly commands: readonly string[];
|
|
100
|
+
/** Optional: commands that parse again instead of reading `ctx.analysis` (design §2's recorded gap). */
|
|
101
|
+
readonly gaps?: readonly string[];
|
|
102
|
+
/** Register the commands on the root program. Called once, synchronously. */
|
|
103
|
+
register(program: CommandRegistrar, ctx: CommandContext): void;
|
|
104
|
+
/**
|
|
105
|
+
* Optional: the model-backed scan (`cognium scan --llm [--llm-verify]`,
|
|
106
|
+
* spec §3). The base declares `--llm` and `--llm-verify` on `scan` itself;
|
|
107
|
+
* when either is given, the CLI hands the whole run to `run` with the
|
|
108
|
+
* engine's option record (keys as typed, e.g. `format`, `severity`,
|
|
109
|
+
* `llm-verify`). With no module serving it, `--llm` prints one refusal line
|
|
110
|
+
* and exits 2. `run` sets `process.exitCode` by the contract's codes.
|
|
111
|
+
*/
|
|
112
|
+
readonly scanLlm?: {
|
|
113
|
+
run(path: string, options: Readonly<Record<string, string | boolean>>, ctx: CommandContext): Promise<void>;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The command names the plan's AI tier defines (spec §3). Used for refusal stubs when no module loads. */
|
|
117
|
+
export declare const AI_COMMANDS: readonly string[];
|
|
118
|
+
/** The default specifier the loader tries. `COGNIUM_CLI_MODULES` overrides it (`none` loads nothing). */
|
|
119
|
+
export declare const DEFAULT_COMMAND_MODULE_SPECIFIERS: readonly string[];
|
|
120
|
+
export declare const ENV_CLI_MODULES = "COGNIUM_CLI_MODULES";
|
|
121
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/command-module/contract.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AAEH,mEAAmE;AACnE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAEtE,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,+FAA+F;IAC/F,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjH;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACn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AAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,wGAAwG;IACxG,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/D;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE;QACjB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5G,CAAC;CACH;AAED,2GAA2G;AAC3G,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAUxC,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,iCAAiC,EAAE,SAAS,MAAM,EAAyB,CAAC;AACzF,eAAO,MAAM,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copied verbatim from cogniumhq/cognium-mcp packages/cli/src/module-contract.ts
|
|
3
|
+
* (branch one-cli/cognium-5, abccfd6). Structural on purpose: this package
|
|
4
|
+
* never imports from cognium. Keep the two in step; the test in
|
|
5
|
+
* tests/command-module/contract.test.ts pins the shape.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The command-module seam (one-CLI design §2).
|
|
9
|
+
*
|
|
10
|
+
* An optional package registers extra commands on the `cognium` CLI. The
|
|
11
|
+
* default specifier is `circle-ir-ai/cli` (PolyForm-NC). The seam mirrors the
|
|
12
|
+
* server's `ToolModule` (`@cognium/mcp-server` `modules.ts`): the same five
|
|
13
|
+
* fields, the same `major.minor` rule against the installed `circle-ir`, and
|
|
14
|
+
* the same enablement, so "which state am I in" has one answer on both doors.
|
|
15
|
+
*
|
|
16
|
+
* This file is the contract. It describes the seam structurally and imports
|
|
17
|
+
* nothing: a module implements it without depending on `cognium` or on
|
|
18
|
+
* commander. A module that is absent loads nothing; one that is present but
|
|
19
|
+
* wrong (shape, `circle-ir` minor, failed import) is refused with one line on
|
|
20
|
+
* stderr, and each AI command name then prints one refusal line naming the
|
|
21
|
+
* install. The CLI's base commands run either way.
|
|
22
|
+
*
|
|
23
|
+
* Contract version: 1 (cognium 5.0.0).
|
|
24
|
+
*/
|
|
25
|
+
/** The command names the plan's AI tier defines (spec §3). Used for refusal stubs when no module loads. */
|
|
26
|
+
export const AI_COMMANDS = [
|
|
27
|
+
'secrets',
|
|
28
|
+
'bom',
|
|
29
|
+
'understand',
|
|
30
|
+
'spec-diff',
|
|
31
|
+
'analyze-skill',
|
|
32
|
+
'quality',
|
|
33
|
+
'health',
|
|
34
|
+
'generate-spec',
|
|
35
|
+
'cluster',
|
|
36
|
+
];
|
|
37
|
+
/** The default specifier the loader tries. `COGNIUM_CLI_MODULES` overrides it (`none` loads nothing). */
|
|
38
|
+
export const DEFAULT_COMMAND_MODULE_SPECIFIERS = ['circle-ir-ai/cli'];
|
|
39
|
+
export const ENV_CLI_MODULES = 'COGNIUM_CLI_MODULES';
|
|
40
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/command-module/contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;;;;;;;;;;;;;;;;GAiBG;AAuGH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC5C,SAAS;IACT,KAAK;IACL,YAAY;IACZ,WAAW;IACX,eAAe;IACf,SAAS;IACT,QAAQ;IACR,eAAe;IACf,SAAS;CACV,CAAC;AAEF,yGAAyG;AACzG,MAAM,CAAC,MAAM,iCAAiC,GAAsB,CAAC,kBAAkB,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `quality` and `health` for the one CLI: findings only, no scores (one-CLI
|
|
3
|
+
* plan OC3, spec §3).
|
|
4
|
+
*
|
|
5
|
+
* Both commands run the same engine calls as cognium-ai's `quality` and
|
|
6
|
+
* `health` (`calculateQualityScore`, `calculateHealthScore`) and report what
|
|
7
|
+
* those calls found, never the composite. The score, tier, colour, weights
|
|
8
|
+
* and per-dimension scores are left out of every output format; `--threshold`
|
|
9
|
+
* is gone with them. A finding has one shape in both commands, so the home
|
|
10
|
+
* and the onboarding counts can read either.
|
|
11
|
+
*/
|
|
12
|
+
import { type QualityIssueSeverity } from '../quality/findings.js';
|
|
13
|
+
import type { CliArgs } from './legacy/args.js';
|
|
14
|
+
/** The one finding shape `quality` and `health` emit. */
|
|
15
|
+
export interface CodeFinding {
|
|
16
|
+
/** `q-` and 16 hex characters: stable across runs for the same rule, file, line and message. */
|
|
17
|
+
id: string;
|
|
18
|
+
/** circle-ir's category (reliability, performance, maintainability, architecture) or `quality` for a quality pass. */
|
|
19
|
+
category: string;
|
|
20
|
+
severity: QualityIssueSeverity;
|
|
21
|
+
/** Path relative to the analysed directory, `/`-separated. */
|
|
22
|
+
file: string;
|
|
23
|
+
line_start: number;
|
|
24
|
+
line_end?: number;
|
|
25
|
+
message: string;
|
|
26
|
+
rule_id: string;
|
|
27
|
+
/** Where it came from: `circle-ir`, or `quality:<pass>` for a quality pass. */
|
|
28
|
+
source: string;
|
|
29
|
+
/** circle-ir's CWE for the rule, for reference only. */
|
|
30
|
+
related_cwe?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface FindingsReport {
|
|
33
|
+
command: 'quality' | 'health';
|
|
34
|
+
directory: string;
|
|
35
|
+
findings: CodeFinding[];
|
|
36
|
+
summary: {
|
|
37
|
+
total: number;
|
|
38
|
+
bySeverity: Record<QualityIssueSeverity, number>;
|
|
39
|
+
byCategory: Record<string, number>;
|
|
40
|
+
};
|
|
41
|
+
meta: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
/** Findings at or above `floor`. */
|
|
44
|
+
export declare function atOrAbove(findings: readonly CodeFinding[], floor: QualityIssueSeverity): CodeFinding[];
|
|
45
|
+
/** Sort and de-duplicate by id. */
|
|
46
|
+
export declare function normaliseFindings(findings: readonly CodeFinding[]): CodeFinding[];
|
|
47
|
+
export declare function buildReport(command: 'quality' | 'health', directory: string, findings: CodeFinding[], meta: Record<string, unknown>): FindingsReport;
|
|
48
|
+
export declare function formatFindingsText(report: FindingsReport, limit?: number): string;
|
|
49
|
+
/** The findings of a quality result: circle-ir's issues and each quality pass's findings. */
|
|
50
|
+
export declare function qualityFindingsOf(root: string, result: unknown): CodeFinding[];
|
|
51
|
+
/** Write a findings report in the run's format. */
|
|
52
|
+
export declare function writeFindings(args: CliArgs, report: FindingsReport): void;
|
|
53
|
+
/** Exit code for a findings report (spec §4). */
|
|
54
|
+
export declare function exitForFindings(args: CliArgs, findings: readonly CodeFinding[]): number;
|
|
55
|
+
export declare function executeHealthFindings(args: CliArgs): Promise<number>;
|
|
56
|
+
//# sourceMappingURL=findings-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings-commands.d.ts","sourceRoot":"","sources":["../../src/command-module/findings-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,EAAoD,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGrH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKhD,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAC;IACX,sHAAsH;IACtH,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,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M,EAAE,cAAc,GAAG,IAAI,CAEzE;AAED,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAEvF;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B1E"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `quality` and `health` for the one CLI: findings only, no scores (one-CLI
|
|
3
|
+
* plan OC3, spec §3).
|
|
4
|
+
*
|
|
5
|
+
* Both commands run the same engine calls as cognium-ai's `quality` and
|
|
6
|
+
* `health` (`calculateQualityScore`, `calculateHealthScore`) and report what
|
|
7
|
+
* those calls found, never the composite. The score, tier, colour, weights
|
|
8
|
+
* and per-dimension scores are left out of every output format; `--threshold`
|
|
9
|
+
* is gone with them. A finding has one shape in both commands, so the home
|
|
10
|
+
* and the onboarding counts can read either.
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { calculateHealthScore, } from '../index.js';
|
|
15
|
+
import { toQualityIssues, qualityIssueId, qualitySeverity } from '../quality/findings.js';
|
|
16
|
+
import { getEffectiveOptions } from './legacy/effective-options.js';
|
|
17
|
+
import { resolveProjectProfileForEngine } from './legacy/project-profile.js';
|
|
18
|
+
import { applyIsolateParseEnv, buildInnerScanOptions } from './legacy/inner-scan-options.js';
|
|
19
|
+
const SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
|
|
20
|
+
/** Findings at or above `floor`. */
|
|
21
|
+
export function atOrAbove(findings, floor) {
|
|
22
|
+
return findings.filter((f) => SEVERITY_RANK[f.severity] >= SEVERITY_RANK[floor]);
|
|
23
|
+
}
|
|
24
|
+
function fromPassFindings(passFindings) {
|
|
25
|
+
const byFile = new Map();
|
|
26
|
+
for (const f of passFindings ?? [])
|
|
27
|
+
byFile.set(qualityIssueId(f), f);
|
|
28
|
+
return toQualityIssues(passFindings ?? []).map((q) => ({
|
|
29
|
+
id: q.id,
|
|
30
|
+
category: byFile.get(q.id)?.category ?? 'quality',
|
|
31
|
+
severity: q.severity,
|
|
32
|
+
file: q.file,
|
|
33
|
+
line_start: q.line_start,
|
|
34
|
+
...(q.line_end !== undefined ? { line_end: q.line_end } : {}),
|
|
35
|
+
message: q.description,
|
|
36
|
+
rule_id: q.rule_id,
|
|
37
|
+
source: 'circle-ir',
|
|
38
|
+
...(q.related_cwe ? { related_cwe: q.related_cwe } : {}),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
function relativeFile(root, file) {
|
|
42
|
+
const rel = path.isAbsolute(file) ? path.relative(root, file) : file;
|
|
43
|
+
return rel.split(path.sep).join('/');
|
|
44
|
+
}
|
|
45
|
+
function fromQualityPass(root, findings) {
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const f of findings) {
|
|
48
|
+
if (!f.location?.file)
|
|
49
|
+
continue; // a finding with no place is a score input, not a finding
|
|
50
|
+
const file = relativeFile(root, f.location.file);
|
|
51
|
+
const line = f.location.line ?? 1;
|
|
52
|
+
out.push({
|
|
53
|
+
id: qualityIssueId({ rule_id: `${f.pass}/${f.ruleId}`, file, line, message: f.message }),
|
|
54
|
+
category: 'quality',
|
|
55
|
+
severity: qualitySeverity(f.severity),
|
|
56
|
+
file,
|
|
57
|
+
line_start: line,
|
|
58
|
+
message: f.message,
|
|
59
|
+
rule_id: f.ruleId,
|
|
60
|
+
source: `quality:${f.pass}`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** Sort and de-duplicate by id. */
|
|
66
|
+
export function normaliseFindings(findings) {
|
|
67
|
+
const byId = new Map();
|
|
68
|
+
for (const f of findings)
|
|
69
|
+
if (!byId.has(f.id))
|
|
70
|
+
byId.set(f.id, f);
|
|
71
|
+
return [...byId.values()].sort((a, b) => SEVERITY_RANK[b.severity] - SEVERITY_RANK[a.severity] ||
|
|
72
|
+
a.file.localeCompare(b.file) ||
|
|
73
|
+
a.line_start - b.line_start ||
|
|
74
|
+
a.rule_id.localeCompare(b.rule_id));
|
|
75
|
+
}
|
|
76
|
+
export function buildReport(command, directory, findings, meta) {
|
|
77
|
+
const bySeverity = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
78
|
+
const byCategory = {};
|
|
79
|
+
for (const f of findings) {
|
|
80
|
+
bySeverity[f.severity] += 1;
|
|
81
|
+
byCategory[f.category] = (byCategory[f.category] ?? 0) + 1;
|
|
82
|
+
}
|
|
83
|
+
return { command, directory, findings, summary: { total: findings.length, bySeverity, byCategory }, meta };
|
|
84
|
+
}
|
|
85
|
+
export function formatFindingsText(report, limit = 50) {
|
|
86
|
+
const lines = [];
|
|
87
|
+
const s = report.summary;
|
|
88
|
+
lines.push(`${report.command}: ${s.total} finding(s) in ${report.directory}`);
|
|
89
|
+
lines.push(` critical ${s.bySeverity.critical} · high ${s.bySeverity.high} · medium ${s.bySeverity.medium} · low ${s.bySeverity.low} · info ${s.bySeverity.info}`);
|
|
90
|
+
for (const f of report.findings.slice(0, limit)) {
|
|
91
|
+
lines.push(` [${f.severity}] ${f.file}:${f.line_start} ${f.rule_id} ${f.message}`);
|
|
92
|
+
}
|
|
93
|
+
if (report.findings.length > limit) {
|
|
94
|
+
lines.push(` … ${report.findings.length - limit} more; use -f json -o ${report.command}.json for all of them`);
|
|
95
|
+
}
|
|
96
|
+
return lines.join('\n');
|
|
97
|
+
}
|
|
98
|
+
function write(args, report) {
|
|
99
|
+
const out = args.format === 'json' ? JSON.stringify(report, null, 2) : formatFindingsText(report);
|
|
100
|
+
if (args.output) {
|
|
101
|
+
fs.writeFileSync(args.output, out);
|
|
102
|
+
if (!args.quiet)
|
|
103
|
+
console.error(`Output written to ${args.output}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(out);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Exit code by the CLI contract (spec §4): 1 when `--severity` was given (or
|
|
111
|
+
* `-e`, with `high` as the floor) and a finding is at or above it; else 0.
|
|
112
|
+
*/
|
|
113
|
+
function exitFor(args, findings) {
|
|
114
|
+
const floor = (args.severity ?? (args.exitCode ? 'high' : null));
|
|
115
|
+
if (!floor)
|
|
116
|
+
return 0;
|
|
117
|
+
return atOrAbove(findings, floor).length > 0 ? 1 : 0;
|
|
118
|
+
}
|
|
119
|
+
/** The findings of a quality result: circle-ir's issues and each quality pass's findings. */
|
|
120
|
+
export function qualityFindingsOf(root, result) {
|
|
121
|
+
const r = result;
|
|
122
|
+
const fromCircleIr = (r.findings ?? []).map((q) => ({
|
|
123
|
+
id: q.id,
|
|
124
|
+
category: 'quality',
|
|
125
|
+
severity: q.severity,
|
|
126
|
+
file: q.file,
|
|
127
|
+
line_start: q.line_start,
|
|
128
|
+
...(q.line_end !== undefined ? { line_end: q.line_end } : {}),
|
|
129
|
+
message: q.description,
|
|
130
|
+
rule_id: q.rule_id,
|
|
131
|
+
source: 'circle-ir',
|
|
132
|
+
...(q.related_cwe ? { related_cwe: q.related_cwe } : {}),
|
|
133
|
+
}));
|
|
134
|
+
const fromPasses = (r.passResults ?? []).flatMap((p) => fromQualityPass(root, p.findings));
|
|
135
|
+
return normaliseFindings([...fromCircleIr, ...fromPasses]);
|
|
136
|
+
}
|
|
137
|
+
/** Write a findings report in the run's format. */
|
|
138
|
+
export function writeFindings(args, report) {
|
|
139
|
+
write(args, report);
|
|
140
|
+
}
|
|
141
|
+
/** Exit code for a findings report (spec §4). */
|
|
142
|
+
export function exitForFindings(args, findings) {
|
|
143
|
+
return exitFor(args, findings);
|
|
144
|
+
}
|
|
145
|
+
export async function executeHealthFindings(args) {
|
|
146
|
+
const targetPath = path.resolve(args.directory || process.cwd());
|
|
147
|
+
applyIsolateParseEnv(args);
|
|
148
|
+
if (!fs.existsSync(targetPath)) {
|
|
149
|
+
console.error(`Error: Path not found: ${targetPath}`);
|
|
150
|
+
return 2;
|
|
151
|
+
}
|
|
152
|
+
if (!args.quiet)
|
|
153
|
+
console.error(`Checking health findings in ${targetPath}...`);
|
|
154
|
+
const eff = getEffectiveOptions(args, targetPath);
|
|
155
|
+
const projectProfile = await resolveProjectProfileForEngine(targetPath, eff.profile);
|
|
156
|
+
const options = {
|
|
157
|
+
includeSecurity: args.healthSecurity,
|
|
158
|
+
includeSecrets: args.healthSecrets,
|
|
159
|
+
includeDeadCode: args.healthDeadCode,
|
|
160
|
+
includeQuality: args.healthQuality,
|
|
161
|
+
includePerformance: args.healthPerformance,
|
|
162
|
+
includePatterns: eff.include.length > 0 ? eff.include : undefined,
|
|
163
|
+
excludePatterns: eff.exclude.length > 0 ? eff.exclude : undefined,
|
|
164
|
+
scanOptions: buildInnerScanOptions(args, eff, projectProfile),
|
|
165
|
+
};
|
|
166
|
+
try {
|
|
167
|
+
const result = await calculateHealthScore(targetPath, options);
|
|
168
|
+
const findings = normaliseFindings(fromPassFindings(result.meta.passFindings));
|
|
169
|
+
const { passFindings: _pf, ...meta } = result.meta;
|
|
170
|
+
write(args, buildReport('health', targetPath, findings, meta));
|
|
171
|
+
return exitFor(args, findings);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
175
|
+
return 2;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=findings-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings-commands.js","sourceRoot":"","sources":["../../src/command-module/findings-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,oBAAoB,GAGrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAA6B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E,OAAO,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAC/E,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;QACnD,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAA+B,CAAC,CAAC,CAAC;QAC1F,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxE,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `circle-ir-ai/cli` — this library's commands as a module for the one CLI,
|
|
3
|
+
* `cognium` 5 (one-CLI plan, design §2; spec §3).
|
|
4
|
+
*
|
|
5
|
+
* The CLI looks for this entry when it starts and, if the package is
|
|
6
|
+
* installed and built against the same `circle-ir` minor, registers these
|
|
7
|
+
* commands next to its own. This package ships no binary and never imports
|
|
8
|
+
* the CLI: the module describes itself (contract.ts, a structural copy of the
|
|
9
|
+
* CLI's `module-contract.ts`) and registers handlers over this library's own
|
|
10
|
+
* functions.
|
|
11
|
+
*
|
|
12
|
+
* Licence states (design §3, OC5/OC6):
|
|
13
|
+
* - state 1 (`circle-ir-ai` installed): the deterministic commands run with no
|
|
14
|
+
* licence and no endpoint, under this package's non-commercial terms, with
|
|
15
|
+
* one notice on stderr the first time one runs;
|
|
16
|
+
* - model-backed paths (`--llm` on any command, and `cognium scan --llm`) run
|
|
17
|
+
* only when asked for by flag and only with an endpoint: `COGNIUM_ENDPOINT`
|
|
18
|
+
* (the CLI's enablement), `--llm-base-url` or `LLM_BASE_URL`, or a verified
|
|
19
|
+
* commercial licence. Without one they refuse with one line and exit 2.
|
|
20
|
+
*/
|
|
21
|
+
import type { CommandContext, CommandModule } from './contract.js';
|
|
22
|
+
import { type CommanderOpts } from './legacy/program.js';
|
|
23
|
+
/** `major.minor` of a version or range (`4.24.0`, `^4.24.0` → `4.24`). */
|
|
24
|
+
export declare function majorMinor(version: string): string | null;
|
|
25
|
+
/** True when both name the same `circle-ir` `major.minor`. */
|
|
26
|
+
export declare function sameCircleIrMinor(a: string, b: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a model may be called for this run: the CLI's endpoint or a
|
|
29
|
+
* commercial licence, or an endpoint the user named on this run.
|
|
30
|
+
*/
|
|
31
|
+
export declare function modelEndpointConfigured(ctx: Pick<CommandContext, 'enablement'>, opts?: {
|
|
32
|
+
llmBaseUrl?: string | null;
|
|
33
|
+
}, env?: NodeJS.ProcessEnv): boolean;
|
|
34
|
+
export declare const MODEL_REFUSAL: string;
|
|
35
|
+
/** The one state-1 notice, the first time a module command runs (OC6). */
|
|
36
|
+
export declare function stateNotice(ctx: Pick<CommandContext, 'enablement'>, quiet: boolean): void;
|
|
37
|
+
/** Test seam: forget that the notice was shown. */
|
|
38
|
+
export declare function __resetNotice(): void;
|
|
39
|
+
/** Engine option record (keys as typed, e.g. `llm-verify`) → commander-style camelCase opts. */
|
|
40
|
+
export declare function camelOpts(options: Readonly<Record<string, string | boolean>>): CommanderOpts;
|
|
41
|
+
export declare const commandModule: CommandModule;
|
|
42
|
+
export default commandModule;
|
|
43
|
+
export { COMMAND_NAMES } from './register.js';
|
|
44
|
+
export type { CommandContext, CommandModule, CommandRegistrar } from './contract.js';
|
|
45
|
+
export type { CodeFinding, FindingsReport } from './findings-commands.js';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index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