@haposoft/cafekit 0.18.2 → 0.18.4

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 (141) hide show
  1. package/README.md +1 -1
  2. package/bin/__tests__/adv-skill.test.js +370 -0
  3. package/bin/__tests__/agent-authority.test.js +38 -0
  4. package/bin/__tests__/agent-instructions.test.js +54 -0
  5. package/bin/__tests__/claude-plugin-build.test.js +151 -0
  6. package/bin/__tests__/codex-hook-runtime-fixture.cjs +26 -0
  7. package/bin/__tests__/codex-hooks-ownership.test.js +8 -11
  8. package/bin/__tests__/codex-hooks.test.js +87 -85
  9. package/bin/__tests__/codex-implicit-policy.test.js +160 -0
  10. package/bin/__tests__/codex-native-hook-boundaries.test.js +2 -4
  11. package/bin/__tests__/codex-native.test.js +136 -2298
  12. package/bin/__tests__/codex-plugin-build.test.js +230 -0
  13. package/bin/__tests__/codex-plugin-context.test.js +135 -0
  14. package/bin/__tests__/codex-plugin-hooks.test.js +220 -0
  15. package/bin/__tests__/codex-quiet-hooks.test.js +2 -8
  16. package/bin/__tests__/codex-runtime-layout.test.js +81 -0
  17. package/bin/__tests__/codex-setup-agents.test.js +216 -0
  18. package/bin/__tests__/codex-skill-projections.test.js +101 -0
  19. package/bin/__tests__/develop-contract.test.js +100 -874
  20. package/bin/__tests__/legacy-hooks-retired.test.js +63 -13
  21. package/bin/__tests__/migrate-apply.test.js +373 -0
  22. package/bin/__tests__/migrate-cli.test.js +152 -0
  23. package/bin/__tests__/migrate-merged.test.js +269 -0
  24. package/bin/__tests__/migrate-plan.test.js +271 -0
  25. package/bin/__tests__/omp-bridge.test.js +81 -5
  26. package/bin/__tests__/omp-hooks.test.js +24 -0
  27. package/bin/__tests__/orca-session.test.js +2 -16
  28. package/bin/__tests__/package-inventory.test.js +228 -2044
  29. package/bin/__tests__/plugin-safety-keys.test.js +121 -0
  30. package/bin/__tests__/privacy-paths.test.js +184 -0
  31. package/bin/__tests__/secret-scanner.test.js +73 -0
  32. package/bin/__tests__/skill-routing-source.test.js +6 -0
  33. package/bin/__tests__/toaa-skill.test.js +195 -0
  34. package/bin/__tests__/usage-hook-retired.test.js +24 -6
  35. package/bin/__tests__/validator-grounding.test.js +0 -198
  36. package/bin/__tests__/vibe-run.test.js +215 -0
  37. package/bin/__tests__/vibe-skill.test.js +548 -0
  38. package/bin/__tests__/website-docs.test.js +58 -0
  39. package/bin/install.js +99 -1
  40. package/bin/lib/backup.js +43 -24
  41. package/bin/lib/codex-install.js +12 -3
  42. package/bin/lib/context.js +5 -0
  43. package/bin/lib/lock.js +98 -18
  44. package/bin/lib/managed-writer.js +16 -10
  45. package/bin/lib/migrate-apply.js +202 -0
  46. package/bin/lib/migrate-merged.js +342 -0
  47. package/bin/lib/migrate-plan.js +419 -0
  48. package/bin/lib/plugin-inventory.js +33 -0
  49. package/bin/phases/claude-runtime.js +5 -3
  50. package/bin/phases/codex-hooks.js +38 -0
  51. package/bin/phases/codex-runtime.js +106 -74
  52. package/bin/phases/copy-payload.js +49 -1
  53. package/bin/phases/omp-runtime.js +4 -26
  54. package/bin/phases/root-config.js +5 -2
  55. package/package.json +1 -1
  56. package/src/claude/CLAUDE.md +1 -1
  57. package/src/claude/agents/advisor.md +55 -0
  58. package/src/claude/agents/debugger.md +2 -3
  59. package/src/claude/agents/deployer.md +2 -1
  60. package/src/claude/agents/docs-keeper.md +12 -0
  61. package/src/claude/agents/inspector.md +1 -1
  62. package/src/claude/agents/project-manager.md +2 -2
  63. package/src/claude/agents/researcher.md +0 -1
  64. package/src/claude/agents/spec-maker.md +4 -1
  65. package/src/claude/hooks/__tests__/plugin-context.test.js +96 -0
  66. package/src/claude/hooks/__tests__/plugin-options.test.js +141 -0
  67. package/src/claude/hooks/__tests__/plugin-state-isolation.test.js +125 -0
  68. package/src/claude/hooks/__tests__/precompact.test.js +7 -1
  69. package/src/claude/hooks/__tests__/privacy-block.test.js +33 -35
  70. package/src/claude/hooks/__tests__/setup-statusline.test.js +179 -0
  71. package/src/claude/hooks/__tests__/spec-gate.test.js +86 -48
  72. package/src/claude/hooks/__tests__/state.test.js +21 -0
  73. package/src/claude/hooks/agent.cjs +5 -2
  74. package/src/claude/hooks/inspect-block.cjs +3 -1
  75. package/src/claude/hooks/lib/hook-state-dir.cjs +19 -1
  76. package/src/claude/hooks/lib/plugin-options.cjs +47 -0
  77. package/src/claude/hooks/lib/privacy-command-analysis.cjs +130 -11
  78. package/src/claude/hooks/lib/privacy-paths.cjs +370 -10
  79. package/src/claude/hooks/lib/spec-touch.cjs +14 -1
  80. package/src/claude/hooks/plugin-context.cjs +80 -0
  81. package/src/claude/hooks/privacy-block.cjs +2 -1
  82. package/src/claude/hooks/rules.cjs +5 -2
  83. package/src/claude/hooks/session.cjs +4 -1
  84. package/src/claude/hooks/spec-state.cjs +5 -4
  85. package/src/claude/hooks/state.cjs +27 -1
  86. package/src/claude/migration-manifest.json +7 -1
  87. package/src/claude/plugin/commands/setup-statusline.md +12 -0
  88. package/src/claude/plugin/core.md +71 -0
  89. package/src/claude/rules/manage-docs.md +1 -2
  90. package/src/claude/rules/review-audit-self-decision.md +1 -1
  91. package/src/claude/rules/skill-workflow-routing.md +1 -1
  92. package/src/claude/rules/state-sync.md +14 -0
  93. package/src/claude/rules/workflow.md +1 -1
  94. package/src/claude/scripts/generate-skill-catalog.cjs +5 -0
  95. package/src/claude/scripts/provenance.cjs +40 -16
  96. package/src/claude/scripts/scan-staged-secrets.cjs +49 -3
  97. package/src/claude/scripts/setup-statusline.cjs +88 -0
  98. package/src/claude/skills/adv/SKILL.md +139 -0
  99. package/src/claude/skills/adv/references/optional-modes.md +41 -0
  100. package/src/claude/skills/adv/references/ultra-mode.md +29 -0
  101. package/src/claude/skills/brainstorm/SKILL.md +1 -1
  102. package/src/claude/skills/code-review/SKILL.md +4 -1
  103. package/src/claude/skills/code-review/references/pr-fix-reply.md +42 -0
  104. package/src/claude/skills/develop/SKILL.md +11 -3
  105. package/src/claude/skills/develop/references/quality-gate.md +1 -1
  106. package/src/claude/skills/fix/SKILL.md +2 -2
  107. package/src/claude/skills/git/SKILL.md +4 -2
  108. package/src/claude/skills/git/references/merge-pr.md +125 -0
  109. package/src/claude/skills/specs/SKILL.md +2 -2
  110. package/src/claude/skills/specs/references/review.md +1 -1
  111. package/src/claude/skills/specs/references/templates.md +2 -0
  112. package/src/claude/skills/sync/SKILL.md +4 -0
  113. package/src/claude/skills/toaa/SKILL.md +82 -0
  114. package/src/claude/skills/toaa/references/autonomous-orchestration.md +54 -0
  115. package/src/claude/skills/toaa/references/prerequisites-checklist.md +37 -0
  116. package/src/claude/skills/vibe/SKILL.md +69 -0
  117. package/src/claude/skills/vibe/references/pipeline-skill-integration.md +34 -0
  118. package/src/claude/skills/vibe/references/report-templates.md +84 -0
  119. package/src/claude/skills/vibe/references/subagent-orchestration.md +23 -0
  120. package/src/codex/AGENTS.md +1 -1
  121. package/src/codex/hooks/inspect-block.cjs +7 -4
  122. package/src/codex/hooks/lib/hook-context.cjs +119 -4
  123. package/src/codex/hooks/lib/plugin-options.cjs +2 -0
  124. package/src/codex/hooks/lib/privacy-state.cjs +18 -1
  125. package/src/codex/hooks/lib/state-store.cjs +31 -6
  126. package/src/codex/hooks/precompact.cjs +9 -8
  127. package/src/codex/hooks/privacy-approval.cjs +2 -2
  128. package/src/codex/hooks/privacy-block.cjs +5 -4
  129. package/src/codex/hooks/rules.cjs +12 -6
  130. package/src/codex/hooks/session.cjs +22 -10
  131. package/src/codex/plugin/core.md +76 -0
  132. package/src/codex/plugin/hooks/plugin-context.cjs +63 -0
  133. package/src/codex/plugin/skills/setup-agents/SKILL.md +17 -0
  134. package/src/codex/scripts/setup-agents.cjs +124 -0
  135. package/src/common/AGENTS.md +1 -1
  136. package/src/omp/extensions/{cafekit-bridge.mjs → cafekit-bridge.js} +73 -5
  137. package/src/omp/hooks/privacy-block.cjs +2 -1
  138. package/bin/__tests__/codex-research-projection.test.js +0 -70
  139. package/bin/__tests__/codex-specs-projection.test.js +0 -76
  140. package/bin/__tests__/specs-v2-execution-closeout.test.js +0 -58
  141. package/src/claude/skills/chrome-devtools/scripts/__tests__/error-handling.test.js +0 -102
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- const assert = require('node:assert/strict');
4
- const fs = require('node:fs');
5
- const path = require('node:path');
6
- const { test } = require('node:test');
7
- const { normalizeCodexBody, CODEX_SPECS_SCOPE_MARKER, CODEX_SPECS_SCOPE_NOTE,
8
- CODEX_RESEARCH_DEPTH_MARKER } = require('../lib/codex-install');
9
- const { splitFrontmatter } = require('../lib/codex-frontmatter');
10
-
11
- const SKILLS = path.resolve(__dirname, '../../src/claude/skills');
12
- const specsPath = path.join(SKILLS, 'specs/SKILL.md');
13
- const specs = fs.readFileSync(specsPath, 'utf8');
14
-
15
- function skillFiles(directory) {
16
- return fs.readdirSync(directory, { withFileTypes: true }).flatMap(entry => {
17
- const file = path.join(directory, entry.name);
18
- return entry.isDirectory() ? skillFiles(file) : entry.name === 'SKILL.md' ? [file] : [];
19
- });
20
- }
21
-
22
- function assertMarker() {
23
- assert.equal(typeof CODEX_SPECS_SCOPE_MARKER, 'string');
24
- assert.ok(CODEX_SPECS_SCOPE_MARKER.length > 0);
25
- }
26
-
27
- test('codex specs projection carries the scope note immediately after unchanged frontmatter', () => {
28
- assertMarker();
29
- assert.equal(typeof CODEX_SPECS_SCOPE_NOTE, 'string');
30
- const plain = normalizeCodexBody(specs);
31
- const projected = normalizeCodexBody(specs, specsPath);
32
- assert.match(projected, /^---\r?\n/);
33
- const before = splitFrontmatter(plain), after = splitFrontmatter(projected);
34
- assert.equal(after.frontmatter.name, 'cf-specs');
35
- assert.deepEqual(after.frontmatter, before.frontmatter);
36
- assert.equal(projected.slice(0, projected.length - after.body.length), plain.slice(0, plain.length - before.body.length));
37
- assert.equal(after.body, `\n${CODEX_SPECS_SCOPE_NOTE}\n\n${before.body}`);
38
- assert.equal(projected.split(CODEX_SPECS_SCOPE_MARKER).length - 1, 1);
39
- assert.equal(normalizeCodexBody(projected, specsPath), projected);
40
- assert.ok(CODEX_SPECS_SCOPE_NOTE.includes(CODEX_SPECS_SCOPE_MARKER));
41
- assert.match(CODEX_SPECS_SCOPE_MARKER, /GATE-SCOPE.*final answer/);
42
- assert.match(CODEX_SPECS_SCOPE_NOTE, /not in commentary or through `request_user_input`/);
43
- assert.match(CODEX_SPECS_SCOPE_NOTE, /Do not send a summary after/);
44
- assert.match(CODEX_SPECS_SCOPE_NOTE, /\[NEEDS CLARIFICATION: <question>\]/);
45
- assert.match(CODEX_SPECS_SCOPE_NOTE, /real question.*not a placeholder/);
46
- assert.match(CODEX_SPECS_SCOPE_NOTE, /EXPAND, KEEP, and CUT together/);
47
- assert.match(CODEX_SPECS_SCOPE_NOTE, /Preserve.*NEEDS CLARIFICATION.*EXPAND.*KEEP.*CUT.*do not translate/);
48
- assert.doesNotMatch(CODEX_SPECS_SCOPE_NOTE, /\b(?:Write|Edit|Read|Bash|WebSearch|WebFetch|AskUserQuestion)\b/);
49
- assert.doesNotMatch(CODEX_SPECS_SCOPE_NOTE, /customer|sales|notif|khách|bán hàng|thông báo/i);
50
- });
51
-
52
- test('specs marker is absent from every other skill and research retains exactly one depth marker', () => {
53
- assertMarker();
54
- const others = skillFiles(SKILLS).filter(file => file !== specsPath);
55
- for (const name of ['ask', 'research']) assert.ok(others.includes(path.join(SKILLS, name, 'SKILL.md')));
56
- for (const file of others) {
57
- const source = fs.readFileSync(file, 'utf8');
58
- const projected = normalizeCodexBody(source, file);
59
- assert.ok(!projected.includes(CODEX_SPECS_SCOPE_MARKER), file);
60
- if (file === path.join(SKILLS, 'research/SKILL.md')) {
61
- assert.equal(projected.split(CODEX_RESEARCH_DEPTH_MARKER).length - 1, 1);
62
- } else if (file !== path.join(SKILLS, 'ask/SKILL.md')) {
63
- assert.equal(projected, normalizeCodexBody(source), file);
64
- }
65
- }
66
- });
67
-
68
- test('specs note is scoped to the exact skill source path and supports Windows separators', () => {
69
- assertMarker();
70
- for (const sourcePath of ['', 'skills/specs/references/templates.md', 'other-skills/specs/SKILL.md']) {
71
- const projected = normalizeCodexBody(specs, sourcePath);
72
- assert.ok(!projected.includes(CODEX_SPECS_SCOPE_MARKER), sourcePath);
73
- assert.equal(projected, normalizeCodexBody(specs), sourcePath);
74
- }
75
- assert.ok(normalizeCodexBody(specs, 'C:\\project\\skills\\specs\\SKILL.md').includes(CODEX_SPECS_SCOPE_MARKER));
76
- });
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- const assert = require('node:assert/strict');
4
- const crypto = require('node:crypto');
5
- const fs = require('node:fs');
6
- const os = require('node:os');
7
- const path = require('node:path');
8
- const test = require('node:test');
9
-
10
- const TEMP_RUN_ID = String(process.env.CAFEKIT_CLOSEOUT_TEMP_RUN_ID || `${process.pid}-${Date.now()}`)
11
- .replace(/[^a-zA-Z0-9_-]/g, '-');
12
- const TEMP_PREFIX = `cafekit-v2-closeout-owned-${TEMP_RUN_ID}`;
13
-
14
- function withTempResources(callback) {
15
- const ownedPaths = [];
16
- const originalHome = Object.hasOwn(process.env, 'HOME')
17
- ? { present: true, value: process.env.HOME }
18
- : { present: false };
19
- function ownedDirectory(label) {
20
- const directory = fs.mkdtempSync(path.join(os.tmpdir(), `${TEMP_PREFIX}-${label}-`));
21
- ownedPaths.push(directory);
22
- return directory;
23
- }
24
- const resources = {
25
- directory: ownedDirectory,
26
- useHome(label) {
27
- const directory = ownedDirectory(label);
28
- process.env.HOME = directory;
29
- return directory;
30
- },
31
- };
32
- try {
33
- return callback(resources);
34
- } finally {
35
- if (originalHome.present) process.env.HOME = originalHome.value;
36
- else delete process.env.HOME;
37
- for (const ownedPath of ownedPaths.reverse()) {
38
- fs.rmSync(ownedPath, { recursive: true, force: true });
39
- }
40
- }
41
- }
42
-
43
- test('temp resource scope cleans exact owned paths and restores HOME after failure', () => {
44
- const originalHome = Object.hasOwn(process.env, 'HOME')
45
- ? { present: true, value: process.env.HOME }
46
- : { present: false };
47
- let root;
48
- let home;
49
- assert.throws(() => withTempResources((resources) => {
50
- root = resources.directory('failure-root');
51
- home = resources.useHome('failure-home');
52
- throw new Error('intentional resource-scope failure');
53
- }), /intentional resource-scope failure/);
54
- assert.equal(fs.existsSync(root), false);
55
- assert.equal(fs.existsSync(home), false);
56
- assert.equal(Object.hasOwn(process.env, 'HOME'), originalHome.present);
57
- if (originalHome.present) assert.equal(process.env.HOME, originalHome.value);
58
- });
@@ -1,102 +0,0 @@
1
- /**
2
- * Tests for error handling in chrome-devtools scripts
3
- * Verifies scripts exit with code 1 on errors
4
- * Run with: node --test __tests__/error-handling.test.js
5
- *
6
- * Note: These tests verify exit code behavior. When puppeteer is not installed,
7
- * scripts still exit with code 1 (module not found), which validates the error path.
8
- * When puppeteer IS installed, missing --url triggers application-level error with code 1.
9
- */
10
- import { describe, it } from 'node:test';
11
- import assert from 'node:assert';
12
- import { spawn } from 'node:child_process';
13
- import { fileURLToPath } from 'node:url';
14
- import path from 'node:path';
15
-
16
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
- const scriptsDir = path.join(__dirname, '..');
18
-
19
- function runScript(script, args = [], timeout = 10000) {
20
- return new Promise((resolve) => {
21
- const proc = spawn('node', [path.join(scriptsDir, script), ...args], {
22
- timeout,
23
- stdio: ['pipe', 'pipe', 'pipe']
24
- });
25
-
26
- let stdout = '';
27
- let stderr = '';
28
-
29
- proc.stdout.on('data', (data) => { stdout += data; });
30
- proc.stderr.on('data', (data) => { stderr += data; });
31
-
32
- proc.on('close', (code) => {
33
- resolve({ code, stdout, stderr, combined: stdout + stderr });
34
- });
35
-
36
- proc.on('error', (err) => {
37
- resolve({ code: 1, stdout, stderr: err.message, combined: err.message });
38
- });
39
-
40
- setTimeout(() => {
41
- proc.kill('SIGTERM');
42
- resolve({ code: null, stdout, stderr, timedOut: true, combined: stdout + stderr });
43
- }, timeout);
44
- });
45
- }
46
-
47
- describe('chrome-devtools error handling', () => {
48
- describe('console.js', () => {
49
- it('should exit with code 1 when --url is missing or on error', async () => {
50
- const result = await runScript('console.js', []);
51
- assert.strictEqual(result.code, 1, 'Expected exit code 1');
52
- });
53
-
54
- it('should output error information', async () => {
55
- const result = await runScript('console.js', []);
56
- assert.strictEqual(result.code, 1);
57
- // Either app-level error (--url required) or module error (puppeteer not found)
58
- const hasError = result.combined.toLowerCase().includes('error') ||
59
- result.combined.includes('--url');
60
- assert.ok(hasError, 'Expected error in output');
61
- });
62
- });
63
-
64
- describe('evaluate.js', () => {
65
- it('should exit with code 1 when --url is missing or on error', async () => {
66
- const result = await runScript('evaluate.js', []);
67
- assert.strictEqual(result.code, 1, 'Expected exit code 1');
68
- });
69
- });
70
-
71
- describe('navigate.js', () => {
72
- it('should exit with code 1 when --url is missing or on error', async () => {
73
- const result = await runScript('navigate.js', []);
74
- assert.strictEqual(result.code, 1, 'Expected exit code 1');
75
- });
76
- });
77
-
78
- describe('network.js', () => {
79
- it('should exit with code 1 when --url is missing or on error', async () => {
80
- const result = await runScript('network.js', []);
81
- assert.strictEqual(result.code, 1, 'Expected exit code 1');
82
- });
83
- });
84
-
85
- describe('performance.js', () => {
86
- it('should exit with code 1 when --url is missing or on error', async () => {
87
- const result = await runScript('performance.js', []);
88
- assert.strictEqual(result.code, 1, 'Expected exit code 1');
89
- });
90
- });
91
-
92
- describe('all scripts exit code consistency', () => {
93
- const scripts = ['console.js', 'evaluate.js', 'navigate.js', 'network.js', 'performance.js'];
94
-
95
- for (const script of scripts) {
96
- it(`${script} should exit 1 on invalid input or error`, async () => {
97
- const result = await runScript(script, []);
98
- assert.strictEqual(result.code, 1, `${script} should exit with code 1`);
99
- });
100
- }
101
- });
102
- });