sneakoscope 4.2.1 → 4.4.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 (34) hide show
  1. package/README.md +7 -6
  2. package/crates/sks-core/Cargo.lock +1 -1
  3. package/crates/sks-core/Cargo.toml +1 -1
  4. package/crates/sks-core/src/main.rs +1 -1
  5. package/dist/bin/sks.js +1 -1
  6. package/dist/cli/command-registry.js +2 -1
  7. package/dist/cli/ultra-search-command.js +163 -0
  8. package/dist/cli/xai-command.js +28 -168
  9. package/dist/core/agents/agent-codex-cockpit.js +3 -3
  10. package/dist/core/agents/agent-wrongness.js +1 -1
  11. package/dist/core/fsx.js +1 -1
  12. package/dist/core/release-parallel-full-coverage.js +1 -1
  13. package/dist/core/routes.js +3 -2
  14. package/dist/core/source-intelligence/source-intelligence-policy.js +45 -26
  15. package/dist/core/source-intelligence/source-intelligence-proof.js +10 -16
  16. package/dist/core/source-intelligence/source-intelligence-runner.js +56 -42
  17. package/dist/core/trust-kernel/trust-report.js +3 -5
  18. package/dist/core/ultra-search/index.js +3 -0
  19. package/dist/core/ultra-search/runtime.js +502 -0
  20. package/dist/core/ultra-search/types.js +3 -0
  21. package/dist/core/version.js +1 -1
  22. package/dist/scripts/agent-visual-consistency-check.js +1 -1
  23. package/dist/scripts/release-metadata-1-19-check.js +2 -2
  24. package/dist/scripts/release-parallel-check.js +2 -2
  25. package/dist/scripts/release-parallel-full-coverage-check.js +1 -1
  26. package/dist/scripts/release-readiness-report.js +6 -6
  27. package/dist/scripts/sks-1-18-gate-lib.js +2 -2
  28. package/dist/scripts/source-intelligence-all-modes-check.js +9 -19
  29. package/dist/scripts/source-intelligence-policy-check.js +6 -6
  30. package/dist/scripts/ultra-search-provider-interface-check.js +27 -0
  31. package/package.json +2 -2
  32. package/dist/core/mcp/xai-mcp-detector.js +0 -157
  33. package/dist/core/mcp/xai-search-adapter.js +0 -100
  34. package/dist/scripts/xai-mcp-capability-check.js +0 -14
@@ -1,9 +1,13 @@
1
1
  import path from 'node:path';
2
2
  import { nowIso, writeJsonAtomic } from '../fsx.js';
3
- export const SOURCE_INTELLIGENCE_POLICY_SCHEMA = 'sks.source-intelligence-policy.v1';
3
+ export const SOURCE_INTELLIGENCE_POLICY_SCHEMA = 'sks.source-intelligence-policy.v2';
4
4
  export function buildSourceIntelligencePolicy(input = {}) {
5
5
  const route = input.route || 'unknown';
6
6
  const offline = input.offline === true;
7
+ const query = input.query || '';
8
+ const docsIntent = /\b(package|npm|SDK|API|MCP|framework|library|docs?|문서|React|Next\.js|Prisma|Tailwind)\b/i.test(query);
9
+ const xIntent = /\b(?:x\.com|twitter\.com|X\/Twitter|트위터|엑스|site:x\.com|site:twitter\.com)\b/i.test(query);
10
+ const urlIntent = /https?:\/\/[^\s)"']+/i.test(query);
7
11
  const context7Available = input.context7Available !== false;
8
12
  const codex = input.codexWebCapability || {
9
13
  schema: 'sks.codex-web-search-capability.v1',
@@ -11,43 +15,65 @@ export function buildSourceIntelligencePolicy(input = {}) {
11
15
  status: 'degraded_unverified',
12
16
  reason: 'capability_not_checked'
13
17
  };
14
- const xai = input.xaiDetection;
15
- const xaiSearchCapable = xai?.search_capable === true;
16
- const xaiConfigured = xai?.configured === true;
17
18
  const blockers = [];
18
19
  const warnings = [];
19
20
  const wrongnessKinds = [];
20
- if (!context7Available) {
21
+ if (docsIntent && !context7Available) {
21
22
  blockers.push('docs_context_missing');
22
23
  wrongnessKinds.push('context7_missing');
23
24
  }
24
25
  if (!offline && codex.status === 'unavailable') {
25
- warnings.push('codex_web_search_unavailable_degraded_to_context7_only');
26
+ warnings.push('codex_web_search_unavailable_degraded_to_ultra_cache_or_docs');
26
27
  wrongnessKinds.push('codex_web_search_missing');
27
28
  }
28
- if (xaiSearchCapable)
29
- warnings.push('xai_search_evidence_required_for_verified_current_claims');
30
- if (xaiConfigured && !xaiSearchCapable && xai?.configured_but_unverified)
31
- warnings.push('xai_mcp_configured_but_search_capability_unverified');
32
- const mode = !context7Available
29
+ if (input.xaiDetection)
30
+ warnings.push('xai_detection_input_ignored_by_source_intelligence_v2');
31
+ const mode = input.mode || (!context7Available && docsIntent
33
32
  ? 'blocked'
34
33
  : offline
35
- ? 'offline_context7_only'
36
- : xaiSearchCapable
37
- ? 'context7_codex_web_xai'
38
- : codex.status === 'unavailable'
39
- ? 'context7_only_degraded'
40
- : 'context7_codex_web';
34
+ ? 'offline_cache'
35
+ : urlIntent
36
+ ? 'url_acquisition'
37
+ : xIntent
38
+ ? 'x_search'
39
+ : /deep|exhaustive|가능한 전부|누락 없이|완벽하게 조사/i.test(query)
40
+ ? 'ultra_deep'
41
+ : 'ultra_balanced');
42
+ const selected = new Set();
43
+ if (docsIntent && context7Available)
44
+ selected.add('context7');
45
+ if (!offline && codex.status !== 'unavailable')
46
+ selected.add('codex_web');
47
+ if (xIntent || mode === 'x_search')
48
+ selected.add('x_public');
49
+ if (offline)
50
+ selected.add('offline_cache');
41
51
  return {
42
52
  schema: SOURCE_INTELLIGENCE_POLICY_SCHEMA,
43
53
  generated_at: nowIso(),
44
54
  ok: blockers.length === 0,
45
55
  route,
46
56
  mode,
57
+ requirements: {
58
+ official_sources: docsIntent,
59
+ full_content: mode !== 'ultra_fast',
60
+ counter_search: mode === 'ultra_deep' || mode === 'ultra_exhaustive',
61
+ claim_ledger: true,
62
+ social_recency: xIntent || mode === 'x_search',
63
+ code_execution_verification: /\b(code|implementation|test|runtime|구현)\b/i.test(query)
64
+ },
65
+ capabilities: {
66
+ docs: context7Available ? ['context7', 'official_web'] : ['official_web'],
67
+ web_search: !offline ? ['codex_web'] : [],
68
+ repo_search: ['github'],
69
+ social: xIntent || mode === 'x_search' ? ['x_public', 'authenticated_chrome_optional', 'official_x_api_optional'] : [],
70
+ browser: ['codex_browser_optional', 'codex_chrome_optional']
71
+ },
72
+ selected_providers: [...selected],
47
73
  context7: {
48
- required: true,
74
+ required: docsIntent,
49
75
  available: context7Available,
50
- status: context7Available ? (offline ? 'offline_only' : 'available') : 'missing'
76
+ status: docsIntent ? (context7Available ? (offline ? 'offline_only' : 'available') : 'missing') : 'not_required'
51
77
  },
52
78
  codex_web_search: {
53
79
  required: !offline,
@@ -55,13 +81,6 @@ export function buildSourceIntelligencePolicy(input = {}) {
55
81
  status: codex.status,
56
82
  reason: codex.reason
57
83
  },
58
- xai_mcp: {
59
- required: xaiSearchCapable,
60
- configured: xaiConfigured,
61
- search_capable: xaiSearchCapable,
62
- configured_but_unverified: xai?.configured_but_unverified === true,
63
- status: xai?.status || 'not_checked'
64
- },
65
84
  wrongness_kinds: wrongnessKinds,
66
85
  blockers,
67
86
  warnings
@@ -1,25 +1,21 @@
1
- export const SOURCE_INTELLIGENCE_PROOF_SCHEMA = 'sks.source-intelligence-proof.v1';
1
+ export const SOURCE_INTELLIGENCE_PROOF_SCHEMA = 'sks.source-intelligence-proof.v2';
2
2
  export function buildSourceIntelligenceProof(policy, evidence) {
3
3
  const blockers = [...policy.blockers];
4
4
  const wrongnessKinds = [...policy.wrongness_kinds];
5
- const context7Ok = evidence.context7?.ok === true;
6
- const codexWebOk = policy.codex_web_search.required ? evidence.codex_web_search?.ok === true : true;
7
- const xaiOk = policy.xai_mcp.required ? evidence.xai_search?.ok === true : true;
8
- const xaiMissingIsBlocker = policy.xai_mcp.required && !xaiOk;
5
+ const context7Ok = policy.context7.required ? evidence.context7?.ok === true : true;
6
+ const ultraOk = evidence.ultra_search?.proof.provider_independent === true && evidence.ultra_search?.proof.xai_runtime_dependency === false;
9
7
  const appshotsRequired = evidence.appshots?.capability.visual_required === true;
10
8
  const appshotsOk = appshotsRequired ? evidence.appshots?.ok === true : true;
11
9
  if (policy.context7.required && !context7Ok) {
12
10
  blockers.push('context7_missing');
13
11
  wrongnessKinds.push('context7_missing');
14
12
  }
15
- if (policy.codex_web_search.required && !codexWebOk && policy.mode !== 'context7_only_degraded') {
16
- blockers.push('codex_web_search_missing');
17
- wrongnessKinds.push('codex_web_search_missing');
18
- }
19
- if (policy.xai_mcp.required && !xaiOk) {
20
- blockers.push('xai_available_not_used');
21
- wrongnessKinds.push('xai_available_not_used');
13
+ if (!ultraOk) {
14
+ blockers.push('ultra_search_provider_independent_proof_missing');
15
+ wrongnessKinds.push('ultra_search_provider_independent_proof_missing');
22
16
  }
17
+ if (evidence.ultra_search?.proof.blockers.length)
18
+ blockers.push(...evidence.ultra_search.proof.blockers);
23
19
  if (appshotsRequired && !appshotsOk) {
24
20
  blockers.push('appshots_operator_action_missing');
25
21
  wrongnessKinds.push('appshots_operator_action_missing');
@@ -32,10 +28,8 @@ export function buildSourceIntelligenceProof(policy, evidence) {
32
28
  context7_required: policy.context7.required,
33
29
  context7_ok: context7Ok,
34
30
  codex_web_required: policy.codex_web_search.required,
35
- codex_web_ok: codexWebOk,
36
- xai_required: policy.xai_mcp.required,
37
- xai_ok: xaiOk,
38
- xai_missing_is_blocker: xaiMissingIsBlocker,
31
+ ultra_search_ok: ultraOk,
32
+ provider_independent: evidence.ultra_search?.proof.provider_independent === true,
39
33
  appshots_required: appshotsRequired,
40
34
  appshots_ok: appshotsOk
41
35
  },
@@ -1,18 +1,16 @@
1
1
  import path from 'node:path';
2
2
  import { ensureDir, nowIso, sha256, writeJsonAtomic, writeTextAtomic } from '../fsx.js';
3
- import { detectXaiMcp } from '../mcp/xai-mcp-detector.js';
4
- import { runXaiSearch } from '../mcp/xai-search-adapter.js';
5
- import { detectCodexWebSearchCapability, runCodexWebSearch } from '../codex/codex-web-search-adapter.js';
3
+ import { detectCodexWebSearchCapability } from '../codex/codex-web-search-adapter.js';
4
+ import { runUltraSearch } from '../ultra-search/index.js';
6
5
  import { buildSourceIntelligencePolicy, writeSourceIntelligencePolicyArtifact } from './source-intelligence-policy.js';
7
6
  import { buildSourceIntelligenceProof } from './source-intelligence-proof.js';
8
7
  import { buildAppshotsEvidence, writeAppshotsEvidenceArtifact } from './appshots-evidence.js';
9
- export const SOURCE_INTELLIGENCE_EVIDENCE_SCHEMA = 'sks.source-intelligence-evidence.v1';
8
+ export const SOURCE_INTELLIGENCE_EVIDENCE_SCHEMA = 'sks.source-intelligence-evidence.v2';
10
9
  export async function runSourceIntelligence(input) {
11
10
  const root = path.resolve(input.root || process.cwd());
12
11
  const missionDir = path.resolve(input.missionDir);
13
12
  const artifactDir = path.join(missionDir, 'source-intelligence');
14
13
  await ensureDir(artifactDir);
15
- const xaiDetection = input.xaiDetection || await detectXaiMcp({ root });
16
14
  const codexWebCapability = detectCodexWebSearchCapability({
17
15
  ...(input.env ? { env: input.env } : {}),
18
16
  ...(input.offline === undefined ? {} : { offline: input.offline })
@@ -22,28 +20,27 @@ export async function runSourceIntelligence(input) {
22
20
  ...(input.offline === undefined ? {} : { offline: input.offline }),
23
21
  ...(input.context7Available === undefined ? {} : { context7Available: input.context7Available }),
24
22
  codexWebCapability,
25
- xaiDetection
23
+ query: input.query,
24
+ ...(input.xaiDetection === undefined ? {} : { xaiDetection: input.xaiDetection })
25
+ });
26
+ const context7 = await runContext7(input.query, {
27
+ required: policy.context7.required,
28
+ available: policy.context7.available,
29
+ offline: input.offline === true,
30
+ ...(input.context7 ? { context7: input.context7 } : {})
31
+ });
32
+ const ultraMode = sourceModeToUltraMode(policy.mode);
33
+ const ultraSearch = await runUltraSearch({
34
+ root,
35
+ missionDir,
36
+ route: input.route || 'unknown',
37
+ query: input.query,
38
+ mode: ultraMode,
39
+ ...(input.offline === undefined ? {} : { offline: input.offline }),
40
+ ...(input.context7 ? { context7: input.context7 } : {}),
41
+ ...(input.codexWebSearch ? { codexWebSearch: input.codexWebSearch } : {}),
42
+ ...(input.env ? { env: input.env } : {})
26
43
  });
27
- const cacheKey = sha256(JSON.stringify({ route: input.route || 'unknown', query: input.query, mode: policy.mode })).slice(0, 16);
28
- const providerTasks = [
29
- runContext7(input.query, {
30
- available: policy.context7.available,
31
- offline: input.offline === true,
32
- ...(input.context7 ? { context7: input.context7 } : {})
33
- }),
34
- policy.codex_web_search.required ? runCodexWebSearch(input.query, {
35
- ...(input.codexWebSearch ? { search: input.codexWebSearch } : {}),
36
- artifactDir,
37
- ...(input.offline === undefined ? {} : { offline: input.offline }),
38
- ...(input.env ? { env: input.env } : {})
39
- }) : Promise.resolve(null),
40
- policy.xai_mcp.required ? runXaiSearch(input.query, {
41
- ...(input.xaiSearch ? { search: input.xaiSearch } : {}),
42
- artifactDir,
43
- configured: true
44
- }) : Promise.resolve(null)
45
- ];
46
- const [context7, codexWeb, xaiSearch] = await Promise.all(providerTasks);
47
44
  const appshots = buildAppshotsEvidence({
48
45
  root,
49
46
  prompt: input.query,
@@ -54,19 +51,17 @@ export async function runSourceIntelligence(input) {
54
51
  ...(input.appshots?.operatorActionRecorded === undefined ? {} : { operatorActionRecorded: input.appshots.operatorActionRecorded }),
55
52
  ...(input.appshots?.appshotsToolAvailable === undefined ? {} : { appshotsToolAvailable: input.appshots.appshotsToolAvailable })
56
53
  });
57
- const providersRequested = [
58
- 'context7',
59
- ...(policy.codex_web_search.required ? ['codex_web_search'] : []),
60
- ...(policy.xai_mcp.required ? ['xai_search'] : [])
61
- ];
54
+ const providersRequested = policy.selected_providers;
62
55
  const providersCompleted = [
63
- ...(context7.ok ? ['context7'] : []),
64
- ...(codexWeb?.ok ? ['codex_web_search'] : []),
65
- ...(xaiSearch?.ok ? ['xai_search'] : [])
56
+ ...(context7.ok && policy.context7.required ? ['context7'] : []),
57
+ ...(ultraSearch.sources.some((source) => source.provider_id === 'codex_web') ? ['codex_web'] : []),
58
+ ...(ultraSearch.sources.some((source) => source.provider_id === 'x_public') ? ['x_public'] : []),
59
+ 'ultra_search'
66
60
  ];
67
- const proof = buildSourceIntelligenceProof(policy, { context7, codex_web_search: codexWeb, xai_search: xaiSearch, appshots });
68
- const blockers = [...policy.blockers, ...context7.blockers, ...(codexWeb?.blockers || []), ...appshots.blockers, ...(proof.blockers || [])];
69
- const warnings = [...policy.warnings, ...(codexWeb?.warnings || []), ...appshots.warnings, ...(xaiSearch?.blockers || []).filter((blocker) => !blockers.includes(blocker))];
61
+ const proof = buildSourceIntelligenceProof(policy, { context7, ultra_search: ultraSearch, appshots });
62
+ const blockers = [...new Set([...policy.blockers, ...context7.blockers, ...appshots.blockers, ...proof.blockers])];
63
+ const warnings = [...new Set([...policy.warnings, ...ultraSearch.warnings, ...appshots.warnings])];
64
+ const cacheKey = sha256(JSON.stringify({ route: input.route || 'unknown', query: input.query, mode: policy.mode })).slice(0, 16);
70
65
  const evidence = {
71
66
  schema: SOURCE_INTELLIGENCE_EVIDENCE_SCHEMA,
72
67
  generated_at: nowIso(),
@@ -81,12 +76,13 @@ export async function runSourceIntelligence(input) {
81
76
  },
82
77
  cache: {
83
78
  key: cacheKey,
84
- local_only: true
79
+ local_only: true,
80
+ ultra_search_hit: ultraSearch.cache.hit
85
81
  },
86
82
  policy,
87
83
  context7,
88
- codex_web_search: codexWeb,
89
- xai_search: xaiSearch,
84
+ codex_web_search: null,
85
+ ultra_search: ultraSearch,
90
86
  appshots,
91
87
  proof,
92
88
  blockers,
@@ -106,15 +102,33 @@ export function renderSourceIntelligenceEvidenceMarkdown(evidence) {
106
102
  `- Route: ${evidence.route}`,
107
103
  `- Mode: ${evidence.mode}`,
108
104
  `- Context7: ${evidence.context7.status}`,
109
- `- Codex Web Search: ${evidence.codex_web_search?.status || 'not_required'}`,
110
- `- X AI Search: ${evidence.xai_search?.status || 'not_required'}`,
105
+ `- UltraSearch: ${evidence.ultra_search.proof.ok ? 'ok' : 'partial'}`,
106
+ `- Legacy x-search MCP: not_required`,
111
107
  `- Appshots: ${evidence.appshots?.status || 'not_required'}`,
112
108
  `- Providers completed: ${evidence.parallel.providers_completed.join(', ') || 'none'}`,
113
109
  `- Blockers: ${evidence.blockers.length ? evidence.blockers.join(', ') : 'none'}`,
114
110
  ''
115
111
  ].join('\n');
116
112
  }
113
+ function sourceModeToUltraMode(mode) {
114
+ if (mode === 'ultra_fast')
115
+ return 'fast';
116
+ if (mode === 'ultra_deep')
117
+ return 'deep';
118
+ if (mode === 'ultra_exhaustive')
119
+ return 'exhaustive';
120
+ if (mode === 'url_acquisition')
121
+ return 'url_acquisition';
122
+ if (mode === 'x_search')
123
+ return 'x_search';
124
+ if (mode === 'offline_cache')
125
+ return 'offline_cache';
126
+ return 'balanced';
127
+ }
117
128
  async function runContext7(query, opts) {
129
+ if (!opts.required) {
130
+ return { schema: 'sks.context7-source-evidence.v1', ok: true, status: 'not_required', query, result_count: 0, blockers: [] };
131
+ }
118
132
  if (opts.available === false) {
119
133
  return { schema: 'sks.context7-source-evidence.v1', ok: false, status: 'missing', query, result_count: 0, blockers: ['docs_context_missing'] };
120
134
  }
@@ -138,12 +138,10 @@ function sourceIntelligenceTrust(proof = {}) {
138
138
  return { issues: [], summary: { required: false, status: 'not_required' } };
139
139
  const proofBlockers = evidence.proof?.blockers || evidence.blockers || [];
140
140
  const issues = [...proofBlockers];
141
- if (evidence.policy?.xai_mcp?.required === true && evidence.xai_search?.ok !== true)
142
- issues.push('xai_available_not_used');
143
141
  if (evidence.policy?.context7?.required === true && evidence.context7?.ok !== true)
144
142
  issues.push('context7_missing');
145
- if (evidence.policy?.codex_web_search?.required === true && evidence.codex_web_search?.ok !== true && evidence.mode !== 'context7_only_degraded')
146
- issues.push('codex_web_search_missing');
143
+ if (evidence.policy?.codex_web_search?.required === true && evidence.ultra_search?.proof?.provider_independent !== true)
144
+ issues.push('ultra_search_provider_independent_proof_missing');
147
145
  return {
148
146
  issues: [...new Set(issues.map(String))],
149
147
  summary: {
@@ -153,7 +151,7 @@ function sourceIntelligenceTrust(proof = {}) {
153
151
  mode: evidence.mode || evidence.policy?.mode || 'unknown',
154
152
  context7_status: evidence.context7?.status || 'unknown',
155
153
  codex_web_status: evidence.codex_web_search?.status || 'not_required',
156
- xai_status: evidence.xai_search?.status || 'not_required',
154
+ ultra_search_status: evidence.ultra_search?.proof?.ok === true ? 'verified' : evidence.ultra_search ? 'partial' : 'not_required',
157
155
  providers_completed: evidence.parallel?.providers_completed || [],
158
156
  blockers: proofBlockers
159
157
  }
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './runtime.js';
3
+ //# sourceMappingURL=index.js.map