@kenkaiiii/ggcoder 5.23.3 → 5.24.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 (82) hide show
  1. package/dist/app-sidecar.js +32 -0
  2. package/dist/app-sidecar.js.map +1 -1
  3. package/dist/core/agent-session-add-dir.test.d.ts +2 -0
  4. package/dist/core/agent-session-add-dir.test.d.ts.map +1 -0
  5. package/dist/core/agent-session-add-dir.test.js +94 -0
  6. package/dist/core/agent-session-add-dir.test.js.map +1 -0
  7. package/dist/core/agent-session.d.ts +21 -0
  8. package/dist/core/agent-session.d.ts.map +1 -1
  9. package/dist/core/agent-session.js +62 -4
  10. package/dist/core/agent-session.js.map +1 -1
  11. package/dist/core/network-guard.d.ts +47 -0
  12. package/dist/core/network-guard.d.ts.map +1 -0
  13. package/dist/core/network-guard.js +208 -0
  14. package/dist/core/network-guard.js.map +1 -0
  15. package/dist/core/network-guard.test.d.ts +2 -0
  16. package/dist/core/network-guard.test.d.ts.map +1 -0
  17. package/dist/core/network-guard.test.js +72 -0
  18. package/dist/core/network-guard.test.js.map +1 -0
  19. package/dist/core/prompt-commands.d.ts.map +1 -1
  20. package/dist/core/prompt-commands.js +55 -36
  21. package/dist/core/prompt-commands.js.map +1 -1
  22. package/dist/core/prompt-commands.test.js +49 -2
  23. package/dist/core/prompt-commands.test.js.map +1 -1
  24. package/dist/core/session-export.d.ts +98 -0
  25. package/dist/core/session-export.d.ts.map +1 -0
  26. package/dist/core/session-export.js +356 -0
  27. package/dist/core/session-export.js.map +1 -0
  28. package/dist/core/session-export.test.d.ts +2 -0
  29. package/dist/core/session-export.test.d.ts.map +1 -0
  30. package/dist/core/session-export.test.js +353 -0
  31. package/dist/core/session-export.test.js.map +1 -0
  32. package/dist/core/settings-manager.d.ts +5 -0
  33. package/dist/core/settings-manager.d.ts.map +1 -1
  34. package/dist/core/settings-manager.js +10 -0
  35. package/dist/core/settings-manager.js.map +1 -1
  36. package/dist/core/slash-commands.d.ts +10 -0
  37. package/dist/core/slash-commands.d.ts.map +1 -1
  38. package/dist/core/slash-commands.js +16 -0
  39. package/dist/core/slash-commands.js.map +1 -1
  40. package/dist/core/slash-commands.test.d.ts +2 -0
  41. package/dist/core/slash-commands.test.d.ts.map +1 -0
  42. package/dist/core/slash-commands.test.js +48 -0
  43. package/dist/core/slash-commands.test.js.map +1 -0
  44. package/dist/core/workspace-guard.d.ts +2 -0
  45. package/dist/core/workspace-guard.d.ts.map +1 -1
  46. package/dist/core/workspace-guard.js +4 -1
  47. package/dist/core/workspace-guard.js.map +1 -1
  48. package/dist/core/workspace-guard.test.js +21 -0
  49. package/dist/core/workspace-guard.test.js.map +1 -1
  50. package/dist/system-prompt.d.ts +11 -1
  51. package/dist/system-prompt.d.ts.map +1 -1
  52. package/dist/system-prompt.js +19 -4
  53. package/dist/system-prompt.js.map +1 -1
  54. package/dist/system-prompt.test.js +9 -0
  55. package/dist/system-prompt.test.js.map +1 -1
  56. package/dist/tools/bash.d.ts +2 -1
  57. package/dist/tools/bash.d.ts.map +1 -1
  58. package/dist/tools/bash.js +9 -1
  59. package/dist/tools/bash.js.map +1 -1
  60. package/dist/tools/bash.test.js +19 -0
  61. package/dist/tools/bash.test.js.map +1 -1
  62. package/dist/tools/grep.d.ts +3 -1
  63. package/dist/tools/grep.d.ts.map +1 -1
  64. package/dist/tools/grep.js +132 -10
  65. package/dist/tools/grep.js.map +1 -1
  66. package/dist/tools/grep.test.js +53 -0
  67. package/dist/tools/grep.test.js.map +1 -1
  68. package/dist/tools/index.d.ts +6 -0
  69. package/dist/tools/index.d.ts.map +1 -1
  70. package/dist/tools/index.js +3 -3
  71. package/dist/tools/index.js.map +1 -1
  72. package/dist/tools/web-fetch.d.ts +2 -1
  73. package/dist/tools/web-fetch.d.ts.map +1 -1
  74. package/dist/tools/web-fetch.js +17 -6
  75. package/dist/tools/web-fetch.js.map +1 -1
  76. package/dist/tools/web-fetch.test.js +34 -0
  77. package/dist/tools/web-fetch.test.js.map +1 -1
  78. package/dist/tools/web-search.d.ts +2 -1
  79. package/dist/tools/web-search.d.ts.map +1 -1
  80. package/dist/tools/web-search.js +21 -5
  81. package/dist/tools/web-search.js.map +1 -1
  82. package/package.json +4 -4
@@ -0,0 +1,72 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { checkCommandNetwork, checkUrlNetwork, extractCommandHosts, isHostAllowed, } from "./network-guard.js";
3
+ describe("isHostAllowed", () => {
4
+ it("matches exact hosts case-insensitively", () => {
5
+ expect(isHostAllowed("GitHub.com", ["github.com"])).toBe(true);
6
+ expect(isHostAllowed("github.com", ["GITHUB.COM"])).toBe(true);
7
+ expect(isHostAllowed("gitlab.com", ["github.com"])).toBe(false);
8
+ });
9
+ it("matches a leading *. wildcard against subdomains only", () => {
10
+ expect(isHostAllowed("api.github.com", ["*.github.com"])).toBe(true);
11
+ expect(isHostAllowed("a.b.github.com", ["*.github.com"])).toBe(true);
12
+ expect(isHostAllowed("github.com", ["*.github.com"])).toBe(false);
13
+ expect(isHostAllowed("evilgithub.com", ["*.github.com"])).toBe(false);
14
+ });
15
+ it("rejects everything against an empty allowlist", () => {
16
+ expect(isHostAllowed("github.com", [])).toBe(false);
17
+ expect(isHostAllowed("", ["github.com"])).toBe(false);
18
+ });
19
+ });
20
+ describe("extractCommandHosts", () => {
21
+ it.each([
22
+ ["curl -sSL https://example.com/x.sh", ["example.com"]],
23
+ ["wget https://files.example.org/a.tar.gz -O a.tgz", ["files.example.org"]],
24
+ ["git clone https://github.com/owner/repo.git", ["github.com"]],
25
+ ["git clone git@gitlab.com:owner/repo.git", ["gitlab.com"]],
26
+ ["git push origin main", []],
27
+ ["ssh deploy@prod.example.com 'uptime'", ["prod.example.com"]],
28
+ ["scp file.txt deploy@prod.example.com:/tmp", ["prod.example.com"]],
29
+ ["npm install left-pad", ["registry.npmjs.org"]],
30
+ ["pnpm add -D vitest", ["registry.npmjs.org"]],
31
+ ["yarn add react", ["registry.yarnpkg.com"]],
32
+ ["pip install requests", ["pypi.org"]],
33
+ ["cd repo && curl https://api.example.com/v1", ["api.example.com"]],
34
+ ])("extracts hosts from %s", (command, expected) => {
35
+ expect(extractCommandHosts(command).sort()).toEqual(expected.sort());
36
+ });
37
+ it.each([
38
+ "ls -la",
39
+ "npm run build",
40
+ "git status",
41
+ "git commit -m 'curl https://example.com'",
42
+ "echo hello",
43
+ "python3 script.py",
44
+ "rm -rf node_modules",
45
+ ])("finds no host in %s (no false blocks)", (command) => {
46
+ expect(extractCommandHosts(command)).toEqual([]);
47
+ });
48
+ });
49
+ describe("checkCommandNetwork", () => {
50
+ it("is a total no-op when the mode is off", () => {
51
+ expect(checkCommandNetwork("curl https://evil.example", "off", [])).toBeNull();
52
+ });
53
+ it("blocks a disallowed host and names the setting", () => {
54
+ const error = checkCommandNetwork("curl https://evil.example/x", "allowlist", ["github.com"]);
55
+ expect(error).toContain("evil.example");
56
+ expect(error).toContain("networkAllow");
57
+ });
58
+ it("allows an allow-listed host and unrecognised commands", () => {
59
+ expect(checkCommandNetwork("git clone https://github.com/o/r.git", "allowlist", ["github.com"])).toBeNull();
60
+ expect(checkCommandNetwork("make build", "allowlist", [])).toBeNull();
61
+ });
62
+ });
63
+ describe("checkUrlNetwork", () => {
64
+ it("is a total no-op when the mode is off", () => {
65
+ expect(checkUrlNetwork("https://evil.example", "off", [])).toBeNull();
66
+ });
67
+ it("enforces the allowlist on a URL", () => {
68
+ expect(checkUrlNetwork("https://api.github.com/x", "allowlist", ["*.github.com"])).toBeNull();
69
+ expect(checkUrlNetwork("https://evil.example/x", "allowlist", ["*.github.com"])).toContain("evil.example");
70
+ });
71
+ });
72
+ //# sourceMappingURL=network-guard.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-guard.test.js","sourceRoot":"","sources":["../../src/core/network-guard.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL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,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9F,MAAM,CAAC,eAAe,CAAC,wBAAwB,EAAE,WAAW,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CACxF,cAAc,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-commands.d.ts","sourceRoot":"","sources":["../../src/core/prompt-commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AA4BD,eAAO,MAAM,eAAe,EAAE,aAAa,EAihB1C,CAAC;AAEF,gDAAgD;AAChD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAExE"}
1
+ {"version":3,"file":"prompt-commands.d.ts","sourceRoot":"","sources":["../../src/core/prompt-commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AA+BD,eAAO,MAAM,eAAe,EAAE,aAAa,EAiiB1C,CAAC;AAEF,gDAAgD;AAChD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAExE"}
@@ -7,9 +7,12 @@ const IS_GG_APP = isGgApp();
7
7
  const TASKS_ADDED_NOTICE = IS_GG_APP
8
8
  ? 'Tasks added. Click the "Tasks" button to open the task list and run them.'
9
9
  : "Tasks added. Press Ctrl+T to open the task list and run them.";
10
+ // The context file is whichever name won CONTEXT_FILES priority for this repo
11
+ // (AGENTS.override.md > AGENTS.md > CLAUDE.md > …), so the notice stays
12
+ // filename-agnostic — /init picks the winner at run time.
10
13
  const CLAUDE_MD_RESTART_NOTICE = IS_GG_APP
11
- ? '> ⚠️ CLAUDE.md was created/updated. GG App loads it fresh per session, so start a **New Session** (click "+ New") before continuing. Without a new session, I won\'t see the new context.'
12
- : "> ⚠️ CLAUDE.md was created/updated. ggcoder loads it at startup, so **exit and restart ggcoder** (`/quit` then run `ggcoder` again) before continuing. Without a restart, I won't see the new context.";
14
+ ? '> ⚠️ The project context file was created/updated. GG App loads it fresh per session, so start a **New Session** (click "+ New") before continuing. Without a new session, I won\'t see the new context.'
15
+ : "> ⚠️ The project context file was created/updated. ggcoder loads it at startup, so **exit and restart ggcoder** (`/quit` then run `ggcoder` again) before continuing. Without a restart, I won't see the new context.";
13
16
  /**
14
17
  * Shared sub-agent fan-out phrasing. One home so the "call the tool N times
15
18
  * in a single response" wording can't drift between command prompts.
@@ -304,60 +307,76 @@ Defensive reference material from public incident reports and OWASP — patterns
304
307
  name: "init",
305
308
  aliases: [],
306
309
  description: "Generate or update CLAUDE.md for this project",
307
- prompt: `Generate or update a minimal CLAUDE.md with project-specific context only: what this project is, how it is structured, and commands/workflows that are unique to it.
310
+ prompt: `Generate or update the project context file with project-specific context only: what this project is, the non-obvious knowledge needed to change it safely, and the workflows that are unique to it.
308
311
 
309
- Do NOT add generic agent behavior already covered by the system prompt, including: read before edit/write, re-read after formatters, ask before destructive actions, no fake verification, generic code-quality advice, single-responsibility rules, one-file-per-component rules, or language-style conventions. Never add guidance that requires running checks, builds, or the full quality suite after every edit or every file change. Include only project-specific overrides or stricter local requirements.
312
+ This file is injected verbatim into the **cached prefix of every request in every future session**, alongside the system prompt. Every line costs tokens forever. A line that repeats something the agent already has is worse than absent: it dilutes the lines that matter. So the bar is not "is this true?" it is **"would a competent agent get this wrong without being told?"**
310
313
 
311
- ## Step 1: Check if CLAUDE.md Exists
314
+ ## What is already in the agent's context — never restate any of it
312
315
 
313
- If CLAUDE.md exists:
314
- - Read the existing file
315
- - Preserve custom sections the user may have added
316
- - Update only project-specific facts that are stale or missing
317
- - Remove generic guidance that is already covered by the system prompt unless it is a deliberate project-specific override
316
+ Read this list once and apply it to every step below. These are already supplied by the system prompt, so writing them into the context file is pure duplication:
318
317
 
319
- If CLAUDE.md does NOT exist:
320
- - Create a new one from scratch
318
+ 1. **Agent behavior** — Do NOT add generic agent behavior already covered by the system prompt: read before edit/write, re-read after formatters, ask before destructive actions, no fake verification, generic code-quality advice, how to use tools, or how to talk to the user.
319
+ 2. **Language conventions** — a Language Style Packs section is auto-injected for every language detected in this repo. Do not duplicate language style packs, generic verification rules, or boilerplate quality gates such as "After editing ANY file" / "Code Quality — Zero Tolerance".
320
+ 3. **Verify commands** — a Verification section is auto-generated from package scripts / manifests (lint, typecheck, format, test) with the correct runner already resolved from the lockfile. Only write a command down if it is NOT discoverable that way: an undocumented multi-step sequence, a required ordering, a non-obvious flag, or a command that lives outside the manifest. Never add guidance that requires running checks, builds, or the full quality suite after every edit or every file change, and never turn discovered commands into mandatory after-every-edit requirements unless local CI explicitly enforces that sequence.
321
+ 4. **The file tree** — the agent can list and grep the repo in one call. Do NOT embed generated symbol maps, exhaustive file indexes, auto-generated directory listings, or large trees. Do not add symbol indexes or auto-generated project inventories; the context file must remain durable, agent-focused project context.
321
322
 
322
- ## Step 2: Analyze Project (Use Sub-agents in Parallel)
323
+ Include only project-specific overrides, stricter local requirements, or knowledge that cannot be derived by reading the code.
323
324
 
324
- Derive every fact from the actual project — source code, entry points, manifests, and config. Treat README, docs, and code comments as unverified hints that are frequently stale: never copy claims from them, and only state things you can confirm from the code and config themselves.
325
+ ## Step 1: Pick the target filename
325
326
 
326
- Spawn 3 sub-agents ${spawnParallel(3)}:
327
+ Context files are loaded **one per directory, first match wins**, in this priority order: \`AGENTS.override.md\` > \`AGENTS.md\` > \`CLAUDE.md\` > \`.cursorrules\` > \`CONVENTIONS.md\`.
328
+
329
+ List the repo root and write to **whichever of those already exists with the highest priority**. If the repo already has an \`AGENTS.md\`, update that file — creating a new CLAUDE.md next to it produces a file the agent will never load. If none exists, create \`CLAUDE.md\`. State which file you chose and why in one line.
330
+
331
+ ## Step 2: Set up the regenerated block
327
332
 
328
- 1. **Project Purpose Agent**: Determine what the project actually does from its real code entry points, main modules, exported/public APIs, CLI commands, routes, and manifests. Do not rely on the README's description.
329
- 2. **Directory Structure Agent**: Map out the folder structure and what each folder contains
330
- 3. **Tech Stack Agent**: Identify languages, frameworks, tools, and dependencies from manifests/lockfiles and config (not from prose docs)
333
+ \`/init\` is re-run over the project's lifetime, so the generated content must be **replaceable, not appendable** otherwise each run grows the file forever.
331
334
 
332
- Wait for all sub-agents to complete, then synthesize the information.
335
+ All content you generate goes inside these exact fence markers:
333
336
 
334
- ## Step 3: Detect Project Type & Commands
337
+ \`\`\`
338
+ <!-- gg:init:start -->
339
+ …generated content…
340
+ <!-- gg:init:end -->
341
+ \`\`\`
335
342
 
336
- Check for config files:
337
- - package.json -> JavaScript/TypeScript (extract package-manager, build, lint, typecheck, test, format, and server scripts)
338
- - pyproject.toml or requirements.txt -> Python
339
- - go.mod -> Go
340
- - Cargo.toml -> Rust
343
+ - If the file exists and already has the fence: **replace everything between the markers wholesale**. Text outside the fence is user-owned — do not touch it, do not reformat it, do not move it.
344
+ - If the file exists without the fence: read it, decide which content is hand-written knowledge worth keeping, move that above the fence untouched, and put your generated content inside a new fence. Remove generic guidance that is already covered by the system prompt (see the list above) unless it is a deliberate project-specific override.
345
+ - If the file does not exist: create it with the fence.
341
346
 
342
- Extract exact commands that are useful project facts. Take commands from authoritative sources — package scripts, manifests, Makefiles, and CI config; do not invent them from convention, and do not trust README/doc command snippets unless a script or manifest confirms they still exist. Do not restate generic "run checks after edits" behavior, and do not turn discovered commands into mandatory after-every-edit requirements unless local docs or CI explicitly require that stricter sequence.
347
+ ## Step 3: Analyze the project (sub-agents in parallel)
343
348
 
344
- ## Step 4: Summarize Stable Structure
349
+ Derive every fact from the actual project — source code, entry points, manifests, config, and history. Treat README, docs, and code comments as unverified hints that are frequently stale: never copy claims from them, and only state things you can confirm from the code and config themselves.
345
350
 
346
- If useful, create a concise structure summary for future agents showing only key stable directories and files with brief descriptions. Do NOT embed generated symbol maps, exhaustive file indexes, auto-generated directory listings, or large trees in CLAUDE.md.
351
+ Spawn 3 sub-agents ${spawnParallel(3)}:
347
352
 
348
- ## Step 5: Generate or Update CLAUDE.md
353
+ 1. **Purpose & Shape Agent**: What does this project actually do, and what are its top-level parts? Read entry points, main modules, exported/public APIs, CLI commands, routes, and manifests. Return: a one-sentence purpose, and for each package/app/module a one-line statement of what it *owns*. Do not rely on the README's description. Do not return a directory listing.
354
+ 2. **Gotchas & Invariants Agent**: Find the knowledge that is expensive to rediscover. Mine \`git log\` (especially revert/fix/hotfix commits), CI and release workflows, \`NOTE\`/\`HACK\`/\`IMPORTANT\`/\`WARNING\`/\`XXX\` comments, test names asserting surprising behavior, generated-file and build-order constraints, and any config with a non-default value. Return only: rules that are non-obvious from reading the code, ordering/sequencing constraints, things that silently break, and the *reason* each exists. Skip anything a careful reader would infer in 30 seconds.
355
+ 3. **Workflow & Stack Agent**: How is this project run, built, released, and deployed, from authoritative sources only — package scripts, manifests, Makefiles, CI config, deploy config. Return the workflows and any command that is NOT a plain single manifest script (multi-step sequences, required order, env vars, non-obvious flags, commands living outside the manifest). Do not return commands the auto-generated Verification section already covers (see item 3 above). Do not invent commands from convention, and do not trust README/doc command snippets unless a script or manifest confirms they still exist.
349
356
 
350
- Create CLAUDE.md with only sections that add project-specific value. Prefer this structure:
357
+ Wait for all sub-agents to complete, then synthesize.
358
+
359
+ ## Step 4: Write the generated block
360
+
361
+ Inside the fence, write only sections that add project-specific value. Prefer this order — drop any section that would be empty or obvious:
351
362
 
352
363
  - Project name and one-sentence purpose
353
- - Key packages/apps/modules and what each owns
354
- - Important project-specific architecture or workflow notes
355
- - Exact local commands (install/build/check/test/dev/publish/deploy) when they are not obvious from package scripts alone
356
- - Project-specific constraints that override defaults (for example required publish order, generated-file workflow, auth/secrets storage, deployment caveats)
364
+ - Key packages/apps/modules and what each owns (one line each, no tree)
365
+ - Architecture or data-flow notes an agent could not infer quickly from the code
366
+ - **Gotchas / invariants** the highest-value section. Each entry states the rule *and* why it exists.
367
+ - Project-specific commands and workflows that survived the Step 3 filter (required publish order, generated-file workflow, dev-server startup, deployment caveats, auth/secrets storage)
368
+
369
+ Avoid generic sections named "Code Quality", "Organization Rules", or "How to Work" unless every bullet is specific to this project.
370
+
371
+ ## Step 5: Budget and verify
372
+
373
+ The combined budget for all project context files is 32KB, shared with any parent-directory context files. **Target 6KB or less for the generated block** — a tight 4KB file that gets read every time beats a 25KB file the agent skims.
357
374
 
358
- Avoid generic sections named "Code Quality", "Organization Rules", or "How to Work" unless every bullet is specific to this project. Do not duplicate language style packs, generic verification rules, or boilerplate quality gates such as "After editing ANY file" / "Code Quality — Zero Tolerance". Do not add symbol indexes, exhaustive file indexes, or auto-generated project inventories; CLAUDE.md must remain durable, agent-focused project context.
375
+ After writing:
359
376
 
360
- Keep total file under 100 lines. If updating, preserve any custom sections the user added. After writing, re-read CLAUDE.md and confirm it contains only project-specific facts supported by local files.
377
+ 1. Run \`wc -c\` on the file and report the byte size. If the generated block exceeds ~6KB, cut the weakest sections (the ones closest to "derivable by reading the code") and rewrite.
378
+ 2. Re-read the file and confirm every remaining line passes the bar: **project-specific, supported by a local file you actually read, and not already in the agent's context per the list above.**
379
+ 3. Report in one line: which file, how many bytes, and how many lines you removed as redundant.
361
380
 
362
381
  ## Step 6: Restart Notice
363
382
 
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-commands.js","sourceRoot":"","sources":["../../src/core/prompt-commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAS5C,MAAM,SAAS,GAAG,OAAO,EAAE,CAAC;AAE5B,MAAM,kBAAkB,GAAG,SAAS;IAClC,CAAC,CAAC,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;;;;;;;;mLA0DuK;KAChL;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,yBAAyB;QACtC,MAAM,EAAE;;EAEV,mBAAmB;;;;;;;;;;;;;;;iFAe4D;KAC9E;IACD;QACE,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,yBAAyB;QACtC,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAqCgC,aAAa,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gLAwDkH;KAC7K;CACF,CAAC;AAEF,gDAAgD;AAChD,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACxF,CAAC"}
@@ -93,7 +93,7 @@ describe("prompt commands", () => {
93
93
  expect(expand?.prompt).not.toContain("Create a Goal");
94
94
  expect(expand?.prompt).not.toContain("planning-only Goal tasks");
95
95
  });
96
- it("keeps /init focused on project-specific CLAUDE.md content", () => {
96
+ it("keeps /init focused on project-specific context", () => {
97
97
  const init = PROMPT_COMMANDS.find((command) => command.name === "init");
98
98
  expect(init).toBeDefined();
99
99
  expect(init?.prompt).toContain("project-specific context only");
@@ -105,12 +105,59 @@ describe("prompt commands", () => {
105
105
  expect(init?.prompt).toContain("Do not duplicate language style packs, generic verification rules");
106
106
  expect(init?.prompt).toContain("Do NOT embed generated symbol maps");
107
107
  expect(init?.prompt).toContain("auto-generated project inventories");
108
- expect(init?.prompt).toContain("CLAUDE.md must remain durable, agent-focused project context");
108
+ expect(init?.prompt).toContain("context file must remain durable, agent-focused project context");
109
109
  expect(init?.prompt).not.toContain("human-authored");
110
110
  expect(init?.prompt).not.toContain("one file per component");
111
111
  expect(init?.prompt).not.toContain("single responsibility");
112
112
  expect(init?.prompt).not.toContain("zero-tolerance code quality checks");
113
113
  expect(init?.prompt).not.toContain("run full quality suite after every edit");
114
114
  });
115
+ it("states each redundancy rule exactly once so /init reads as one filter", () => {
116
+ const init = PROMPT_COMMANDS.find((command) => command.name === "init");
117
+ const count = (needle) => init.prompt.split(needle).length - 1;
118
+ // The old prompt restated these across the preamble and 3 separate steps.
119
+ // Repetition-as-emphasis is what you write when a rule isn't structurally
120
+ // enforceable; the fence + budget now carry that load instead.
121
+ expect(count("Do NOT add generic agent behavior")).toBe(1);
122
+ expect(count("Do NOT embed generated symbol maps")).toBe(1);
123
+ expect(count("Never add guidance that requires running checks")).toBe(1);
124
+ });
125
+ it("makes /init regeneration replace a fenced block instead of appending", () => {
126
+ const init = PROMPT_COMMANDS.find((command) => command.name === "init");
127
+ // /init is re-run over a project's lifetime. Without a marker separating
128
+ // agent-generated from user-written content, "preserve custom sections"
129
+ // preserves everything and the file grows monotonically.
130
+ expect(init?.prompt).toContain("<!-- gg:init:start -->");
131
+ expect(init?.prompt).toContain("<!-- gg:init:end -->");
132
+ expect(init?.prompt).toContain("replace everything between the markers wholesale");
133
+ expect(init?.prompt).toContain("Text outside the fence is user-owned");
134
+ });
135
+ it("makes /init write to the context file the loader actually reads", () => {
136
+ const init = PROMPT_COMMANDS.find((command) => command.name === "init");
137
+ // CONTEXT_FILES takes one file per directory, AGENTS.md outranks CLAUDE.md.
138
+ // Writing a fresh CLAUDE.md next to an existing AGENTS.md creates a file
139
+ // that is silently never loaded.
140
+ expect(init?.prompt).toContain("one per directory, first match wins");
141
+ expect(init?.prompt).toContain("AGENTS.override.md`");
142
+ expect(init?.prompt).toContain("already has an `AGENTS.md`, update that file");
143
+ });
144
+ it("budgets /init output in bytes with a stated token cost, not a line cap", () => {
145
+ const init = PROMPT_COMMANDS.find((command) => command.name === "init");
146
+ // A line cap is unverifiable by the model and doesn't constrain tables or
147
+ // code fences; the real constraint is PROJECT_CONTEXT_MAX_BYTES (32KB).
148
+ expect(init?.prompt).toContain("cached prefix of every request");
149
+ expect(init?.prompt).toContain("Target 6KB or less");
150
+ expect(init?.prompt).toContain("`wc -c`");
151
+ expect(init?.prompt).not.toContain("under 100 lines");
152
+ });
153
+ it("hunts non-derivable knowledge instead of mapping directories", () => {
154
+ const init = PROMPT_COMMANDS.find((command) => command.name === "init");
155
+ // Gotchas/invariants are the only content an agent can't recover by
156
+ // reading the code, so they replace the directory-structure sweep whose
157
+ // output the prompt then forbids embedding anyway.
158
+ expect(init?.prompt).toContain("Gotchas & Invariants Agent");
159
+ expect(init?.prompt).toContain("would a competent agent get this wrong without being told?");
160
+ expect(init?.prompt).not.toContain("Directory Structure Agent");
161
+ });
115
162
  });
116
163
  //# sourceMappingURL=prompt-commands.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-commands.test.js","sourceRoot":"","sources":["../../src/core/prompt-commands.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACnF,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE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,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAExE,oEAAoE;QACpE,wEAAwE;QACxE,mDAAmD;QACnD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QAC7D,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,4DAA4D,CAAC,CAAC;QAC7F,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,98 @@
1
+ import type { Message } from "@kenkaiiii/gg-ai";
2
+ /**
3
+ * Markdown transcript export.
4
+ *
5
+ * Renders a session's persisted messages into a single self-contained `.md`
6
+ * file a human can read, paste into a PR, or hand to a teammate. Deliberately
7
+ * NOT built on the webview's `Item[]`: the app keeps tool activity in the
8
+ * pinned LiveToolPanel and never in the transcript, so serializing from there
9
+ * would export a chat with the actual work missing.
10
+ *
11
+ * Bubble text goes through the SAME `restoreUserRow` / `restoreAssistantTexts`
12
+ * helpers the `/history` resume path uses, so what lands in the file matches
13
+ * what the user saw on screen (steering wrappers, attachment notes and
14
+ * autopilot preambles stripped) rather than the raw provider payload.
15
+ */
16
+ /** Hard cap on a single tool result's rendered text. Sessions already cap
17
+ * persisted tool text at 40k chars; an export is for reading, so it gets a
18
+ * much tighter budget — enough to see what happened, not a data dump. */
19
+ export declare const MAX_TOOL_RESULT_CHARS = 1500;
20
+ /** Hard cap on a single tool call's rendered arguments. */
21
+ export declare const MAX_TOOL_ARGS_CHARS = 800;
22
+ export interface SessionExportMeta {
23
+ /** Workspace mode this session ran in — picks the filename + title wording. */
24
+ mode: "chat" | "code";
25
+ cwd: string;
26
+ provider: string;
27
+ model: string;
28
+ /** Session id (a short prefix is shown in the header). */
29
+ sessionId?: string;
30
+ /** Export timestamp. Defaults to now. */
31
+ date?: Date;
32
+ }
33
+ /**
34
+ * How much of the agent's tool work to render.
35
+ *
36
+ * - `summary` (default) — one dim line per burst of tool calls, naming what ran
37
+ * (`read src/a.ts`, `bash pnpm build`). Keeps the narrative of what the agent
38
+ * did without the payloads. A real 1,346-message session is 708KB at `full`
39
+ * and 71KB here — the same story, minus the 90% no human was going to read.
40
+ * - `none` — pure conversation, nothing but the two voices.
41
+ * - `full` — collapsed `<details>` with arguments and (truncated) results. For
42
+ * debugging and bug reports, not for sharing.
43
+ */
44
+ export type ToolDetail = "none" | "summary" | "full";
45
+ export interface SessionExportOptions {
46
+ /** How much tool work to render. Default `summary`. */
47
+ toolDetail?: ToolDetail;
48
+ /** Render the model's reasoning blocks. Default false — thinking is scratch
49
+ * work, and a shared transcript is better without it. */
50
+ includeThinking?: boolean;
51
+ }
52
+ /** `2026-07-26-1402` — local time, sortable, and unique enough that two
53
+ * exports in the same day don't silently collide in the save dialog. */
54
+ export declare function exportTimestamp(date: Date): string;
55
+ /**
56
+ * Default filename offered in the native save dialog, e.g.
57
+ * `your-chat-2026-07-26-1402.md`. Coding sessions say `session` instead of
58
+ * `chat` so a folder of exports stays self-describing.
59
+ */
60
+ export declare function defaultExportFilename(mode: "chat" | "code", date?: Date): string;
61
+ /** One-line summary of a tool call for the `<details>` summary row: the tool
62
+ * name plus its most identifying argument (path, command, pattern, …). */
63
+ export declare function toolSummary(name: string, args: Record<string, unknown>): string;
64
+ /**
65
+ * Render a tool call's arguments, or null when there's nothing worth showing.
66
+ *
67
+ * A lone string argument (the overwhelmingly common shape — `bash`'s command, a
68
+ * `web_fetch` url) is rendered raw in a fence: `JSON.stringify` would turn a
69
+ * shell one-liner into unreadable `\"` / `\n` soup. It's dropped entirely when
70
+ * the summary row already showed that exact value in full, so short calls don't
71
+ * say the same thing twice. Everything else falls back to pretty JSON.
72
+ */
73
+ export declare function renderToolArgs(args: Record<string, unknown>): string | null;
74
+ /**
75
+ * One dim line standing in for a burst of tool calls, e.g.
76
+ * `_🔧 read src/a.ts · bash pnpm build · edit App.tsx · +4 more_`.
77
+ *
78
+ * Entries are deduped so an agent that reads the same file three times says it
79
+ * once, and capped so a 40-tool burst doesn't become a wall. Failures are still
80
+ * called out — a reader skimming for what went wrong shouldn't have to re-export
81
+ * at `full` to discover that something did.
82
+ */
83
+ export declare function renderToolSummaryLine(calls: readonly {
84
+ name: string;
85
+ args: Record<string, unknown>;
86
+ failed: boolean;
87
+ }[]): string | null;
88
+ /**
89
+ * Render a session's messages as Markdown.
90
+ *
91
+ * System messages are always dropped (the system prompt is ours, not the
92
+ * user's, and shipping it in a shared file leaks internals). Compaction
93
+ * summaries and self-correction hook prompts are machine-facing injections —
94
+ * they render as a quiet italic marker instead of a user bubble, exactly like
95
+ * the app shows them.
96
+ */
97
+ export declare function sessionToMarkdown(meta: SessionExportMeta, messages: readonly Message[], options?: SessionExportOptions): string;
98
+ //# sourceMappingURL=session-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-export.d.ts","sourceRoot":"","sources":["../../src/core/session-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,kBAAkB,CAAC;AAGnE;;;;;;;;;;;;;GAaG;AAEH;;0EAE0E;AAC1E,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG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