@gajae-code/coding-agent 0.7.0 → 0.7.2

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 (101) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/types/cli/notify-cli.d.ts +2 -0
  3. package/dist/types/config/settings-schema.d.ts +39 -2
  4. package/dist/types/extensibility/shared-events.d.ts +1 -0
  5. package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
  6. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +1 -1
  7. package/dist/types/gjc-runtime/tmux-common.d.ts +3 -0
  8. package/dist/types/gjc-runtime/tmux-sessions.d.ts +2 -0
  9. package/dist/types/lsp/types.d.ts +2 -0
  10. package/dist/types/notifications/attachment-registry.d.ts +17 -0
  11. package/dist/types/notifications/chat-adapters.d.ts +9 -0
  12. package/dist/types/notifications/config.d.ts +9 -1
  13. package/dist/types/notifications/engine.d.ts +59 -0
  14. package/dist/types/notifications/managed-daemon.d.ts +48 -0
  15. package/dist/types/notifications/telegram-daemon.d.ts +19 -0
  16. package/dist/types/notifications/threaded-inbound.d.ts +19 -0
  17. package/dist/types/notifications/threaded-render.d.ts +6 -1
  18. package/dist/types/session/agent-session.d.ts +2 -0
  19. package/dist/types/tools/fetch.d.ts +23 -0
  20. package/dist/types/tools/index.d.ts +1 -0
  21. package/dist/types/tools/telegram-send.d.ts +32 -0
  22. package/dist/types/web/insane/bridge.d.ts +103 -0
  23. package/dist/types/web/insane/url-guard.d.ts +22 -0
  24. package/dist/types/web/search/provider.d.ts +18 -1
  25. package/dist/types/web/search/providers/insane.d.ts +53 -0
  26. package/dist/types/web/search/providers/text-citations.d.ts +23 -0
  27. package/dist/types/web/search/types.d.ts +12 -4
  28. package/package.json +10 -8
  29. package/scripts/verify-insane-vendor.ts +132 -0
  30. package/src/cli/args.ts +1 -1
  31. package/src/cli/fast-help.ts +1 -1
  32. package/src/cli/notify-cli.ts +152 -5
  33. package/src/cli.ts +1 -3
  34. package/src/commands/team.ts +1 -1
  35. package/src/config/settings-schema.ts +30 -1
  36. package/src/defaults/gjc/skills/ralplan/SKILL.md +11 -4
  37. package/src/edit/modes/replace.ts +1 -1
  38. package/src/extensibility/shared-events.ts +1 -0
  39. package/src/gjc-runtime/launch-tmux.ts +27 -5
  40. package/src/gjc-runtime/ledger-event-renderer.ts +1 -0
  41. package/src/gjc-runtime/ralplan-runtime.ts +2 -2
  42. package/src/gjc-runtime/tmux-common.ts +8 -0
  43. package/src/gjc-runtime/tmux-sessions.ts +8 -1
  44. package/src/gjc-runtime/workflow-manifest.generated.json +29 -0
  45. package/src/gjc-runtime/workflow-manifest.ts +7 -2
  46. package/src/hashline/hash.ts +1 -1
  47. package/src/internal-urls/docs-index.generated.ts +9 -8
  48. package/src/lsp/config.ts +16 -3
  49. package/src/lsp/defaults.json +7 -0
  50. package/src/lsp/types.ts +2 -0
  51. package/src/modes/controllers/event-controller.ts +15 -0
  52. package/src/modes/interactive-mode.ts +46 -2
  53. package/src/modes/utils/context-usage.ts +2 -2
  54. package/src/notifications/attachment-registry.ts +23 -0
  55. package/src/notifications/chat-adapters.ts +147 -0
  56. package/src/notifications/config.ts +23 -2
  57. package/src/notifications/engine.ts +100 -0
  58. package/src/notifications/index.ts +224 -45
  59. package/src/notifications/managed-daemon.ts +163 -0
  60. package/src/notifications/telegram-daemon.ts +235 -14
  61. package/src/notifications/threaded-inbound.ts +60 -4
  62. package/src/notifications/threaded-render.ts +20 -2
  63. package/src/session/agent-session.ts +82 -51
  64. package/src/tools/ask.ts +3 -2
  65. package/src/tools/fetch.ts +78 -1
  66. package/src/tools/index.ts +3 -0
  67. package/src/tools/telegram-send.ts +137 -0
  68. package/src/web/insane/bridge.ts +350 -0
  69. package/src/web/insane/url-guard.ts +155 -0
  70. package/src/web/search/provider.ts +77 -18
  71. package/src/web/search/providers/anthropic.ts +70 -3
  72. package/src/web/search/providers/codex.ts +1 -119
  73. package/src/web/search/providers/gemini.ts +99 -0
  74. package/src/web/search/providers/insane.ts +551 -0
  75. package/src/web/search/providers/openai-compatible.ts +66 -32
  76. package/src/web/search/providers/text-citations.ts +111 -0
  77. package/src/web/search/types.ts +13 -2
  78. package/vendor/insane-search/LICENSE +21 -0
  79. package/vendor/insane-search/MANIFEST.json +24 -0
  80. package/vendor/insane-search/engine/__init__.py +23 -0
  81. package/vendor/insane-search/engine/__main__.py +128 -0
  82. package/vendor/insane-search/engine/bias_check.py +183 -0
  83. package/vendor/insane-search/engine/executor.py +254 -0
  84. package/vendor/insane-search/engine/fetch_chain.py +725 -0
  85. package/vendor/insane-search/engine/learning.py +175 -0
  86. package/vendor/insane-search/engine/phase0.py +214 -0
  87. package/vendor/insane-search/engine/safety.py +91 -0
  88. package/vendor/insane-search/engine/templates/package.json +11 -0
  89. package/vendor/insane-search/engine/templates/playwright_mobile_chrome.js +188 -0
  90. package/vendor/insane-search/engine/templates/playwright_real_chrome.js +243 -0
  91. package/vendor/insane-search/engine/tests/test_hardening.py +57 -0
  92. package/vendor/insane-search/engine/tests/test_smoke.py +152 -0
  93. package/vendor/insane-search/engine/tests/test_u1.py +200 -0
  94. package/vendor/insane-search/engine/tests/test_u4.py +131 -0
  95. package/vendor/insane-search/engine/tests/test_u5.py +163 -0
  96. package/vendor/insane-search/engine/tests/test_u7.py +124 -0
  97. package/vendor/insane-search/engine/transport.py +211 -0
  98. package/vendor/insane-search/engine/url_transforms.py +98 -0
  99. package/vendor/insane-search/engine/validators.py +331 -0
  100. package/vendor/insane-search/engine/waf_detector.py +214 -0
  101. package/vendor/insane-search/engine/waf_profiles.yaml +162 -0
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Bridge from TypeScript to the vendored insane-search Python engine.
3
+ *
4
+ * Invokes `python3 -m engine "<url>" --json` per fallback attempt (cwd + PYTHONPATH
5
+ * pointed at the vendored engine), validates the JSON envelope, and maps it onto a
6
+ * discriminated result. Hardened: clamped timeout, AbortSignal propagation that
7
+ * kills+reaps the child, bounded stdout/stderr capture, and a per-process
8
+ * concurrency cap so blocked reads cannot fork-storm.
9
+ *
10
+ * Fail-closed: missing dependencies / bad output / auth-required never throw past
11
+ * the caller and never auto-install anything; they return ok:false with a stable,
12
+ * bounded note so `read` can continue with its normal degraded result.
13
+ */
14
+ import { spawn as nodeSpawn } from "node:child_process";
15
+ /** packages/coding-agent/vendor/insane-search */
16
+ export declare const INSANE_VENDOR_DIR: string;
17
+ /** Stable note prefixes — tests assert on these without depending on full stderr. */
18
+ export declare const INSANE_NOTES: {
19
+ readonly guardBlocked: (reason: string) => string;
20
+ readonly vendorMissing: `insane fallback unavailable: vendor engine missing at packages/coding-agent/vendor/insane-search`;
21
+ readonly noPython: `insane fallback unavailable: python3 not found; install python3 and curl_cffi, then retry with web.insaneFallback=true`;
22
+ readonly noCurlCffi: `insane fallback unavailable: python3 cannot import curl_cffi; install curl_cffi for Phase 0-2`;
23
+ readonly noBrowser: `insane fallback unavailable: node/playwright/stealth dependencies missing for Phase 3; install dependencies under packages/coding-agent/vendor/insane-search/engine/templates`;
24
+ readonly timeout: (seconds: number) => string;
25
+ readonly invalidJson: `insane fallback failed: engine returned invalid JSON`;
26
+ readonly authRequired: `insane fallback stopped: authentication required`;
27
+ readonly verdict: (verdict: string) => string;
28
+ readonly untried: (routes: string) => string;
29
+ readonly mustBrowserMcp: `insane fallback requires browser MCP/manual phase: must_invoke_playwright_mcp=true`;
30
+ readonly concurrency: `insane fallback skipped: max concurrent engine attempts reached`;
31
+ readonly emptyContent: `insane fallback failed: engine reported ok but returned no content`;
32
+ };
33
+ /** Raw JSON envelope produced by `python3 -m engine --json`. */
34
+ export interface InsaneFetchResultRaw {
35
+ ok?: boolean;
36
+ verdict?: string;
37
+ content?: string;
38
+ profile_used?: string;
39
+ trace?: unknown;
40
+ untried_routes?: string[];
41
+ must_invoke_playwright_mcp?: boolean;
42
+ }
43
+ export interface InsaneSuccess {
44
+ ok: true;
45
+ content: string;
46
+ profileUsed?: string;
47
+ notes: string[];
48
+ }
49
+ export interface InsaneFailure {
50
+ ok: false;
51
+ reason: string;
52
+ verdict?: string;
53
+ notes: string[];
54
+ }
55
+ export type InsaneBridgeResult = InsaneSuccess | InsaneFailure;
56
+ export interface EngineInvocation {
57
+ url: string;
58
+ timeoutMs: number;
59
+ signal?: AbortSignal;
60
+ }
61
+ export interface EngineRawOutput {
62
+ code: number | null;
63
+ stdout: string;
64
+ stderr: string;
65
+ timedOut: boolean;
66
+ aborted: boolean;
67
+ }
68
+ /** Seam: run the engine subprocess. Default spawns python3. */
69
+ export type EngineRunner = (inv: EngineInvocation) => Promise<EngineRawOutput>;
70
+ export interface InsaneDependencyStatus {
71
+ vendorPresent: boolean;
72
+ python: boolean;
73
+ curlCffi: boolean;
74
+ browser: boolean;
75
+ }
76
+ /** Seam: probe dependencies. Default probes the real environment (cached). */
77
+ export type DependencyProber = () => Promise<InsaneDependencyStatus>;
78
+ type SpawnImpl = typeof nodeSpawn;
79
+ /** Real engine runner: `python3 -m engine "<url>" --json`. */
80
+ export declare function runEngineSubprocess(inv: EngineInvocation, options?: {
81
+ spawnImpl?: SpawnImpl;
82
+ }): Promise<EngineRawOutput>;
83
+ /** Reset the probe cache between tests so probe state never leaks. */
84
+ export declare function resetInsaneProbeCacheForTest(): void;
85
+ /** Probe (and cache) the insane-search runtime dependencies. */
86
+ export declare function probeInsaneDependencies(): Promise<InsaneDependencyStatus>;
87
+ export declare function resetInsaneConcurrencyForTest(): void;
88
+ export interface TryInsaneFetchOptions {
89
+ timeoutMs?: number;
90
+ signal?: AbortSignal;
91
+ concurrencyLimit?: number;
92
+ /** Seam: dependency prober (default real, cached). */
93
+ prober?: DependencyProber;
94
+ /** Seam: engine runner (default real subprocess). */
95
+ runner?: EngineRunner;
96
+ }
97
+ /**
98
+ * Attempt to read `url` through the insane-search engine. The caller is
99
+ * responsible for the opt-in gate, raw-mode skip, and the public-URL guard
100
+ * (which MUST run before this is called). Never throws; always returns a result.
101
+ */
102
+ export declare function tryInsaneFetch(url: string, options?: TryInsaneFetchOptions): Promise<InsaneBridgeResult>;
103
+ export {};
@@ -0,0 +1,22 @@
1
+ export interface PublicUrlAccepted {
2
+ ok: true;
3
+ url: URL;
4
+ addresses: string[];
5
+ }
6
+ export interface PublicUrlRejected {
7
+ ok: false;
8
+ reason: string;
9
+ }
10
+ export type PublicUrlResult = PublicUrlAccepted | PublicUrlRejected;
11
+ /** Resolver seam so tests can inject DNS results without real lookups. */
12
+ export type AddressResolver = (hostname: string) => Promise<string[]>;
13
+ /** True for any address that is not a routable public unicast address. */
14
+ export declare function isPrivateOrSpecialAddress(address: string): boolean;
15
+ /**
16
+ * Validate that `rawUrl` is a public http/https target safe to hand to the
17
+ * insane-search engine. Resolves DNS names and rejects any that map to a
18
+ * private/special address. Never throws; returns a discriminated result.
19
+ */
20
+ export declare function validatePublicHttpUrlForInsane(rawUrl: string, options?: {
21
+ resolver?: AddressResolver;
22
+ }): Promise<PublicUrlResult>;
@@ -20,5 +20,22 @@ export declare function looksHostedModelId(modelId: string | undefined): boolean
20
20
  export declare function isLocalBaseUrl(baseUrl: string | undefined): boolean;
21
21
  export declare function inferNativeProviderFromModel(ctx: ActiveSearchModelContext | undefined): SearchProviderId | undefined;
22
22
  export declare function canUseGenericCredentials(authStorage: AuthStorage, ctx: ActiveSearchModelContext | undefined, sessionId?: string, signal?: AbortSignal): Promise<boolean>;
23
- export declare function shouldTryGenericOpenAICompat(authStorage: AuthStorage, ctx: ActiveSearchModelContext | undefined, sessionId?: string, signal?: AbortSignal): Promise<boolean>;
23
+ /**
24
+ * Native web-search provider to attempt by reusing the ACTIVE model's own
25
+ * credentials + baseUrl, dispatched by the model's wire protocol.
26
+ *
27
+ * This is the "native search over a proxy" path: when a model is served through
28
+ * a proxy/custom endpoint, its canonical search credentials (e.g. a dedicated
29
+ * `anthropic` key, or ChatGPT OAuth for `codex`) are usually absent, but the
30
+ * credential that authenticates the model itself — stored under the active
31
+ * provider id and aimed at `ctx.baseUrl` — can drive native web search just as
32
+ * well. Each provider's `search()` falls back to those active credentials when
33
+ * its canonical ones are missing.
34
+ *
35
+ * Returned ids are matched purely from the wire `api` (+ model-id family where a
36
+ * native tool only makes sense for that family); the providers themselves fail
37
+ * closed (and the chain falls through to DuckDuckGo) if the endpoint does not
38
+ * actually support web search.
39
+ */
40
+ export declare function activeContextNativeId(ctx: ActiveSearchModelContext | undefined): SearchProviderId | undefined;
24
41
  export declare function resolveProviderChain(options: ResolveProviderChainOptions): Promise<SearchProvider[]>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Insane Search Provider
3
+ *
4
+ * Native TypeScript, fail-closed adaptation of the MIT-licensed upstream
5
+ * fivetaku/insane-search public-route strategy. This ports only safe Phase 0
6
+ * concepts: deterministic no-auth public endpoints plus route-attempt tracing.
7
+ *
8
+ * Deliberately excluded from upstream: TLS impersonation, browser/cookie warming,
9
+ * CAPTCHA/paywall/login bypasses, credential storage, Playwright automation, and
10
+ * auto dependency installation. Unsupported or terminal auth/paywall/block states
11
+ * throw instead of pretending a shallow fetch succeeded.
12
+ */
13
+ import type { AuthStorage } from "@gajae-code/ai";
14
+ import type { SearchResponse, SearchSource } from "../../../web/search/types";
15
+ import type { SearchParams } from "./base";
16
+ import { SearchProvider } from "./base";
17
+ export interface InsaneRouteAttempt {
18
+ platform: InsanePlatform;
19
+ route: string;
20
+ ok: boolean;
21
+ status: number;
22
+ bytes: number;
23
+ note?: string;
24
+ }
25
+ type InsanePlatform = "reddit" | "x" | "youtube" | "hackernews";
26
+ interface RouteSuccess {
27
+ platform: InsanePlatform;
28
+ route: string;
29
+ finalUrl: string;
30
+ sources: SearchSource[];
31
+ attempts: InsaneRouteAttempt[];
32
+ }
33
+ interface RouteFailure {
34
+ platform: InsanePlatform;
35
+ attempts: InsaneRouteAttempt[];
36
+ }
37
+ type RouteResult = RouteSuccess | RouteFailure | null;
38
+ export declare function routeInsanePublicUrl(rawUrl: string, signal?: AbortSignal): Promise<RouteResult>;
39
+ /** Execute safe Insane Search public-route discovery. */
40
+ export declare function searchInsane(params: {
41
+ query: string;
42
+ num_results?: number;
43
+ recency?: "day" | "week" | "month" | "year";
44
+ signal?: AbortSignal;
45
+ }): Promise<SearchResponse>;
46
+ /** Keyless provider that ports safe upstream public-route fallbacks only. */
47
+ export declare class InsaneProvider extends SearchProvider {
48
+ readonly id = "insane";
49
+ readonly label = "Insane";
50
+ isAvailable(_authStorage: AuthStorage): boolean;
51
+ search(params: SearchParams): Promise<SearchResponse>;
52
+ }
53
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Inline citation extraction shared by native web-search providers.
3
+ *
4
+ * Web-search-capable models sometimes return a genuinely grounded answer whose
5
+ * sources are written inline (markdown links or bare URLs) instead of as
6
+ * structured citation annotations. When a provider has independent proof that a
7
+ * web search actually ran, these helpers recover sources from the answer text so
8
+ * the result is not discarded.
9
+ */
10
+ import type { SearchSource } from "../types";
11
+ /** Append a source, de-duplicating by URL. */
12
+ export declare function addSource(sources: SearchSource[], source: SearchSource): void;
13
+ /**
14
+ * Strips prose punctuation and unmatched closing delimiters from extracted URLs.
15
+ * Models often return links embedded in markdown or sentence text.
16
+ */
17
+ export declare function normalizeExtractedUrl(candidate: string): string | null;
18
+ /**
19
+ * Extracts citation sources from markdown links and bare URLs in answer text.
20
+ * Used only as a fallback when a provider confirms a search ran but omits
21
+ * structured citation annotations.
22
+ */
23
+ export declare function extractTextSources(text: string): SearchSource[];
@@ -4,7 +4,7 @@
4
4
  * Unified types for web search responses across supported providers.
5
5
  */
6
6
  /** Supported web search providers */
7
- export type SearchProviderId = "duckduckgo" | "exa" | "brave" | "jina" | "kimi" | "zai" | "anthropic" | "perplexity" | "gemini" | "codex" | "xai" | "tavily" | "parallel" | "kagi" | "synthetic" | "searxng" | "openai-compatible";
7
+ export type SearchProviderId = "duckduckgo" | "insane" | "exa" | "brave" | "jina" | "kimi" | "zai" | "anthropic" | "perplexity" | "gemini" | "codex" | "xai" | "tavily" | "parallel" | "kagi" | "synthetic" | "searxng" | "openai-compatible";
8
8
  export type WebSearchMode = "on" | "off" | "auto";
9
9
  export interface ActiveSearchModelContext {
10
10
  provider: string;
@@ -15,7 +15,7 @@ export interface ActiveSearchModelContext {
15
15
  headers?: Record<string, string>;
16
16
  webSearch?: WebSearchMode;
17
17
  }
18
- export declare const CONFIGURABLE_SEARCH_PROVIDER_IDS: readonly ["duckduckgo", "exa", "brave", "jina", "kimi", "zai", "anthropic", "perplexity", "gemini", "codex", "xai", "tavily", "parallel", "kagi", "synthetic", "searxng"];
18
+ export declare const CONFIGURABLE_SEARCH_PROVIDER_IDS: readonly ["duckduckgo", "insane", "exa", "brave", "jina", "kimi", "zai", "anthropic", "perplexity", "gemini", "codex", "xai", "tavily", "parallel", "kagi", "synthetic", "searxng"];
19
19
  export declare function isSearchProviderId(value: string): value is SearchProviderId;
20
20
  export declare function isConfigurableSearchProviderId(value: string): value is (typeof CONFIGURABLE_SEARCH_PROVIDER_IDS)[number];
21
21
  export declare function isSearchProviderPreference(value: string): value is (typeof CONFIGURABLE_SEARCH_PROVIDER_IDS)[number] | "auto";
@@ -96,6 +96,14 @@ export interface AnthropicCitation {
96
96
  cited_text: string;
97
97
  encrypted_index: string;
98
98
  }
99
+ /**
100
+ * Error payload returned in `web_search_tool_result.content` when a server-side
101
+ * web search fails. Unlike the success case, this is an object, not an array.
102
+ */
103
+ export interface AnthropicWebSearchToolResultError {
104
+ type: "web_search_tool_result_error";
105
+ error_code?: string;
106
+ }
99
107
  export interface AnthropicContentBlock {
100
108
  type: string;
101
109
  /** Text content (for type="text") */
@@ -108,8 +116,8 @@ export interface AnthropicContentBlock {
108
116
  input?: {
109
117
  query: string;
110
118
  };
111
- /** Search results (for type="web_search_tool_result") */
112
- content?: AnthropicSearchResult[];
119
+ /** Search results array on success, or an error object on failure (type="web_search_tool_result") */
120
+ content?: AnthropicSearchResult[] | AnthropicWebSearchToolResultError;
113
121
  }
114
122
  export interface AnthropicApiResponse {
115
123
  id: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/coding-agent",
4
- "version": "0.7.0",
4
+ "version": "0.7.2",
5
5
  "description": "Gajae Code CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://gaebal-gajae.dev",
7
7
  "author": "Yeachan-Heo",
@@ -45,18 +45,19 @@
45
45
  "generate-docs-index": "bun scripts/generate-docs-index.ts",
46
46
  "prepack": "bun scripts/generate-docs-index.ts",
47
47
  "generate-template": "bun scripts/generate-template.ts",
48
- "install:defaults": "bun src/cli.ts setup defaults"
48
+ "install:defaults": "bun src/cli.ts setup defaults",
49
+ "verify:insane-vendor": "bun scripts/verify-insane-vendor.ts"
49
50
  },
50
51
  "dependencies": {
51
52
  "@agentclientprotocol/sdk": "0.21.0",
52
53
  "@babel/parser": "^7.29.3",
53
54
  "@mozilla/readability": "^0.6.0",
54
- "@gajae-code/stats": "0.7.0",
55
- "@gajae-code/agent-core": "0.7.0",
56
- "@gajae-code/ai": "0.7.0",
57
- "@gajae-code/natives": "0.7.0",
58
- "@gajae-code/tui": "0.7.0",
59
- "@gajae-code/utils": "0.7.0",
55
+ "@gajae-code/stats": "0.7.2",
56
+ "@gajae-code/agent-core": "0.7.2",
57
+ "@gajae-code/ai": "0.7.2",
58
+ "@gajae-code/natives": "0.7.2",
59
+ "@gajae-code/tui": "0.7.2",
60
+ "@gajae-code/utils": "0.7.2",
60
61
  "@puppeteer/browsers": "^2.13.0",
61
62
  "@types/turndown": "5.0.6",
62
63
  "@xterm/headless": "^6.0.0",
@@ -84,6 +85,7 @@
84
85
  "examples",
85
86
  "README.md",
86
87
  "CHANGELOG.md",
88
+ "vendor",
87
89
  "dist/types"
88
90
  ],
89
91
  "exports": {
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Vendor verification for packages/coding-agent/vendor/insane-search.
4
+ *
5
+ * Asserts:
6
+ * 1. Forbidden upstream paths/patterns are absent (install hooks, star-baiting,
7
+ * update-notifier, transcript-language scanner, .claude-plugin).
8
+ * 2. MANIFEST.json exists and pins a full 40-char upstream commit SHA.
9
+ * 3. The vendored runtime files are present.
10
+ * 4. `npm pack --dry-run --json` includes the vendor tree (engine entrypoint,
11
+ * templates, LICENSE, manifest) in the published package.
12
+ *
13
+ * Exit code 0 on success, 1 on any failure.
14
+ */
15
+ import { execFileSync } from "node:child_process";
16
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
17
+ import { dirname, join, relative } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+
20
+ const pkgDir = join(dirname(fileURLToPath(import.meta.url)), "..");
21
+ const vendorDir = join(pkgDir, "vendor", "insane-search");
22
+ const failures: string[] = [];
23
+
24
+ function fail(msg: string): void {
25
+ failures.push(msg);
26
+ }
27
+
28
+ function walk(dir: string): string[] {
29
+ const out: string[] = [];
30
+ for (const entry of readdirSync(dir)) {
31
+ const full = join(dir, entry);
32
+ if (statSync(full).isDirectory()) out.push(...walk(full));
33
+ else out.push(full);
34
+ }
35
+ return out;
36
+ }
37
+
38
+ // 1. Forbidden paths / patterns
39
+ if (!existsSync(vendorDir)) {
40
+ fail(`vendor tree missing at ${vendorDir}`);
41
+ } else {
42
+ const files = walk(vendorDir).map(f => relative(vendorDir, f));
43
+ const forbiddenNames = ["setup.sh", "gptaku-update-check.cjs"];
44
+ const forbiddenSubpaths = [".claude-plugin/", "/references/", "/tests/coverage_battery"];
45
+ for (const f of files) {
46
+ const base = f.split("/").pop() ?? f;
47
+ if (forbiddenNames.includes(base)) fail(`forbidden file present: ${f}`);
48
+ for (const sub of forbiddenSubpaths) {
49
+ if (`/${f}`.includes(sub)) fail(`forbidden path present: ${f}`);
50
+ }
51
+ }
52
+ // Scan for star-baiting / settings.json mutation / transcript scanning patterns.
53
+ const forbiddenPatterns: Array<[RegExp, string]> = [
54
+ [/user\/starred/, "github star-baiting (user/starred)"],
55
+ [/gh\s+api\s+-X\s+PUT/, "gh api star write"],
56
+ [/SessionStart/, "settings.json SessionStart hook injection"],
57
+ [/\.claude\/projects/, "past-session transcript scanner"],
58
+ ];
59
+ for (const f of files) {
60
+ if (f === "MANIFEST.json") continue; // manifest documents the excluded patterns by name
61
+ let body = "";
62
+ try {
63
+ body = readFileSync(join(vendorDir, f), "utf8");
64
+ } catch {
65
+ continue;
66
+ }
67
+ for (const [re, label] of forbiddenPatterns) {
68
+ if (re.test(body)) fail(`forbidden pattern (${label}) found in ${f}`);
69
+ }
70
+ }
71
+ }
72
+
73
+ // 2. Manifest with pinned SHA
74
+ const manifestPath = join(vendorDir, "MANIFEST.json");
75
+ let commit = "";
76
+ if (!existsSync(manifestPath)) {
77
+ fail("MANIFEST.json missing");
78
+ } else {
79
+ try {
80
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as {
81
+ upstream?: { commit?: string };
82
+ };
83
+ commit = manifest.upstream?.commit ?? "";
84
+ if (!/^[0-9a-f]{40}$/.test(commit)) fail(`MANIFEST upstream.commit is not a full 40-char SHA: "${commit}"`);
85
+ } catch (err) {
86
+ fail(`MANIFEST.json is not valid JSON: ${(err as Error).message}`);
87
+ }
88
+ }
89
+
90
+ // 3. Required runtime files present
91
+ const requiredFiles = [
92
+ "engine/__main__.py",
93
+ "engine/__init__.py",
94
+ "engine/fetch_chain.py",
95
+ "engine/templates/package.json",
96
+ "engine/templates/playwright_real_chrome.js",
97
+ "engine/waf_profiles.yaml",
98
+ "LICENSE",
99
+ "MANIFEST.json",
100
+ ];
101
+ for (const rel of requiredFiles) {
102
+ if (!existsSync(join(vendorDir, rel))) fail(`required vendored file missing: ${rel}`);
103
+ }
104
+
105
+ // 4. Package pack inclusion
106
+ try {
107
+ const raw = execFileSync("npm", ["pack", "--dry-run", "--json"], {
108
+ cwd: pkgDir,
109
+ encoding: "utf8",
110
+ stdio: ["ignore", "pipe", "ignore"],
111
+ });
112
+ const parsed = JSON.parse(raw) as Array<{ files?: Array<{ path: string }> }>;
113
+ const packed = new Set((parsed[0]?.files ?? []).map(f => f.path.replace(/\\/g, "/")));
114
+ const mustPack = [
115
+ "vendor/insane-search/engine/__main__.py",
116
+ "vendor/insane-search/engine/templates/playwright_real_chrome.js",
117
+ "vendor/insane-search/LICENSE",
118
+ "vendor/insane-search/MANIFEST.json",
119
+ ];
120
+ for (const rel of mustPack) {
121
+ if (!packed.has(rel)) fail(`package pack does not include ${rel}`);
122
+ }
123
+ } catch (err) {
124
+ fail(`npm pack --dry-run failed: ${(err as Error).message}`);
125
+ }
126
+
127
+ if (failures.length > 0) {
128
+ console.error("insane-vendor verification FAILED:");
129
+ for (const f of failures) console.error(` - ${f}`);
130
+ process.exit(1);
131
+ }
132
+ console.log(`insane-vendor verification passed (pinned ${commit}).`);
package/src/cli/args.ts CHANGED
@@ -265,7 +265,7 @@ export function getExtraHelpText(): string {
265
265
  GJC_SLOW_MODEL - Override slow/reasoning model (see --slow)
266
266
  GJC_PLAN_MODEL - Override planning model (see --plan)
267
267
  GJC_NO_PTY - Disable PTY-based interactive bash execution
268
- --tmux - Launch interactive startup inside a new tmux session
268
+ --tmux - Launch interactive startup inside a fresh tmux session
269
269
  gjc session - List, inspect, create, remove, or attach tagged GJC-managed tmux sessions
270
270
  GJC_LAUNCH_POLICY - Launch policy for --tmux startup: tmux or direct
271
271
  GJC_TMUX_SESSION - Explicit tmux session name override for --tmux startup
@@ -50,7 +50,7 @@ export function getExtraHelpText(): string {
50
50
  GJC_SLOW_MODEL - Override slow/reasoning model (see --slow)
51
51
  GJC_PLAN_MODEL - Override planning model (see --plan)
52
52
  GJC_NO_PTY - Disable PTY-based interactive bash execution
53
- --tmux - Launch interactive startup inside a new tmux session
53
+ --tmux - Launch interactive startup inside a fresh tmux session
54
54
  gjc session - List, inspect, create, remove, or attach tagged GJC-managed tmux sessions
55
55
  GJC_LAUNCH_POLICY - Launch policy for --tmux startup: tmux or direct
56
56
  GJC_TMUX_SESSION - Explicit tmux session name override for --tmux startup