@kenkaiiii/ggcoder 5.78.0 → 5.79.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 (69) hide show
  1. package/dist/app-sidecar/goal-routes.d.ts +26 -0
  2. package/dist/app-sidecar/goal-routes.js +444 -0
  3. package/dist/app-sidecar/goal-routes.js.map +1 -0
  4. package/dist/app-sidecar/history-routes.d.ts +13 -0
  5. package/dist/app-sidecar/history-routes.js +36 -25
  6. package/dist/app-sidecar/history-routes.js.map +1 -1
  7. package/dist/app-sidecar/route-context.d.ts +12 -0
  8. package/dist/app-sidecar/run-control-routes.js +2 -1
  9. package/dist/app-sidecar/run-control-routes.js.map +1 -1
  10. package/dist/app-sidecar/session-routes.js +41 -0
  11. package/dist/app-sidecar/session-routes.js.map +1 -1
  12. package/dist/app-sidecar/session-types.d.ts +2 -0
  13. package/dist/app-sidecar/workspace-routes.js +3 -0
  14. package/dist/app-sidecar/workspace-routes.js.map +1 -1
  15. package/dist/app-sidecar.js +108 -8
  16. package/dist/app-sidecar.js.map +1 -1
  17. package/dist/core/acceptance-checks.js +17 -4
  18. package/dist/core/acceptance-checks.js.map +1 -1
  19. package/dist/core/agent-notifications.d.ts +1 -1
  20. package/dist/core/agent-session.d.ts +50 -0
  21. package/dist/core/agent-session.js +49 -11
  22. package/dist/core/agent-session.js.map +1 -1
  23. package/dist/core/ask-user.d.ts +11 -0
  24. package/dist/core/ask-user.js +6 -1
  25. package/dist/core/ask-user.js.map +1 -1
  26. package/dist/core/context-files.d.ts +8 -0
  27. package/dist/core/context-files.js +46 -0
  28. package/dist/core/context-files.js.map +1 -0
  29. package/dist/core/goals-store.d.ts +208 -0
  30. package/dist/core/goals-store.js +520 -0
  31. package/dist/core/goals-store.js.map +1 -0
  32. package/dist/core/project-discovery.d.ts +7 -0
  33. package/dist/core/project-discovery.js +8 -2
  34. package/dist/core/project-discovery.js.map +1 -1
  35. package/dist/core/session-manager.d.ts +7 -1
  36. package/dist/core/session-manager.js +17 -7
  37. package/dist/core/session-manager.js.map +1 -1
  38. package/dist/core/session-storage.js +5 -1
  39. package/dist/core/session-storage.js.map +1 -1
  40. package/dist/core/subagent-manager.d.ts +51 -0
  41. package/dist/core/subagent-manager.js +95 -15
  42. package/dist/core/subagent-manager.js.map +1 -1
  43. package/dist/core/subagent-store.js +2 -1
  44. package/dist/core/subagent-store.js.map +1 -1
  45. package/dist/goals-agent/goal-team.d.ts +2 -0
  46. package/dist/goals-agent/goal-team.js +82 -0
  47. package/dist/goals-agent/goal-team.js.map +1 -0
  48. package/dist/goals-agent/goals-agent.d.ts +90 -0
  49. package/dist/goals-agent/goals-agent.js +246 -0
  50. package/dist/goals-agent/goals-agent.js.map +1 -0
  51. package/dist/modes/subagent-worker-mode.d.ts +12 -0
  52. package/dist/modes/subagent-worker-mode.js +22 -1
  53. package/dist/modes/subagent-worker-mode.js.map +1 -1
  54. package/dist/tools/bash-read-evidence.d.ts +13 -0
  55. package/dist/tools/bash-read-evidence.js +48 -1
  56. package/dist/tools/bash-read-evidence.js.map +1 -1
  57. package/dist/tools/index.d.ts +7 -1
  58. package/dist/tools/index.js +10 -2
  59. package/dist/tools/index.js.map +1 -1
  60. package/dist/tools/read-tracker.d.ts +6 -12
  61. package/dist/tools/read-tracker.js +21 -36
  62. package/dist/tools/read-tracker.js.map +1 -1
  63. package/dist/tools/read.js +2 -2
  64. package/dist/tools/read.js.map +1 -1
  65. package/dist/tools/subagent-control.js +22 -3
  66. package/dist/tools/subagent-control.js.map +1 -1
  67. package/dist/tools/write.js +110 -8
  68. package/dist/tools/write.js.map +1 -1
  69. package/package.json +4 -4
@@ -0,0 +1,82 @@
1
+ /**
2
+ * GG Goals' own team: the only agents its workers can be, separate from GG
3
+ * Coder's bundled agents (core/bundled-agents.ts) and from any the user
4
+ * defines in `.gg/agents`. A goal works across the user's attached folders
5
+ * (often not code at all: job applications, an SEO plan), and its workers
6
+ * report to an orchestrator rather than a person at the keyboard, so their
7
+ * rules differ: change files in place for the user to review, never branch or
8
+ * commit, and stop to report a blocker instead of guessing. Keeping the
9
+ * roster fixed keeps those rules in force: a user's or project's agent of the
10
+ * same name never replaces them.
11
+ *
12
+ * `description` is the routing signal GG Goals reads in spawn_agent's roster,
13
+ * so each names the shape of task it's for.
14
+ */
15
+ /** Rules every member works by, ahead of its own role. */
16
+ const TEAM_RULES = `You're a worker on a GG Goals team. GG Goals, the coordinator, briefed you and sees only your final report; the user reads its summary.
17
+
18
+ ## How the team works
19
+ - Work in your working folder and the goal's other attached folders. Those are the only places you may change; never write anywhere else.
20
+ - Change files in place. Never create branches, commit, push, open pull requests or change git settings: the user reviews the work and commits it themselves.
21
+ - Do only your task. Other workers are on other parts of the goal at the same time, so leave files outside your task alone.
22
+ - Deliver the size the brief asks for. A minimum ("at least 1,000 words", "6 sources") is met by landing just past it, not by aiming well beyond it; a target ("about 800 words") means about that. Extra length, sections or sources aren't better work: they cost the user time and tokens.
23
+ - Never change the machine itself: no global installs (\`npm install -g\`, \`brew install\`, \`pip install\` outside a project's own environment), no system settings, no logging in to services. Installing a project's own dependencies inside its folder is fine. If the task needs more, report it as a blocker.
24
+ - If you reach a decision your brief doesn't settle (a choice only the user can make, missing access or credentials, a contradiction), stop and report it as a blocker: what you need, and the options you see with the one you'd pick. Never guess.
25
+
26
+ ## Checking your work
27
+ Don't read a file back after editing or writing it: the edit's own result already shows the change. Run each check (a test suite, a typecheck, the command itself) on its own as the last thing you do, as a plain command: \`npm test\`, not \`cd … && npm test; echo $?\`. Its exit code is what proves the work, to you and to the coordinator; a check wrapped in other commands proves nothing and gets run again by someone else.
28
+
29
+ ## Your report
30
+ Start with one line: done, blocked, or failed. Then what you did or found, with full file paths; how you checked it; and anything the coordinator must know (a blocker's options, a risk, something left undone). Keep it short and plain.`;
31
+ const BUILDER_ROLE = `## Your role: builder
32
+ You carry out one task end to end and leave a working result, not a description of one: code, documents, data, config, whatever the task needs.
33
+ 1. Read what the task touches first, and match how it's already done there.
34
+ 2. Make the change directly, as small and focused as the task allows.
35
+ 3. Check it: run the narrowest test, typecheck or command that proves it works; for writing, reread it against the brief. Fix what you broke.
36
+ 4. Report.`;
37
+ const SCOUT_ROLE = `## Your role: scout
38
+ You look and report; you never change anything. You answer what the brief asks about the attached folders: what's there, how it fits together, where something lives, what state it's in.
39
+ 1. Map the relevant folders with ls and find.
40
+ 2. Search with grep and code_search, then read the key files to confirm. Never report what you haven't read.
41
+ 3. Report the answer first, then the files that matter (path and one line each) and anything surprising.`;
42
+ const RESEARCHER_ROLE = `## Your role: researcher
43
+ You find out what the attached folders can't tell you, from the web: facts, options, prices, docs, examples, current information. You change nothing.
44
+ 1. Pin down the question and what would count as an answer.
45
+ 2. Search, then read the most authoritative sources (official sites and docs first).
46
+ 3. Report the answer first, then the evidence: every claim with the URL it came from, and where sources disagree. Never state from memory what you can look up.`;
47
+ const CHECKER_ROLE = `## Your role: checker
48
+ You make sure another worker's finished task really works and matches its brief, and you fix what doesn't, so it comes back done in one pass instead of bouncing between workers.
49
+ 1. Read the brief you're given and every file the work changed.
50
+ 2. Run the checks that prove it: the tests, a typecheck, the command itself, links and facts it relies on.
51
+ 3. Fix every problem you find that sits inside the task's own scope (a failing test, a wrong value, a missed requirement, a broken link), then run the checks again until they pass.
52
+ 4. Don't redo or extend the work, and don't fix anything outside the task. If a problem needs a real rework or a decision, report it as a blocker instead.
53
+ 5. Report: passed, or fixed (what was wrong and what you changed), or blocked; then the checks you ran and what they showed.`;
54
+ function member(name, description, tools, role) {
55
+ return {
56
+ name,
57
+ description,
58
+ tools,
59
+ model: "inherit",
60
+ systemPrompt: `${TEAM_RULES}\n\n${role}`,
61
+ source: "bundled",
62
+ };
63
+ }
64
+ export const GOAL_TEAM = [
65
+ member("builder", "Makes changes: writes and edits files, runs commands. For any task that produces or changes something.", [
66
+ "read",
67
+ "write",
68
+ "edit",
69
+ "bash",
70
+ "find",
71
+ "grep",
72
+ "ls",
73
+ "code_search",
74
+ "source_path",
75
+ "web_fetch",
76
+ "web_search",
77
+ ], BUILDER_ROLE),
78
+ member("scout", "Read-only look around the attached folders: what's there, where things are, what state they're in.", ["read", "find", "grep", "ls", "code_search", "source_path"], SCOUT_ROLE),
79
+ member("researcher", "Finds things out on the web: facts, options, docs, current information, with sources.", ["read", "find", "grep", "ls", "web_fetch", "web_search", "steroids"], RESEARCHER_ROLE),
80
+ member("checker", "Checks a finished task against its brief (runs tests, reads the changes) and fixes what's wrong, so it comes back done in one pass.", ["read", "write", "edit", "find", "grep", "ls", "code_search", "bash", "web_fetch"], CHECKER_ROLE),
81
+ ];
82
+ //# sourceMappingURL=goal-team.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-team.js","sourceRoot":"","sources":["../../src/goals-agent/goal-team.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,0DAA0D;AAC1D,MAAM,UAAU,GAAG;;;;;;;;;;;;;;2OAcwN,CAAC;AAE5O,MAAM,YAAY,GAAG;;;;;WAKV,CAAC;AAEZ,MAAM,UAAU,GAAG;;;;yGAIsF,CAAC;AAE1G,MAAM,eAAe,GAAG;;;;gKAIwI,CAAC;AAEjK,MAAM,YAAY,GAAG;;;;;;6HAMwG,CAAC;AAE9H,SAAS,MAAM,CAAC,IAAY,EAAE,WAAmB,EAAE,KAAe,EAAE,IAAY;IAC9E,OAAO;QACL,IAAI;QACJ,WAAW;QACX,KAAK;QACL,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,GAAG,UAAU,OAAO,IAAI,EAAE;QACxC,MAAM,EAAE,SAAS;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAA+B;IACnD,MAAM,CACJ,SAAS,EACT,wGAAwG,EACxG;QACE,MAAM;QACN,OAAO;QACP,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,IAAI;QACJ,aAAa;QACb,aAAa;QACb,WAAW;QACX,YAAY;KACb,EACD,YAAY,CACb;IACD,MAAM,CACJ,OAAO,EACP,oGAAoG,EACpG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,EAC5D,UAAU,CACX;IACD,MAAM,CACJ,YAAY,EACZ,uFAAuF,EACvF,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC,EACrE,eAAe,CAChB;IACD,MAAM,CACJ,SAAS,EACT,qIAAqI,EACrI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,EACnF,YAAY,CACb;CACF,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { AgentSession, type AgentSessionOptions } from "../core/agent-session.js";
2
+ import { type GoalBriefExtras, type GoalRecord } from "../core/goals-store.js";
3
+ import type { ChildModelPick } from "../core/subagent-manager.js";
4
+ /**
5
+ * Little Ken's faces in the Workers view's dialogue box. GG Goals picks one
6
+ * for the spoken line it ends a message with (`[ken:face] …`). Must match
7
+ * KEN_FACES in gg-app/src/goal-ken-talk.ts, which reads the line (an unknown
8
+ * face falls back to neutral there).
9
+ */
10
+ export declare const KEN_FACES: readonly ["neutral", "happy", "excited", "thinking", "focused", "surprised", "worried", "sad", "proud", "wink"];
11
+ /**
12
+ * GG Goals: the orchestrator a Goal window talks to. It is its own agent, not
13
+ * GG Coder with a note attached: its identity and the goal brief form its
14
+ * system prompt, it has no plan mode (it plans in the conversation), and its
15
+ * prompt cache is keyed apart from coding sessions.
16
+ */
17
+ export declare const GOALS_SYSTEM_PROMPT: string;
18
+ /** Agent tools GG Goals always has, instead of finding them via tool_search. */
19
+ export declare const GOALS_CORE_TOOLS: readonly string[];
20
+ export type GoalsAgentOptions = Omit<AgentSessionOptions, "agentPrompt" | "agentRole" | "agentContext" | "systemPrompt" | "promptCacheKeyPrefix" | "getSystemPromptTail" | "onEnterPlan" | "onExitPlan" | "planSubmissionGate" | "coreTools" | "wrapTool" | "withoutTools" | "subAgents" | "shareRootsWithSubAgents" | "defaultSubAgent"> & {
21
+ /** The goal this session coordinates; its folder is the session's cwd. */
22
+ goal: {
23
+ dir: string;
24
+ record: GoalRecord;
25
+ };
26
+ /** Memory and attached projects' rules, read once for the session (see loadGoalBriefExtras). */
27
+ extras?: GoalBriefExtras;
28
+ /** True once the user has started the goal. Read live: the phase changes mid-session. */
29
+ isActive?: () => boolean;
30
+ /** The workers' model. Read at each spawn: the user can change it any time. */
31
+ getChildModel?: () => ChildModelPick | undefined;
32
+ };
33
+ /**
34
+ * The model GG Goals' workers ("critters") run on, from the goal's pick. A
35
+ * pick whose model is gone from the registry, or now belongs to a different
36
+ * provider, is ignored, so workers fall back to GG Goals' own model.
37
+ */
38
+ export declare function goalCritterPick(record: GoalRecord | undefined): ChildModelPick | undefined;
39
+ /** GG Goals' full prompt body: identity first, then this goal's brief. */
40
+ export declare function buildGoalsAgentPrompt(goal: {
41
+ dir: string;
42
+ record: GoalRecord;
43
+ }, extras?: GoalBriefExtras): string;
44
+ /**
45
+ * Read what GG Goals' brief carries besides the goal, once per session: its
46
+ * memory, and each attached folder's instruction files (AGENTS.md, CLAUDE.md…).
47
+ * GG Goals' own cwd is the goal folder, so without this it never saw the rules
48
+ * of the projects it works in. A folder that can't be read just has no rules.
49
+ */
50
+ export declare function loadGoalBriefExtras(goal: {
51
+ dir: string;
52
+ record: GoalRecord;
53
+ }): Promise<GoalBriefExtras>;
54
+ /**
55
+ * Tools that do or start work: held until the user starts the goal, then
56
+ * GG Goals' own. It does small and connected work itself (a worker starts
57
+ * cold and re-reads everything; live runs showed one session beating a
58
+ * single worker on every such goal), and starts workers for big independent
59
+ * parts. Same tool schemas either way, so the cached tool block never changes.
60
+ */
61
+ export declare const GOALS_START_TOOLS: ReadonlySet<string>;
62
+ /**
63
+ * Tools GG Goals never has: UI component adoption and image generation (not
64
+ * part of a goal's work), and the one-shot \`subagent\`, which always runs in
65
+ * GG Goals' own goal folder and can't be pointed at an attached folder;
66
+ * spawn_agent is the only way it starts workers.
67
+ */
68
+ export declare const GOALS_WITHOUT_TOOLS: readonly string[];
69
+ /** What editing, running or starting work returns during the briefing. */
70
+ export declare const BRIEFING_ERROR = "Not yet: the goal hasn't started. During the briefing you only read (read, ls, find, web search) and ask. Editing, running commands and starting workers open once the user starts the goal. If the user has told you to go ahead, ask the start question now with ask_user (the goal starts when they pick it); never begin the work before that.";
71
+ /** Error text ask_user returns while GG Goals has not spoken yet. */
72
+ export declare const GREET_FIRST_ERROR = "Not yet: write to the user first. Greet them and say the goal back in your own words as a normal message, then ask.";
73
+ /**
74
+ * Hold ask_user until GG Goals has written something to the user. A question
75
+ * card as the very first thing in a new goal reads as an interrogation, and a
76
+ * card shown before the turn's text would sit above the greeting. Once there
77
+ * is any assistant text (this run or an earlier one), the tool is untouched.
78
+ */
79
+ /**
80
+ * Added to the answer that starts the goal. The kickoff told GG Goals not to
81
+ * start work in its first reply, and the start question usually rides on that
82
+ * same reply's card: without this it stopped right after the user started the
83
+ * goal (live run, "Add a blog"), and the goal sat idle.
84
+ */
85
+ export declare const GOAL_STARTED_NOTE = "\n\nThe goal has started. Start the work now, in this reply: do it yourself, or start workers for its big independent parts.";
86
+ /**
87
+ * Create a GG Goals session. Sessions are stored like coding sessions, keyed by
88
+ * the goal folder, so the goal list and goal deletion find them there.
89
+ */
90
+ export declare function createGoalsAgentSession(options: GoalsAgentOptions): AgentSession;
@@ -0,0 +1,246 @@
1
+ import { AgentSession } from "../core/agent-session.js";
2
+ import { readGoalMemory, renderGoalPrompt, } from "../core/goals-store.js";
3
+ import { collectProjectContext } from "../system-prompt.js";
4
+ import { getModel } from "../core/model-registry.js";
5
+ import { GOAL_TEAM } from "./goal-team.js";
6
+ /**
7
+ * Little Ken's faces in the Workers view's dialogue box. GG Goals picks one
8
+ * for the spoken line it ends a message with (`[ken:face] …`). Must match
9
+ * KEN_FACES in gg-app/src/goal-ken-talk.ts, which reads the line (an unknown
10
+ * face falls back to neutral there).
11
+ */
12
+ export const KEN_FACES = [
13
+ "neutral",
14
+ "happy",
15
+ "excited",
16
+ "thinking",
17
+ "focused",
18
+ "surprised",
19
+ "worried",
20
+ "sad",
21
+ "proud",
22
+ "wink",
23
+ ];
24
+ /**
25
+ * GG Goals: the orchestrator a Goal window talks to. It is its own agent, not
26
+ * GG Coder with a note attached: its identity and the goal brief form its
27
+ * system prompt, it has no plan mode (it plans in the conversation), and its
28
+ * prompt cache is keyed apart from coding sessions.
29
+ */
30
+ export const GOALS_SYSTEM_PROMPT = `You are GG Goals, inside GG Coder. The user hands you a goal and may walk away until it's done, and you own it end to end: you understand it, agree the approach with the user up front, get the work done (yourself, or with a team of workers when the work splits into big independent parts), and keep the user informed until the goal is met.
31
+
32
+ ## How you work
33
+
34
+ - One goal, one ongoing conversation. Treat earlier messages as shared history, not as a fresh request.
35
+ - Before the goal starts you only read (read, ls, find, web search) and ask; editing, writing, running commands and starting workers open once the user starts it.
36
+ - Do the work yourself by default: you already know the goal and have read what matters, while a worker starts cold and re-reads everything. That covers anything connected (one project, one document, one report), anything you can finish in a few minutes, and research you can do with a few searches. Never start a single worker for work you could do yourself.
37
+ - Start workers only for parts that are big and independent of each other, two or more at once so they run side by side: separate projects or repos, separate research topics that each need many searches, separate large documents. Do any small or connected part yourself while they run.
38
+ - When you do the work yourself, work like your team does: change files in place (never branch, commit or push), never change the machine itself (no global installs or logins), don't read a file back after editing it, prove it with the narrowest check (a test, a build, the command itself) run as a plain command (chain checks only with &&: a check behind ; or || or in a loop can hide a failure, so it doesn't count and has to be run again), and give the URL of every source you rely on in research.
39
+ - Your team (spawn_agent's agent): builder makes changes (writes, edits, runs commands); scout looks around the attached folders without changing anything; researcher finds things out on the web, with sources; checker checks a finished task and fixes what's wrong in the same pass. Workers change files in place for the user to review; they never branch or commit.
40
+ - Size the team to the work: every extra worker costs a fresh start and re-reads, so split only into parts that are independent and each substantial, and start those workers together in one spawn_agent call. Give each worker everything its part needs (its tests, its section of the docs, its piece of a shared file) rather than saving that for a final worker after the rest: a final step waits for every other worker and then starts from scratch. Keep a final worker only for work that truly needs all the parts done, like a write-up drawing on all the research. Brief each worker fully, as it sees nothing of this conversation: the goal, the exact files or area, constraints, and what to report back. Set each worker's cwd to the attached folder it mostly works in; every worker can also reach the goal's other attached folders. List the files a worker needs that you've already read in its context_files, so it starts with their contents instead of reading them again; name any others by full path in the brief. Attached files are for reading (to change one, the user attaches its folder). Keep briefs to what to do and what done looks like, at the size the user asked for: never raise a target or widen the scope in a brief (a minimum stays the minimum, not a floor to aim past; a "cover the states" answer is not a 50-state table), since every extra is paid for in time and tokens, and a fix round should only close a real gap against what was asked. Workers already know to stop and report a blocker rather than guess.
41
+ - Handle each worker the moment it finishes, not when they all have. Wait with wait_agent using condition "any" (never "all" while there is other work to hand out): check that worker's report, give it its next task with followup_task or start a new worker, then wait again for the rest. Steer a running worker with send_message, and stop one that has gone off track with interrupt_agent.
42
+ - Check what a worker reports before you rely on it. When its checks passed and the report is clear, rely on it; read its output yourself only when something wasn't verified or you need its content for your summary. Send a checker only for important work you can't check by reading. When a task has a check that proves it (a test suite, a build, a command), name it in spawn_agent's checks (command_passed, written as the worker runs it in its cwd, like \`npm test\`; plus file_exists or file_changed for what it makes), so it's verified when the worker finishes; never send a checker just to re-run a command the builder already ran. A checker fixes what it finds itself, so never send a builder after a checker to fix its findings.
43
+ - Keep rounds few: each task gets at most one fix round (a followup_task to the same worker, which keeps what it learned, or one checker). If it still isn't right after that, stop and tell the user what's wrong rather than going back and forth.
44
+ - When a worker fails, times out or reports it couldn't finish, find out why from its report. If it was a passing error or a weak brief, retry once: followup_task on the same worker if it stopped normally (it keeps what it learned), or a fresh worker with a sharper brief if it crashed or timed out (a crashed worker is closed and can't take a follow-up). If it fails again, or only the user can fix the cause, stop that piece of work and tell the user plainly what failed and what you need. Never drop failed work quietly or count it as done.
45
+ - When a worker reports a blocker, settle it yourself if the goal and this conversation already answer it, and send the answer with followup_task. Otherwise ask the user with ask_user, and keep the other workers going while you wait for their answer.
46
+ - Work that needs the user's own accounts or machine (a login, credentials, installing software system-wide, payments) belongs in the briefing, before the start: find out then what's installed and whether they're signed in, by asking. If after the start it turns out to be missing, stop that piece of work and tell the user what they need to do; never have a worker install or sign in on their behalf.
47
+ - Once the goal has started, the user may be away: ask them only when work can't go on without a decision only they can make. Settle small follow-on choices yourself (tidying, naming, an obvious next step inside the goal) and say what you chose in your summary; offer optional extras in the summary instead of asking.
48
+ - When the user messages you while workers are running, answer them first in a short message (where each piece of work stands), then go back to waiting. Never leave a message unanswered until the end.
49
+ - Before your final summary, collect every finished worker's report (wait_agent with their agent_ids), so you write the summary once, complete.
50
+ - Ask the user only for what you cannot look up.
51
+ - Be exact about status. Never say something is done, fixed or verified unless you checked it, and say plainly when something could not be checked.
52
+ - Keep the user in the loop without flooding them: short updates when something finishes, needs a decision, or is blocked.
53
+
54
+ ## Talking to the user
55
+
56
+ Plain words, short paragraphs, no jargon the user did not use. Lead with the answer or the outcome. Use ask_user for real decisions, with your recommendation marked; never ask in prose what a clickable choice can answer.
57
+
58
+ ## Your line on the farm
59
+
60
+ Once the goal has started, the user often watches the Workers view instead of the chat, where you are little Ken on a farm with a dialogue box that pops up now and then. Short progress notes between tool calls are said there as they are, so keep those to one plain sentence or two. After the start, the message that ends your turn (your summary, a blocker, a question) always ends with one spoken line for it, as its very last line and nowhere else, in exactly this form:
61
+
62
+ [ken:face] what you'd say out loud
63
+
64
+ - face is one of: ${KEN_FACES.join(", ")}. Match the moment: focused while working, happy when a part is done, proud when a result beats the target, surprised when you find something, worried about a risk, sad when something failed, excited when the goal is reached, thinking when weighing a choice, wink for a tip, neutral otherwise.
65
+ - The line is one or two short sentences (under 120 characters) of plain speech, the gist for someone glancing over: no Markdown, tables, code, file paths or links. For example: [ken:happy] Images done. Mobile load is down to 1.4 seconds.
66
+ - The chat hides this line, so never refer to it, and keep everything the user needs in the message itself. Skip it before the start.`;
67
+ /** Agent tools GG Goals always has, instead of finding them via tool_search. */
68
+ export const GOALS_CORE_TOOLS = [
69
+ "spawn_agent",
70
+ "wait_agent",
71
+ "send_message",
72
+ "followup_task",
73
+ "list_agents",
74
+ "interrupt_agent",
75
+ "web_search",
76
+ "web_fetch",
77
+ // Reading the attached context without a shell.
78
+ "find",
79
+ "ls",
80
+ ];
81
+ /**
82
+ * The model GG Goals' workers ("critters") run on, from the goal's pick. A
83
+ * pick whose model is gone from the registry, or now belongs to a different
84
+ * provider, is ignored, so workers fall back to GG Goals' own model.
85
+ */
86
+ export function goalCritterPick(record) {
87
+ const pick = record?.critterModel;
88
+ if (!pick)
89
+ return undefined;
90
+ const model = getModel(pick.model);
91
+ if (!model || model.provider !== pick.provider)
92
+ return undefined;
93
+ return { provider: model.provider, model: model.id };
94
+ }
95
+ /** GG Goals' full prompt body: identity first, then this goal's brief. */
96
+ export function buildGoalsAgentPrompt(goal, extras = {}) {
97
+ return `${GOALS_SYSTEM_PROMPT}\n\n${renderGoalPrompt(goal.dir, goal.record, extras)}`;
98
+ }
99
+ /**
100
+ * Read what GG Goals' brief carries besides the goal, once per session: its
101
+ * memory, and each attached folder's instruction files (AGENTS.md, CLAUDE.md…).
102
+ * GG Goals' own cwd is the goal folder, so without this it never saw the rules
103
+ * of the projects it works in. A folder that can't be read just has no rules.
104
+ */
105
+ export async function loadGoalBriefExtras(goal) {
106
+ const folders = goal.record.context.filter((item) => item.kind === "folder");
107
+ const [memory, projectRules] = await Promise.all([
108
+ readGoalMemory(goal.dir),
109
+ Promise.all(folders.map(async (item) => ({
110
+ folder: item.path,
111
+ rules: await collectProjectContext(item.path).catch(() => []),
112
+ }))),
113
+ ]);
114
+ return { memory, projectRules };
115
+ }
116
+ /**
117
+ * Tools that do or start work: held until the user starts the goal, then
118
+ * GG Goals' own. It does small and connected work itself (a worker starts
119
+ * cold and re-reads everything; live runs showed one session beating a
120
+ * single worker on every such goal), and starts workers for big independent
121
+ * parts. Same tool schemas either way, so the cached tool block never changes.
122
+ */
123
+ export const GOALS_START_TOOLS = new Set([
124
+ "edit",
125
+ "write",
126
+ "bash",
127
+ "spawn_agent",
128
+ "followup_task",
129
+ ]);
130
+ /**
131
+ * Tools GG Goals never has: UI component adoption and image generation (not
132
+ * part of a goal's work), and the one-shot \`subagent\`, which always runs in
133
+ * GG Goals' own goal folder and can't be pointed at an attached folder;
134
+ * spawn_agent is the only way it starts workers.
135
+ */
136
+ export const GOALS_WITHOUT_TOOLS = ["ui_adopt", "generate_image", "subagent"];
137
+ /** What editing, running or starting work returns during the briefing. */
138
+ export const BRIEFING_ERROR = "Not yet: the goal hasn't started. During the briefing you only read (read, ls, find, web search) and ask. Editing, running commands and starting workers open once the user starts the goal. If the user has told you to go ahead, ask the start question now with ask_user (the goal starts when they pick it); never begin the work before that.";
139
+ /** Error text ask_user returns while GG Goals has not spoken yet. */
140
+ export const GREET_FIRST_ERROR = "Not yet: write to the user first. Greet them and say the goal back in your own words as a normal message, then ask.";
141
+ function hasAssistantText(messages) {
142
+ return messages.some((m) => m.role === "assistant" &&
143
+ (typeof m.content === "string"
144
+ ? m.content.trim().length > 0
145
+ : Array.isArray(m.content) &&
146
+ m.content.some((part) => typeof part === "object" &&
147
+ part !== null &&
148
+ part.type === "text" &&
149
+ typeof part.text === "string" &&
150
+ part.text.trim().length > 0)));
151
+ }
152
+ /**
153
+ * Hold ask_user until GG Goals has written something to the user. A question
154
+ * card as the very first thing in a new goal reads as an interrogation, and a
155
+ * card shown before the turn's text would sit above the greeting. Once there
156
+ * is any assistant text (this run or an earlier one), the tool is untouched.
157
+ */
158
+ /**
159
+ * Added to the answer that starts the goal. The kickoff told GG Goals not to
160
+ * start work in its first reply, and the start question usually rides on that
161
+ * same reply's card: without this it stopped right after the user started the
162
+ * goal (live run, "Add a blog"), and the goal sat idle.
163
+ */
164
+ export const GOAL_STARTED_NOTE = "\n\nThe goal has started. Start the work now, in this reply: do it yourself, or start workers for its big independent parts.";
165
+ /**
166
+ * GG Goals' ask_user: never before it has greeted the user, and the answer
167
+ * that starts the goal comes back with GOAL_STARTED_NOTE.
168
+ */
169
+ function goalAskUser(tools, hasSpoken, isActive) {
170
+ return tools.map((tool) => tool.name !== "ask_user"
171
+ ? tool
172
+ : {
173
+ ...tool,
174
+ execute: async (args, context) => {
175
+ if (!hasSpoken())
176
+ throw new Error(GREET_FIRST_ERROR);
177
+ const wasActive = isActive();
178
+ const result = await tool.execute(args, context);
179
+ if (wasActive || !isActive())
180
+ return result;
181
+ if (typeof result === "string")
182
+ return result + GOAL_STARTED_NOTE;
183
+ const { content } = result;
184
+ return {
185
+ ...result,
186
+ content: typeof content === "string"
187
+ ? content + GOAL_STARTED_NOTE
188
+ : [...content, { type: "text", text: GOAL_STARTED_NOTE.trim() }],
189
+ };
190
+ },
191
+ });
192
+ }
193
+ /**
194
+ * Create a GG Goals session. Sessions are stored like coding sessions, keyed by
195
+ * the goal folder, so the goal list and goal deletion find them there.
196
+ */
197
+ export function createGoalsAgentSession(options) {
198
+ const { goal, extras, additionalTools = [], isActive = () => false, ...sessionOptions } = options;
199
+ let spokeThisSession = false;
200
+ // `getMessages()` is the conversation as of the last finished run, so text
201
+ // streamed in the current run is tracked live alongside it.
202
+ const hasSpoken = () => spokeThisSession || hasAssistantText(session.getMessages());
203
+ const session = new AgentSession({
204
+ ...sessionOptions,
205
+ additionalTools: goalAskUser(additionalTools, hasSpoken, isActive),
206
+ // The goal is static for a session, so its brief belongs in the cached
207
+ // prefix rather than a per-run tail.
208
+ agentPrompt: buildGoalsAgentPrompt(goal, extras),
209
+ // Talks to the user directly, so no sub-agent return contract.
210
+ agentRole: "primary",
211
+ // The goal folder holds notes, not a codebase; attached folders are added
212
+ // as workspace roots and read on demand.
213
+ agentContext: "none",
214
+ promptCacheKeyPrefix: "gggoals",
215
+ // Orchestrating is the job: bringing in workers, steering them and
216
+ // waiting on them must not need a tool_search first.
217
+ coreTools: GOALS_CORE_TOOLS,
218
+ withoutTools: GOALS_WITHOUT_TOOLS,
219
+ // Its own team (goal-team.ts), never GG Coder's or the user's agents,
220
+ // and each worker can reach every attached folder, not only its own.
221
+ subAgents: GOAL_TEAM,
222
+ shareRootsWithSubAgents: true,
223
+ // A worker started without naming an agent is still a team member.
224
+ defaultSubAgent: "builder",
225
+ // The team only starts once the user starts the goal. Same tool schemas
226
+ // either way, so the cached tool block never changes.
227
+ wrapTool: (tool) => {
228
+ if (!GOALS_START_TOOLS.has(tool.name))
229
+ return tool;
230
+ return {
231
+ ...tool,
232
+ execute: async (args, context) => {
233
+ if (!isActive())
234
+ throw new Error(BRIEFING_ERROR);
235
+ return tool.execute(args, context);
236
+ },
237
+ };
238
+ },
239
+ });
240
+ session.eventBus.on("text_delta", ({ text }) => {
241
+ if (text.trim())
242
+ spokeThisSession = true;
243
+ });
244
+ return session;
245
+ }
246
+ //# sourceMappingURL=goals-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goals-agent.js","sourceRoot":"","sources":["../../src/goals-agent/goals-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA4B,MAAM,0BAA0B,CAAC;AAClF,OAAO,EACL,cAAc,EACd,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS;IACT,OAAO;IACP,SAAS;IACT,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,KAAK;IACL,OAAO;IACP,MAAM;CACE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAkCf,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;sIAE8F,CAAC;AAE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AAC,CAAC;gBACrC,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7C,IAAI,IAAI,CAAC,IAAI,EAAE;YAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -31,11 +31,23 @@ export declare function classifyResolvedTurn(turn: {
31
31
  /** The limit the turn ran under, for the timeout message. Defaults to SUB_AGENT_TIMEOUT_MS. */
32
32
  timeLimitMs?: number;
33
33
  }): TurnOutcome;
34
+ /**
35
+ * Add the parent's shared roots to a child's workspace (see
36
+ * SubagentWorkerInitialize.additionalRoots). A root that's gone or already
37
+ * covered is skipped, never fatal: the child still has its own folder.
38
+ * Returns the roots added.
39
+ */
40
+ export declare function addSharedRoots(session: Pick<AgentSession, "addDirectory">, roots: readonly string[]): Promise<string[]>;
34
41
  export interface SubagentWorkerInitialize {
35
42
  provider: Provider;
36
43
  model: string;
37
44
  fallbackModel?: string;
38
45
  cwd: string;
46
+ /**
47
+ * More folders the child may read and change besides its cwd (the
48
+ * parent's shared workspace roots, see SubAgentManager.shareWorkspaceRoots).
49
+ */
50
+ additionalRoots?: string[];
39
51
  baseUrl?: string;
40
52
  /** Replaces the whole system prompt. */
41
53
  systemPrompt?: string;
@@ -1,5 +1,6 @@
1
1
  import { createInterface } from "node:readline";
2
2
  import { AgentSession } from "../core/agent-session.js";
3
+ import { log } from "../core/logger.js";
3
4
  import { isModelUnavailableError } from "../core/model-unavailable.js";
4
5
  import { boundSubAgentOutput, promptSubAgent, SUB_AGENT_MAX_TURN_EXTENSIONS, SUB_AGENT_TIMEOUT_MS, SUB_AGENT_TIMEOUT_RECOVERY_MS, subAgentThinkingLevel, } from "../tools/subagent-shared.js";
5
6
  import { writeTurnRecord } from "../core/subagent-turn-record.js";
@@ -63,6 +64,24 @@ export function classifyResolvedTurn(turn) {
63
64
  return { status: "failed", error: turn.loopError };
64
65
  return { status: "completed" };
65
66
  }
67
+ /**
68
+ * Add the parent's shared roots to a child's workspace (see
69
+ * SubagentWorkerInitialize.additionalRoots). A root that's gone or already
70
+ * covered is skipped, never fatal: the child still has its own folder.
71
+ * Returns the roots added.
72
+ */
73
+ export async function addSharedRoots(session, roots) {
74
+ const added = [];
75
+ for (const root of roots) {
76
+ const result = await session.addDirectory(root);
77
+ if (result.ok)
78
+ added.push(result.root);
79
+ else if (!result.error.startsWith("Already in the workspace")) {
80
+ log("WARN", "subagent-worker", "shared workspace root unavailable", { error: result.error });
81
+ }
82
+ }
83
+ return added;
84
+ }
66
85
  /** Set once our stdout pipe dies (parent restart). See runSubagentWorkerMode. */
67
86
  let orphaned = false;
68
87
  function emit(frame) {
@@ -164,7 +183,7 @@ export async function runSubagentWorkerMode() {
164
183
  }
165
184
  };
166
185
  const createSession = async (options) => {
167
- const { fallbackModel: _fallbackModel, childSessionPath, turnTimeoutMs: _turnTimeoutMs, ...sessionOptions } = options;
186
+ const { fallbackModel: _fallbackModel, childSessionPath, turnTimeoutMs: _turnTimeoutMs, additionalRoots = [], ...sessionOptions } = options;
168
187
  const next = new AgentSession({
169
188
  ...sessionOptions,
170
189
  maxTurns: 50,
@@ -177,6 +196,8 @@ export async function runSubagentWorkerMode() {
177
196
  });
178
197
  wireEvents(next);
179
198
  await next.initialize();
199
+ // Before the first turn, so the prompt names every root from the start.
200
+ await addSharedRoots(next, additionalRoots);
180
201
  return next;
181
202
  };
182
203
  const runTurn = (task, checks) => {
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-worker-mode.js","sourceRoot":"","sources":["../../src/modes/subagent-worker-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,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AO,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACnE,IAAI,UAAU,EAAE,CAAC;QACf,oEAAoE;QACpE,wEAAwE;QACxE,kEAAkE;QAClE,mDAAmD;QACnD,QAAQ,GAAG,IAAI,CAAC;QAChB,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,cAAc,CAAC;QAC7B,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACD,MAAM,OAAO,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
@@ -3,8 +3,21 @@ import { type ReadTracker } from "./read-tracker.js";
3
3
  import type { ToolOperations } from "./operations.js";
4
4
  /** Paths a command prints in full, or [] when it is not a pure file dump. */
5
5
  export declare function catTargets(command: string): string[];
6
+ /** A line-range view of one literal file path; `end` undefined means "to EOF". */
7
+ interface RangeTarget {
8
+ target: string;
9
+ start: number;
10
+ end: number;
11
+ }
12
+ /**
13
+ * Line-range views a command prints: `sed -n 'A,Bp' FILE`, `sed -n 'Ap' FILE`,
14
+ * `head -N FILE` and `head -n N FILE`. Exactly one literal file per command,
15
+ * nothing piped or redirected — the output must be the raw lines.
16
+ */
17
+ export declare function rangeTargets(command: string): RangeTarget[];
6
18
  /**
7
19
  * Record reads proven by one step's bash calls. Call with the tool results
8
20
  * exactly as appended to the transcript (post-trim).
9
21
  */
10
22
  export declare function recordBashReads(tracker: ReadTracker, cwd: string, ops: ToolOperations, toolCalls: readonly ToolCall[], toolResults: readonly ToolResult[]): Promise<string[]>;
23
+ export {};