@sockulags/agent-os 0.17.0 → 0.18.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/cli/index.mjs CHANGED
@@ -6,7 +6,7 @@ import fs from 'node:fs'
6
6
  import os from 'node:os'
7
7
  import path from 'node:path'
8
8
  import { createInterface } from 'node:readline'
9
- import { fileURLToPath, pathToFileURL } from 'node:url'
9
+ import { fileURLToPath } from 'node:url'
10
10
  import {
11
11
  HOOK_TIMEOUT_SECONDS,
12
12
  QUALITY_HOOK_MARKER
@@ -1189,7 +1189,18 @@ export async function run(argv = process.argv.slice(2), dependencies = {}) {
1189
1189
  return 0
1190
1190
  }
1191
1191
 
1192
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
1192
+ // npm and npx start the CLI through a bin symlink. Node resolves symlinks for import.meta.url but
1193
+ // leaves process.argv[1] as the symlink path, so compare real paths.
1194
+ function isMainModule() {
1195
+ if (!process.argv[1]) return false
1196
+ try {
1197
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url))
1198
+ } catch {
1199
+ return false
1200
+ }
1201
+ }
1202
+
1203
+ if (isMainModule()) {
1193
1204
  run().then((code) => {
1194
1205
  process.exitCode = code
1195
1206
  }).catch((error) => {
@@ -111,6 +111,16 @@ test('prints scoped npm commands and explains the direct default', async () => {
111
111
  assert.match(help, /--method <name>\s+direct \(default\) or plugin/)
112
112
  })
113
113
 
114
+ test('runs when invoked through a bin symlink as npm and npx do', { skip: process.platform === 'win32' }, () => {
115
+ const binDir = path.join(temporaryRoot(), 'node_modules', '.bin')
116
+ fs.mkdirSync(binDir, { recursive: true })
117
+ const bin = path.join(binDir, 'agent-os')
118
+ fs.symlinkSync(path.join(packageRootForTest(), 'cli', 'index.mjs'), bin)
119
+ const result = spawnSync(process.execPath, [bin, '--version'], { encoding: 'utf8' })
120
+ assert.equal(result.status, 0, result.stderr)
121
+ assert.equal(result.stdout.trim(), VERSION)
122
+ })
123
+
114
124
  test('rejects conflicting policy flags and direct local scope', async () => {
115
125
  assert.throws(() => parseArgs(['install', '--policy', '--no-policy']), /one of --policy and --no-policy/)
116
126
  await assert.rejects(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sockulags/agent-os",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "A lightweight agent operating system for Claude Code and Codex: agent-os-core for intent, planning, and evidence, and agent-os-dev for delivery, review, and guard hooks.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-os-core",
3
3
  "description": "Agent OS core: capture intent, plan decisions, explain plainly, keep scope, and prove claims. Useful for any agent work, not only code.",
4
- "version": "0.17.0",
4
+ "version": "0.18.0",
5
5
  "author": {
6
6
  "name": "Lucas Skog"
7
7
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-os-core",
3
3
  "description": "Agent OS core: capture intent, plan decisions, explain plainly, keep scope, and prove claims. Useful for any agent work, not only code.",
4
- "version": "0.17.0",
4
+ "version": "0.18.0",
5
5
  "homepage": "https://sockulags.github.io/agent-os/",
6
6
  "repository": "https://github.com/sockulags/agent-os",
7
7
  "keywords": [
@@ -53,7 +53,9 @@ Write `None` when nothing a person sees or does changes. Never delete.>
53
53
 
54
54
  ## Ground truth
55
55
 
56
- <The commands or observations that prove the outcome, such as `npm test -- export` or a named manual check.>
56
+ <The commands or observations that prove the outcome, such as `npm test -- export` or a named manual check.
57
+ Acceptance examples define the behavior, not the number of tests: name where they are proven, such as
58
+ one table-driven test, an end-to-end step, or an observation.>
57
59
 
58
60
  ## Open risks
59
61
 
@@ -24,7 +24,9 @@ Use the strongest practical layer:
24
24
  4. Static inspection only when execution is impossible and the limitation is explicit.
25
25
 
26
26
  Passing a weaker layer does not prove a stronger claim. Stale or second-hand results are context, not
27
- verification.
27
+ verification. When the strongest layer is unavailable, report that gap instead of compensating with
28
+ more unit tests at a weaker layer. A check that proves a claim does not have to become a committed
29
+ test; with agent-os-dev installed, proportional-testing decides what stays.
28
30
 
29
31
  When agent-os-dev is installed, a quality-ratchet Stop block saying the check is stale or a required
30
32
  check failed is this discipline enforced: rerun the check, or name the claim as unverified.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-os-dev",
3
3
  "description": "Agent OS development: shape plans, deliver against ground truth, review independently, and guard delivery with hooks. Requires agent-os-core.",
4
- "version": "0.17.0",
4
+ "version": "0.18.0",
5
5
  "author": {
6
6
  "name": "Lucas Skog"
7
7
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-os-dev",
3
3
  "description": "Agent OS development: shape plans, deliver against ground truth, review independently, and guard delivery with hooks. Requires agent-os-core.",
4
- "version": "0.17.0",
4
+ "version": "0.18.0",
5
5
  "homepage": "https://sockulags.github.io/agent-os/",
6
6
  "repository": "https://github.com/sockulags/agent-os",
7
7
  "keywords": [
@@ -4,7 +4,9 @@ A blocking finding needs a location, triggering condition, concrete consequence,
4
4
  the candidate fails a requirement or imposes a material maintenance cost. Security and data-loss
5
5
  risks need a credible path, not a production incident. Duplicated rules that can diverge or mixed
6
6
  responsibilities that make the requested behavior unsafe to change can justify simplification;
7
- line count, personal style, and an equally valid design alternative cannot.
7
+ line count, personal style, and an equally valid design alternative cannot. Tests are code to
8
+ maintain: changed behavior that nothing protects and a new test that `proportional-testing` would
9
+ not keep, such as one duplicating an existing case or asserting internal calls, are both findings.
8
10
 
9
11
  Separate required corrections from useful nonblocking follow-ups. Omit cosmetic preferences and
10
12
  speculative hardening. No findings is a valid result. Do not manufacture work to justify review.
@@ -17,12 +17,14 @@ Find the smallest supported explanation that accounts for the failure and predic
17
17
 
18
18
  Reproduce, reduce, trace the nearest seam, and compare plausible causes with high-information checks.
19
19
  Use temporary instrumentation when it helps. When the failure can be captured as an automated test,
20
- write that test first and confirm it fails for the diagnosed reason. In a delivery that commits, commit
21
- the failing test before the fix, and when agent-os-dev guards are installed run
22
- `guards.mjs lock-test <path>` from the quality-ratchet skill's `scripts/` so the test cannot be bent
23
- to fit the fix. Once evidence supports a cause, implement the smallest fix. Re-run the original
24
- failing path, then `guards.mjs unlock-test <path>`. Changing a locked test needs the developer's
25
- explicit agreement, because it changes what counts as fixed.
20
+ write that test first, as a case in the existing test for the same rule when one exists and in the
21
+ shape [proportional-testing](../proportional-testing/SKILL.md) keeps, and confirm it fails for the
22
+ diagnosed reason. In a delivery that commits, commit the failing test before the fix, and when
23
+ agent-os-dev guards are installed run `guards.mjs lock-test <path>` from the quality-ratchet skill's
24
+ `scripts/` so the test cannot be bent to fit the fix. Once evidence supports a cause, implement the
25
+ smallest fix. Re-run the original failing path, then `guards.mjs unlock-test <path>`. The lock
26
+ covers the whole file, so tidy other cases in it after unlocking. Changing a locked test needs the
27
+ developer's explicit agreement, because it changes what counts as fixed.
26
28
 
27
29
  If the failure cannot be reproduced or competing explanations cannot be distinguished, report the
28
30
  bounded uncertainty and the next discriminating check. Do not turn a plausible hypothesis into a
@@ -21,8 +21,10 @@ or public API compatibility, each with one sentence on why.>
21
21
 
22
22
  - **Blocking:** incorrect behavior, a missed acceptance example from the spec, a security or data
23
23
  loss risk, a broken public contract, or an edit to an accepted intent or spec.
24
- - **Should fix:** a defect with limited impact, a missing regression test for changed behavior, or
25
- complexity the change does not need.
24
+ - **Should fix:** a defect with limited impact; changed behavior that no existing test, type, or lint
25
+ rule protects; a new test that duplicates an existing one, asserts internal calls or module
26
+ structure instead of behavior, or copies setup a shared fixture already covers; or complexity the
27
+ change does not need.
26
28
  - **Minor:** naming, comments, or local readability. Report at most <three> minor findings per review.
27
29
 
28
30
  ## Out of scope for review
@@ -15,16 +15,27 @@ Before adding a test:
15
15
 
16
16
  1. Identify the observable behavior changed and its plausible blast radius.
17
17
  2. Search existing tests for that behavior and affected contracts.
18
- 3. Name the realistic regression the proposed test would catch that existing coverage would not.
18
+ 3. Name the realistic regression the proposed test would catch that existing tests, types, and lint
19
+ rules would not.
19
20
  4. If that regression is unclear, do not add the test.
20
21
  5. Otherwise extend existing or table-driven coverage when practical, using the cheapest test level
21
22
  that proves the behavior.
22
23
 
24
+ Decide whether a test is evidence for this change or a lasting guard. Commit it only when it protects
25
+ externally observable behavior and survives a behavior-preserving refactor: it mocks none of the
26
+ project's own modules, and it asserts call order or arguments only where that call is the contract at
27
+ a system boundary. Otherwise run it as evidence and do not commit it, or fold it into the existing
28
+ case for the same rule.
29
+
30
+ Leave a touched test file no worse than you found it. When you add a case, merge cases that test the
31
+ same rule into one table-driven test, name tests by the rule they protect rather than the issue that
32
+ added them, and remove assertions the new case makes redundant.
33
+
23
34
  For a confirmed bug, establish one reproducing regression check when practical, prove it fails for
24
35
  the expected reason, fix it, then run that check and relevant affected tests. Expand execution only
25
36
  when the blast radius is uncertain, shared infrastructure changed, or project policy requires a
26
37
  broader gate.
27
38
 
28
- Do not create a test for every function, branch, file, or generated code path. Prefer observable
29
- contracts over call sequences and private structure. This discipline controls test creation and
30
- development-time selection; it never removes required repository or CI checks at delivery.
39
+ Do not create a test for every function, branch, file, or generated code path. This discipline
40
+ controls test creation and development-time selection; it never removes required repository or CI
41
+ checks at delivery.
@@ -22,7 +22,7 @@ Existing coverage may already be sufficient.
22
22
  Test externally observable behavior and contracts. A behavior-preserving refactor should not force
23
23
  large test rewrites. Avoid tests whose main value is asserting internal calls, exact call sequences
24
24
  when ordering is not contractual, trivial delegation, getters, constructors, framework boilerplate,
25
- private structure, or mocks that reproduce the implementation.
25
+ private structure, mocks of the project's own modules, or mocks that reproduce the implementation.
26
26
 
27
27
  Before adding coverage, search for an existing behavioral test. Prefer extending it, adding a case
28
28
  to a table-driven test, and reusing its fixtures. One strong regression test is better than several
@@ -83,5 +83,5 @@ Coverage is adequate when the intended behavior is verified, plausible affected
83
83
  important justified edge cases have been considered, relevant existing tests pass, and the chosen
84
84
  test level is proportional to the risk.
85
85
 
86
- Before adding another test, ask: **What realistic regression would this catch that existing tests
87
- would not?** If there is no clear answer, do not add it.
86
+ Before adding another test, ask: **What realistic regression would this catch that existing tests,
87
+ types, and lint rules would not?** If there is no clear answer, do not add it.
@@ -25,7 +25,8 @@ independent-review, and verification steps still decide delivery.
25
25
  Use three zones:
26
26
 
27
27
  1. A bounded, behavior-preserving improvement on the implementation surface already being
28
- touched is allowed when it makes the requested change clearer or safer.
28
+ touched is allowed when it makes the requested change clearer or safer. A touched test file is
29
+ part of that surface; `proportional-testing` says what it keeps.
29
30
  2. Report at most one concrete adjacent structural opportunity when it materially constrains the
30
31
  requested change, but leave it out of the patch unless the boundary expands.
31
32
  3. Ignore unrelated debt. `scope-guard` owns drift; do not turn a ratchet signal into a cleanup
@@ -35,15 +36,15 @@ Extract a named responsibility when it makes the touched code easier to understa
35
36
  invariant, even with one caller. This is allowed local improvement, not automatic scope expansion.
36
37
  Do not force inheritance, shared utils, or extra layers merely to reduce file size.
37
38
 
38
- The check reports added, changed, and deleted source files, touched-source NLOC before/after, the
39
- before/after status of source paths that were already present at entry, package dependency deltas,
40
- and optional analyzer capability. When lizard is installed, it also reports cyclomatic complexity
41
- before and after for touched functions, ranked by increase. That value counts paths through a
42
- function, not readability; it is best effort, can miss functions in unusual formatting, and has
43
- before values only for files that were clean at entry. Raw file, function, line, or complexity
44
- counts are signals only. There is no aggregate score and no threshold gate unless the project sets
45
- one. Missing lizard is reported as unavailable rather than clean; jscpd is detected but not
46
- integrated into the delta. The core Node evidence remains usable without either.
39
+ The check reports added, changed, and deleted source files, test files included, touched-source NLOC
40
+ before/after, the before/after status of source paths that were already present at entry, package
41
+ dependency deltas, and optional analyzer capability. When lizard is installed, it also reports
42
+ cyclomatic complexity before and after for touched functions, ranked by increase. That value counts
43
+ paths through a function, not readability; it is best effort, can miss functions in unusual
44
+ formatting, and has before values only for files that were clean at entry. Raw file, function, line,
45
+ or complexity counts are signals only. There is no aggregate score and no threshold gate unless the
46
+ project sets one. Missing lizard is reported as unavailable rather than clean; jscpd is detected but
47
+ not integrated into the delta. The core Node evidence remains usable without either.
47
48
 
48
49
  Use existing project checks for enforceable rules and report structural signals as advisory.
49
50
  When configuring external checks, read [references/project-controls.md](references/project-controls.md).
@@ -77,12 +77,15 @@ Agent OS does not suppress pre-existing analyzer failures or equate tool success
77
77
 
78
78
  ## New exceptions and policy changes
79
79
 
80
- The runner reports new source lines matching `type-escape` (common `: any`/`as any` annotations and casts, TypeScript suppression comments),
81
- `lint-disable` (ESLint suppression and Java `@SuppressWarnings`), and `test-skip` (common test skips,
82
- focused tests, and Java `@Disabled`). It subtracts existing occurrences per file, ignoring simple
83
- line movement. These lexical signals can match comments or strings and can reappear on rename;
84
- they do not establish a semantic defect. Review them or delegate exact rules to the project's linter.
85
- Only rules explicitly listed in `blockSignals` block delivery. Raw LOC and structural counts never do.
80
+ The runner reports new source lines matching `type-escape` (common `: any`/`as any` annotations and
81
+ casts, TypeScript suppression comments), `lint-disable` (ESLint suppression and Java
82
+ `@SuppressWarnings`), `test-skip` (common test skips, focused tests, and Java `@Disabled`), and
83
+ `project-mock` (`vi.mock` or `jest.mock` of a relative path or an `@/`, `~/`, or `#/` alias, which
84
+ couples a test to the project's own module structure). It subtracts existing occurrences per file,
85
+ ignoring simple line movement. These lexical signals can match comments or strings and can reappear
86
+ on rename; they do not establish a semantic defect. Review them or delegate exact rules to the
87
+ project's linter. Only rules explicitly listed in `blockSignals` block delivery. Raw LOC and
88
+ structural counts never do.
86
89
 
87
90
  ## Complexity threshold
88
91
 
@@ -9,7 +9,8 @@ export const DEFAULT_TRUST_STORE = path.join(os.homedir(), '.agent-os', 'trusted
9
9
  const SIGNALS = {
10
10
  'type-escape': /@ts-(?:ignore|nocheck|expect-error)\b|:\s*any\b|\bas\s+any\b/,
11
11
  'lint-disable': /eslint-disable|@SuppressWarnings\b/,
12
- 'test-skip': /\b(?:it|test|describe)\s*\.\s*(?:skip|todo|only)\s*\(|\b[fx](?:it|describe)\s*\(|@Disabled\b/
12
+ 'test-skip': /\b(?:it|test|describe)\s*\.\s*(?:skip|todo|only)\s*\(|\b[fx](?:it|describe)\s*\(|@Disabled\b/,
13
+ 'project-mock': /\b(?:vi|jest)\s*\.\s*(?:mock|doMock)\s*\(\s*['"`](?:\.{1,2}\/|[@~#]\/)/
13
14
  }
14
15
  const hash = value => createHash('sha256').update(value).digest('hex')
15
16
  const identity = value => hash(JSON.stringify(value))
@@ -80,6 +80,26 @@ test('advisory failures and new exception signals do not gate delivery', t => {
80
80
  assert.deepEqual(hook(f.root), {})
81
81
  })
82
82
 
83
+ test('new mocks of project modules are advisory signals; package mocks are not', t => {
84
+ const f = fixture(t)
85
+ f.write('source.test.ts', "vi.mock('@/lib/db')\n")
86
+ begin(f.root, options)
87
+ f.write('source.test.ts', [
88
+ "vi.mock('@/lib/db')",
89
+ "vi.mock('@/lib/mail')",
90
+ "jest.mock('../store', () => ({}))",
91
+ 'vi.doMock("./clock")',
92
+ "vi.mock('@scope/package')",
93
+ "vi.mock('node:fs')"
94
+ ].join('\n'))
95
+ const result = check(f.root, options)
96
+ assert.equal(result.status, 'ok')
97
+ assert.deepEqual(result.sourceFiles.changed, ['source.test.ts'])
98
+ assert.deepEqual(result.controls.signals.map(s => [s.rule, s.line]),
99
+ [['project-mock', 2], ['project-mock', 3], ['project-mock', 4]])
100
+ assert.deepEqual(hook(f.root), {})
101
+ })
102
+
83
103
  test('an explicit project exception rule blocks only additions since entry', t => {
84
104
  const f = fixture(t, [], { blockSignals: ['test-skip'] })
85
105
  f.write('source.ts', "test.skip('old', () => {})")
@@ -39,6 +39,8 @@ where that is the true answer:
39
39
  every variation. A spec example shared between units states exactly this unit's part. A bare
40
40
  pointer such as "behaviors 1 to 3" is not acceptance.
41
41
  - **Ground truth:** the commands to run and the named cases or observations they must show.
42
+ Acceptance lines define the behavior, not the number of tests: several can be proven by one
43
+ table-driven test, an end-to-end step, or an observation.
42
44
  - **Dependencies:** for each dependency, what this unit consumes from it, in a line.
43
45
  - **Evidence and settled decisions:** only the decisions a worker could otherwise get wrong, one
44
46
  line each with its link. Do not retell the spec's decisions.