create-agent-rig 0.8.0 → 0.9.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 (52) hide show
  1. package/CHANGELOG.md +105 -1
  2. package/README.md +92 -3
  3. package/package.json +4 -3
  4. package/packages/cli/dist/commands/memory.js +123 -0
  5. package/packages/cli/dist/commands/setup.js +45 -0
  6. package/packages/cli/dist/index.js +107 -3
  7. package/packages/cli/dist/lib/subsystems.js +269 -0
  8. package/packages/cli/dist/lib/version.js +15 -0
  9. package/packages/cli/dist/policy/benchmark/corpus.js +165 -0
  10. package/packages/cli/dist/policy/core/coverage.js +253 -0
  11. package/packages/cli/dist/policy/core/decision-record.js +130 -44
  12. package/packages/cli/dist/policy/core/declaration.js +58 -17
  13. package/packages/cli/dist/policy/core/evidence-matrix.js +94 -0
  14. package/packages/cli/dist/policy/core/probe.js +442 -0
  15. package/packages/cli/dist/policy/core/validation.js +194 -1
  16. package/packages/cli/dist/policy/core/vocabulary.js +70 -3
  17. package/packages/cli/dist/policy/harness/claude.js +9 -1
  18. package/packages/cli/dist/policy/harness/codex.js +48 -1
  19. package/packages/cli/dist/policy/harness/shared-hooks.js +18 -0
  20. package/packages/cli/dist/policy/index.js +9 -2
  21. package/templates/agent-os/stack/aws-cdk/.claude/agents/cdk-diff-reviewer.md +2 -0
  22. package/templates/agent-os/stack/aws-cdk/.codex/agents/cdk-diff-reviewer.toml +2 -0
  23. package/templates/agent-os/subagent-routing.json +32 -0
  24. package/templates/agent-os/universal/.agents/skills/loop/SKILL.md +41 -4
  25. package/templates/agent-os/universal/.claude/agents/code-reviewer.md +2 -0
  26. package/templates/agent-os/universal/.claude/agents/prose-reviewer.md +2 -0
  27. package/templates/agent-os/universal/.claude/agents/security-scanner.md +2 -0
  28. package/templates/agent-os/universal/.claude/agents/test-writer.md +2 -0
  29. package/templates/agent-os/universal/.claude/hooks/guard-subagent-model.mjs +234 -0
  30. package/templates/agent-os/universal/.claude/hooks/lib/edit-input.mjs +75 -32
  31. package/templates/agent-os/universal/.claude/hooks/warn-subagent-routing.mjs +120 -0
  32. package/templates/agent-os/universal/.claude/rules/workflow.md +5 -0
  33. package/templates/agent-os/universal/.claude/scripts/preflight.mjs +27 -3
  34. package/templates/agent-os/universal/.claude/scripts/queue/gate-rounds.mjs +70 -2
  35. package/templates/agent-os/universal/.claude/scripts/queue/index.mjs +12 -4
  36. package/templates/agent-os/universal/.claude/scripts/unattended-flag.mjs +64 -1
  37. package/templates/agent-os/universal/.claude/settings.json +16 -0
  38. package/templates/agent-os/universal/.claude/skills/loop/SKILL.md +41 -4
  39. package/templates/agent-os/universal/.codex/agents/code-reviewer.toml +2 -0
  40. package/templates/agent-os/universal/.codex/agents/prose-reviewer.toml +2 -0
  41. package/templates/agent-os/universal/.codex/agents/security-scanner.toml +2 -0
  42. package/templates/agent-os/universal/.codex/agents/test-writer.toml +2 -0
  43. package/templates/agent-os/universal/.codex/config.toml +3 -0
  44. package/templates/agent-os/universal/docs/decisions/codex-adapter.md +31 -5
  45. package/templates/agent-os/universal/docs/decisions/subagent-routing.md +142 -0
  46. package/templates/agent-os/universal/layers.json +4 -0
  47. package/templates/hash-history.json +8 -4
  48. package/templates/release-ledger.json +2 -1
  49. package/templates/skeleton/node-service/services/api/test/artifact.test.ts +3 -4
  50. package/templates/skeleton/node-service/services/api/test/package-manager.test.ts +40 -0
  51. package/templates/skeleton/node-service/services/api/test/package-manager.ts +51 -0
  52. package/templates/skeleton/node-service/services/api/test/static-dir.test.ts +9 -8
@@ -0,0 +1,40 @@
1
+ import { mkdtemp, rm, writeFile } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import path from 'node:path';
4
+ import { afterEach, describe, expect, it } from 'vitest';
5
+
6
+ import { runPackageManager } from './package-manager.js';
7
+
8
+ const literalArgs = ['space value', '&|<>^%!()', 'single "double"', ''];
9
+
10
+ describe('package-manager transport for the artifact fallback', () => {
11
+ let work: string | undefined;
12
+
13
+ afterEach(async () => {
14
+ if (work !== undefined) await rm(work, { recursive: true, force: true });
15
+ });
16
+
17
+ it('honors the trusted current pnpm CLI on every platform with literal argv and preserves a failing child output', async () => {
18
+ work = await mkdtemp(path.join(tmpdir(), 'artifact-package-manager-'));
19
+ const cli = path.join(work, 'pnpm-cli.cjs');
20
+ await writeFile(
21
+ cli,
22
+ [
23
+ 'process.stdout.write(JSON.stringify(process.argv.slice(2)));',
24
+ "process.stderr.write('artifact transport stderr');",
25
+ 'process.exit(7);',
26
+ ].join(''),
27
+ );
28
+
29
+ const failure = await runPackageManager(literalArgs, {
30
+ cwd: work,
31
+ env: { ...process.env, npm_execpath: cli },
32
+ }).catch((error: unknown) => error);
33
+
34
+ expect(failure).toMatchObject({
35
+ code: 7,
36
+ stdout: JSON.stringify(literalArgs),
37
+ stderr: 'artifact transport stderr',
38
+ });
39
+ });
40
+ });
@@ -0,0 +1,51 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { promisify } from 'node:util';
5
+
6
+ const exec = promisify(execFile);
7
+
8
+ const currentPnpmCli = (environment: NodeJS.ProcessEnv): string | undefined => {
9
+ const currentCli = environment.npm_execpath;
10
+ if (currentCli && /^pnpm(?:-cli)?\.(?:cjs|js)$/i.test(path.basename(currentCli)) && existsSync(currentCli)) {
11
+ return currentCli;
12
+ }
13
+ return undefined;
14
+ };
15
+
16
+ const pnpmCli = (environment: NodeJS.ProcessEnv): string => {
17
+ const currentCli = currentPnpmCli(environment);
18
+ if (currentCli) return currentCli;
19
+
20
+ const installedCli = path.join(
21
+ path.dirname(process.execPath),
22
+ 'node_modules',
23
+ 'pnpm',
24
+ 'bin',
25
+ 'pnpm.cjs',
26
+ );
27
+ if (existsSync(installedCli)) return installedCli;
28
+
29
+ const corepackCli = path.join(
30
+ path.dirname(process.execPath),
31
+ 'node_modules',
32
+ 'corepack',
33
+ 'dist',
34
+ 'pnpm.js',
35
+ );
36
+ if (existsSync(corepackCli)) return corepackCli;
37
+
38
+ throw new Error('Cannot locate pnpm JavaScript CLI; npm_execpath must name the installed pnpm CLI');
39
+ };
40
+
41
+ /** Runs the workspace package manager without passing its arguments through a Windows shell. */
42
+ export const runPackageManager = (
43
+ args: string[],
44
+ options: Parameters<typeof exec>[2],
45
+ ): ReturnType<typeof exec> => {
46
+ const environment = options?.env ?? process.env;
47
+ const currentCli = currentPnpmCli(environment);
48
+ if (currentCli) return exec(process.execPath, [currentCli, ...args], options);
49
+ if (process.platform !== 'win32') return exec('pnpm', args, options);
50
+ return exec(process.execPath, [pnpmCli(environment), ...args], options);
51
+ };
@@ -1,26 +1,27 @@
1
1
  // The composition root resolves the built web bundle relative to itself; the
2
2
  // resolution is a pure function so it can be tested without importing main.ts.
3
3
  //
4
- // What is NOT pinned here: the Windows half of the same defect — the old
5
- // `new URL(url).pathname` yielded `/C:/…`. Both expressions are identical on a
6
- // POSIX runner, so observing the difference would mean passing a path flavour
7
- // into `defaultStaticDirFor`, i.e. a parameter that exists only for the test.
8
- // The decision was to leave that hook out; percent-decoding below is the same
9
- // bug's POSIX-visible half, and it fails against the old expression.
4
+ // This native absolute fixture exercises the platform root spelling and
5
+ // percent-decoding without injecting a path flavor into the production helper.
10
6
  import path from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
11
8
  import { describe, expect, it } from 'vitest';
12
9
  import { defaultStaticDirFor } from '../src/static-dir.js';
13
10
 
11
+ const moduleUrl = pathToFileURL(
12
+ path.join(path.parse(process.cwd()).root, 'a b', 'proj', 'services', 'api', 'src', 'main.ts'),
13
+ ).href;
14
+
14
15
  describe('resolving the default static dir from the module url', () => {
15
16
  it('decodes percent-escapes in the path (a directory may contain a space)', () => {
16
- const resolved = defaultStaticDirFor('file:///Users/a%20b/proj/services/api/src/main.ts');
17
+ const resolved = defaultStaticDirFor(moduleUrl);
17
18
 
18
19
  expect(resolved).toContain('a b');
19
20
  expect(resolved).not.toContain('%20');
20
21
  });
21
22
 
22
23
  it('points three levels up from services/api/src at apps/web/out', () => {
23
- const resolved = defaultStaticDirFor('file:///Users/a%20b/proj/services/api/src/main.ts');
24
+ const resolved = defaultStaticDirFor(moduleUrl);
24
25
 
25
26
  expect(resolved.endsWith(path.join('a b', 'proj', 'apps', 'web', 'out'))).toBe(true);
26
27
  expect(path.isAbsolute(resolved)).toBe(true);