@nac3/forge-cli 0.2.0-alpha.3 → 0.2.0-alpha.30

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 (162) hide show
  1. package/dist/bin/yf.d.ts.map +1 -1
  2. package/dist/bin/yf.js +27 -0
  3. package/dist/bin/yf.js.map +1 -1
  4. package/dist/chat/claude.d.ts +22 -15
  5. package/dist/chat/claude.d.ts.map +1 -1
  6. package/dist/chat/claude.js +75 -22
  7. package/dist/chat/claude.js.map +1 -1
  8. package/dist/chat/panel.d.ts.map +1 -1
  9. package/dist/chat/panel.js +692 -17
  10. package/dist/chat/panel.js.map +1 -1
  11. package/dist/chat/server.js +630 -32
  12. package/dist/chat/server.js.map +1 -1
  13. package/dist/chat/spec_extract.d.ts.map +1 -1
  14. package/dist/chat/spec_extract.js +39 -0
  15. package/dist/chat/spec_extract.js.map +1 -1
  16. package/dist/chat/tools/audit_consumers.d.ts +66 -0
  17. package/dist/chat/tools/audit_consumers.d.ts.map +1 -0
  18. package/dist/chat/tools/audit_consumers.js +231 -0
  19. package/dist/chat/tools/audit_consumers.js.map +1 -0
  20. package/dist/chat/tools/git.js +4 -4
  21. package/dist/chat/tools/github.js +3 -3
  22. package/dist/chat/tools/lifecycle.js +3 -3
  23. package/dist/chat/tools/manual.js +1 -1
  24. package/dist/chat/tools/reader.js +8 -8
  25. package/dist/chat/tools/workflow.d.ts +45 -0
  26. package/dist/chat/tools/workflow.d.ts.map +1 -0
  27. package/dist/chat/tools/workflow.js +404 -0
  28. package/dist/chat/tools/workflow.js.map +1 -0
  29. package/dist/chat/tools.d.ts.map +1 -1
  30. package/dist/chat/tools.js +23 -4
  31. package/dist/chat/tools.js.map +1 -1
  32. package/dist/commands/approve.d.ts +32 -0
  33. package/dist/commands/approve.d.ts.map +1 -0
  34. package/dist/commands/approve.js +198 -0
  35. package/dist/commands/approve.js.map +1 -0
  36. package/dist/commands/block.d.ts +28 -0
  37. package/dist/commands/block.d.ts.map +1 -0
  38. package/dist/commands/block.js +189 -0
  39. package/dist/commands/block.js.map +1 -0
  40. package/dist/commands/bootstrap.d.ts +35 -0
  41. package/dist/commands/bootstrap.d.ts.map +1 -0
  42. package/dist/commands/bootstrap.js +205 -0
  43. package/dist/commands/bootstrap.js.map +1 -0
  44. package/dist/commands/chat.d.ts +3 -0
  45. package/dist/commands/chat.d.ts.map +1 -1
  46. package/dist/commands/chat.js +46 -1
  47. package/dist/commands/chat.js.map +1 -1
  48. package/dist/commands/clarify.d.ts +30 -0
  49. package/dist/commands/clarify.d.ts.map +1 -0
  50. package/dist/commands/clarify.js +671 -0
  51. package/dist/commands/clarify.js.map +1 -0
  52. package/dist/commands/discover.d.ts +30 -0
  53. package/dist/commands/discover.d.ts.map +1 -0
  54. package/dist/commands/discover.js +178 -0
  55. package/dist/commands/discover.js.map +1 -0
  56. package/dist/commands/doctor.js +94 -42
  57. package/dist/commands/doctor.js.map +1 -1
  58. package/dist/commands/keys_setup.d.ts +53 -0
  59. package/dist/commands/keys_setup.d.ts.map +1 -0
  60. package/dist/commands/keys_setup.js +487 -0
  61. package/dist/commands/keys_setup.js.map +1 -0
  62. package/dist/commands/legacy-audit.d.ts +34 -0
  63. package/dist/commands/legacy-audit.d.ts.map +1 -0
  64. package/dist/commands/legacy-audit.js +270 -0
  65. package/dist/commands/legacy-audit.js.map +1 -0
  66. package/dist/commands/license.d.ts.map +1 -1
  67. package/dist/commands/license.js +41 -0
  68. package/dist/commands/license.js.map +1 -1
  69. package/dist/commands/operate.d.ts +22 -0
  70. package/dist/commands/operate.d.ts.map +1 -0
  71. package/dist/commands/operate.js +523 -0
  72. package/dist/commands/operate.js.map +1 -0
  73. package/dist/commands/spec.d.ts +38 -0
  74. package/dist/commands/spec.d.ts.map +1 -0
  75. package/dist/commands/spec.js +256 -0
  76. package/dist/commands/spec.js.map +1 -0
  77. package/dist/commands/support.d.ts +22 -0
  78. package/dist/commands/support.d.ts.map +1 -0
  79. package/dist/commands/support.js +143 -0
  80. package/dist/commands/support.js.map +1 -0
  81. package/dist/commands/triage.d.ts +34 -0
  82. package/dist/commands/triage.d.ts.map +1 -0
  83. package/dist/commands/triage.js +228 -0
  84. package/dist/commands/triage.js.map +1 -0
  85. package/dist/commands/vault-inventory.d.ts +30 -0
  86. package/dist/commands/vault-inventory.d.ts.map +1 -0
  87. package/dist/commands/vault-inventory.js +214 -0
  88. package/dist/commands/vault-inventory.js.map +1 -0
  89. package/dist/commands/vault.d.ts.map +1 -1
  90. package/dist/commands/vault.js +5 -0
  91. package/dist/commands/vault.js.map +1 -1
  92. package/dist/commands/voice.js +1 -1
  93. package/dist/commands/voice.js.map +1 -1
  94. package/dist/commands/workflow-coverage.d.ts +30 -0
  95. package/dist/commands/workflow-coverage.d.ts.map +1 -0
  96. package/dist/commands/workflow-coverage.js +138 -0
  97. package/dist/commands/workflow-coverage.js.map +1 -0
  98. package/dist/core/keys_envelope.d.ts +13 -0
  99. package/dist/core/keys_envelope.d.ts.map +1 -1
  100. package/dist/core/keys_envelope.js.map +1 -1
  101. package/dist/deploy/adapter.d.ts +93 -0
  102. package/dist/deploy/adapter.d.ts.map +1 -0
  103. package/dist/deploy/adapter.js +42 -0
  104. package/dist/deploy/adapter.js.map +1 -0
  105. package/dist/deploy/aws_adapter.d.ts +28 -0
  106. package/dist/deploy/aws_adapter.d.ts.map +1 -0
  107. package/dist/deploy/aws_adapter.js +98 -0
  108. package/dist/deploy/aws_adapter.js.map +1 -0
  109. package/dist/deploy/cloudflare.d.ts +24 -0
  110. package/dist/deploy/cloudflare.d.ts.map +1 -0
  111. package/dist/deploy/cloudflare.js +169 -0
  112. package/dist/deploy/cloudflare.js.map +1 -0
  113. package/dist/license/hito4_client.d.ts +17 -1
  114. package/dist/license/hito4_client.d.ts.map +1 -1
  115. package/dist/license/hito4_client.js +71 -10
  116. package/dist/license/hito4_client.js.map +1 -1
  117. package/dist/license/index.d.ts.map +1 -1
  118. package/dist/license/index.js +7 -0
  119. package/dist/license/index.js.map +1 -1
  120. package/dist/license/sync.d.ts +54 -0
  121. package/dist/license/sync.d.ts.map +1 -0
  122. package/dist/license/sync.js +131 -0
  123. package/dist/license/sync.js.map +1 -0
  124. package/dist/support/reports.d.ts +31 -0
  125. package/dist/support/reports.d.ts.map +1 -0
  126. package/dist/support/reports.js +162 -0
  127. package/dist/support/reports.js.map +1 -0
  128. package/dist/telemetry/usage.d.ts +67 -0
  129. package/dist/telemetry/usage.d.ts.map +1 -0
  130. package/dist/telemetry/usage.js +208 -0
  131. package/dist/telemetry/usage.js.map +1 -0
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.d.ts.map +1 -1
  134. package/dist/version.js +1 -1
  135. package/dist/version.js.map +1 -1
  136. package/dist/voice/intents.d.ts +1 -1
  137. package/dist/voice/intents.js +0 -0
  138. package/dist/voice/providers/google.d.ts +9 -0
  139. package/dist/voice/providers/google.d.ts.map +1 -1
  140. package/dist/voice/providers/google.js +204 -28
  141. package/dist/voice/providers/google.js.map +1 -1
  142. package/dist/voice/router.d.ts +10 -0
  143. package/dist/voice/router.d.ts.map +1 -1
  144. package/dist/voice/router.js +39 -20
  145. package/dist/voice/router.js.map +1 -1
  146. package/dist/voice/types.d.ts +5 -2
  147. package/dist/voice/types.d.ts.map +1 -1
  148. package/dist/voice/types.js.map +1 -1
  149. package/dist/workflow/state.d.ts +190 -0
  150. package/dist/workflow/state.d.ts.map +1 -0
  151. package/dist/workflow/state.js +119 -0
  152. package/dist/workflow/state.js.map +1 -0
  153. package/package.json +13 -15
  154. package/templates/nextjs-app/README.md +48 -0
  155. package/templates/nextjs-app/next.config.js +8 -0
  156. package/templates/nextjs-app/package.json +33 -0
  157. package/templates/nextjs-app/src/app/globals.css +43 -0
  158. package/templates/nextjs-app/src/app/layout.tsx +29 -0
  159. package/templates/nextjs-app/src/app/page.tsx +63 -0
  160. package/templates/nextjs-app/src/nac/manifest.ts +36 -0
  161. package/templates/nextjs-app/tsconfig.json +21 -0
  162. package/templates/nextjs-app/yujin.forge.json +11 -0
@@ -0,0 +1,231 @@
1
+ /**
2
+ * forge_audit_consumers -- internal Forge tool to prevent
3
+ * producer/consumer desynchronization (SQ Sec X "Producer/Consumer
4
+ * Symmetry").
5
+ *
6
+ * Forge calls this BEFORE committing any change that touches a
7
+ * shared data structure (vault slot, JSON key, env var, tool name,
8
+ * endpoint contract, type / interface name, file format). The tool
9
+ * does a deterministic grep across src/ + tests/ + docs/ and
10
+ * returns every location that reads or writes the concept, so
11
+ * Forge can verify all readers are in sync with the new writer
12
+ * shape (and, if not, fix them in the same commit).
13
+ *
14
+ * This tool is the operational arm of SQ Sec X. Forge is expected
15
+ * to use it autonomously -- the user is never prompted to interpret
16
+ * the output; Forge interprets it and acts.
17
+ *
18
+ * The grep is pure file-system + glob; no LLM, no external services.
19
+ * Runs in < 1 second on the Forge tree itself (~10k files).
20
+ *
21
+ * Background: on 2026-05-29 the BYOK keys_setup refactor (290db8a)
22
+ * introduced provider_keys.json as the canonical key writer, but
23
+ * three downstream readers (chat resolveApiKey, Google STT provider,
24
+ * Google TTS provider) were not updated in the same commit. Each
25
+ * was patched independently (alpha.6 -> alpha.7 -> alpha.8). Had
26
+ * Forge run forge_audit_consumers('anthropic_api_key') and
27
+ * ('google_stt_key' / 'google_tts_key') before alpha.4 publish,
28
+ * the desync would have been caught up-front.
29
+ *
30
+ * ASCII-only.
31
+ */
32
+ import { promises as fs } from 'node:fs';
33
+ import path from 'node:path';
34
+ export const AUDIT_CONSUMERS_SPEC = {
35
+ name: 'forge_audit_consumers',
36
+ description: 'Enumerate every file in the project that reads OR writes the '
37
+ + 'given concept (env var name, JSON key, type identifier, tool '
38
+ + 'name, vault slot, etc). Use this BEFORE any commit that '
39
+ + 'changes a shared data structure to verify all consumers are '
40
+ + 'in sync with the new producer shape. Returns hits classified '
41
+ + 'as write / read / test / doc with file path and line number. '
42
+ + 'Pure grep, no LLM. Required by SQ Sec X "Producer/Consumer '
43
+ + 'Symmetry".',
44
+ input_schema: {
45
+ type: 'object',
46
+ properties: {
47
+ concept: {
48
+ type: 'string',
49
+ description: 'The identifier to grep for. Examples: '
50
+ + '"anthropic_api_key" / "google_tts_key" / '
51
+ + '"forge_git_commit" / "provider_keys.json" / '
52
+ + 'an exported type name.',
53
+ },
54
+ include_tests: {
55
+ type: 'boolean',
56
+ description: 'Include tests/ in the search. Default true.',
57
+ },
58
+ include_docs: {
59
+ type: 'boolean',
60
+ description: 'Include docs/ in the search. Default true.',
61
+ },
62
+ max_hits: {
63
+ type: 'number',
64
+ description: 'Cap on hits returned. Default 200. If exceeded, Forge '
65
+ + 'should narrow the concept (it may be too generic).',
66
+ },
67
+ },
68
+ required: ['concept'],
69
+ },
70
+ requires_approval: false,
71
+ };
72
+ const SCAN_ROOTS = ['src', 'tests', 'docs', 'packages', 'apps'];
73
+ const SKIP_DIRS = new Set([
74
+ 'node_modules', 'dist', 'build', '.git', '.next', '.expo', '.wrangler',
75
+ 'coverage', '.cache', '.vitest', 'android', 'ios', '_deploy_stage',
76
+ ]);
77
+ const TEXT_EXTS = new Set([
78
+ '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs',
79
+ '.json', '.yml', '.yaml', '.md', '.html', '.css',
80
+ '.php', '.py', '.sql', '.sh', '.toml', '.env',
81
+ ]);
82
+ const WRITE_PATTERNS = [
83
+ /\bwrite\b/i,
84
+ /\b(set|put|store|persist|save|insert|create)\b/i,
85
+ /=\s*$/, // assignment at end of line
86
+ /:\s*['"`]/, // JSON-like field setting
87
+ ];
88
+ const READ_PATTERNS = [
89
+ /\b(read|get|fetch|load|parse|consume|use)\b/i,
90
+ /\bif\b.*\b(has|includes|in)\b/i,
91
+ ];
92
+ function classifyHit(filePath, snippet) {
93
+ const lower = filePath.toLowerCase();
94
+ if (lower.includes('test') || lower.includes('spec'))
95
+ return 'test';
96
+ if (lower.startsWith('docs/') || lower.startsWith('docs\\')
97
+ || lower.endsWith('.md') || lower.endsWith('.html'))
98
+ return 'doc';
99
+ for (const re of WRITE_PATTERNS) {
100
+ if (re.test(snippet))
101
+ return 'write';
102
+ }
103
+ for (const re of READ_PATTERNS) {
104
+ if (re.test(snippet))
105
+ return 'read';
106
+ }
107
+ return 'unknown';
108
+ }
109
+ async function walkAndSearch(root, rel, needle, out, limit) {
110
+ if (out.length >= limit)
111
+ return;
112
+ let entries;
113
+ try {
114
+ entries = await fs.readdir(root, { withFileTypes: true });
115
+ }
116
+ catch {
117
+ return;
118
+ }
119
+ for (const entry of entries) {
120
+ if (out.length >= limit)
121
+ return;
122
+ if (SKIP_DIRS.has(entry.name))
123
+ continue;
124
+ const childPath = path.join(root, entry.name);
125
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
126
+ if (entry.isDirectory()) {
127
+ await walkAndSearch(childPath, childRel, needle, out, limit);
128
+ continue;
129
+ }
130
+ if (!entry.isFile())
131
+ continue;
132
+ const ext = path.extname(entry.name).toLowerCase();
133
+ if (!TEXT_EXTS.has(ext))
134
+ continue;
135
+ let contents;
136
+ try {
137
+ contents = await fs.readFile(childPath, 'utf-8');
138
+ }
139
+ catch {
140
+ continue;
141
+ }
142
+ if (!needle.test(contents))
143
+ continue;
144
+ needle.lastIndex = 0;
145
+ const lines = contents.split(/\r?\n/);
146
+ for (let i = 0; i < lines.length; i++) {
147
+ const line = lines[i];
148
+ if (line === undefined)
149
+ continue;
150
+ if (!needle.test(line)) {
151
+ needle.lastIndex = 0;
152
+ continue;
153
+ }
154
+ needle.lastIndex = 0;
155
+ const snippet = line.length > 200 ? line.slice(0, 200) : line;
156
+ out.push({
157
+ file: childRel,
158
+ line: i + 1,
159
+ snippet,
160
+ kind: classifyHit(childRel, snippet),
161
+ });
162
+ if (out.length >= limit)
163
+ return;
164
+ }
165
+ }
166
+ }
167
+ /** Build a regex that matches the concept as a whole word.
168
+ * Escapes regex metacharacters in the input so the user can
169
+ * pass "provider_keys.json" or "forge.X" without issue. */
170
+ function buildNeedle(concept) {
171
+ const escaped = concept.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
172
+ /* Word-boundary-like (\b does not work for things containing
173
+ * underscores in modern JS, so use a manual class). */
174
+ return new RegExp(`(?:^|[^a-zA-Z0-9_])${escaped}(?:$|[^a-zA-Z0-9_])`, 'gm');
175
+ }
176
+ export async function runAuditConsumers(args, ctx) {
177
+ const concept = String(args.concept || '').trim();
178
+ if (concept === '') {
179
+ return {
180
+ tool: AUDIT_CONSUMERS_SPEC.name,
181
+ is_error: true,
182
+ result: { error: 'concept (non-empty string) required' },
183
+ display: 'bad input',
184
+ };
185
+ }
186
+ const includeTests = args.include_tests !== false;
187
+ const includeDocs = args.include_docs !== false;
188
+ const limit = typeof args.max_hits === 'number' && args.max_hits > 0
189
+ ? Math.floor(args.max_hits) : 200;
190
+ const needle = buildNeedle(concept);
191
+ const hits = [];
192
+ for (const root of SCAN_ROOTS) {
193
+ if (root === 'tests' && !includeTests)
194
+ continue;
195
+ if (root === 'docs' && !includeDocs)
196
+ continue;
197
+ const abs = path.join(ctx.projectRoot, root);
198
+ try {
199
+ await fs.access(abs);
200
+ }
201
+ catch {
202
+ continue;
203
+ }
204
+ await walkAndSearch(abs, root, needle, hits, limit + 1);
205
+ }
206
+ const truncated = hits.length > limit;
207
+ if (truncated)
208
+ hits.length = limit;
209
+ const summary = { write: 0, read: 0, test: 0, doc: 0, unknown: 0 };
210
+ for (const h of hits)
211
+ summary[h.kind] += 1;
212
+ const result = {
213
+ concept,
214
+ hits,
215
+ truncated,
216
+ summary,
217
+ };
218
+ const displayParts = [
219
+ `${hits.length} hit(s) on "${concept}"`,
220
+ `write=${summary.write} read=${summary.read} test=${summary.test} doc=${summary.doc}`,
221
+ ];
222
+ if (truncated)
223
+ displayParts.push('(truncated)');
224
+ return {
225
+ tool: AUDIT_CONSUMERS_SPEC.name,
226
+ is_error: false,
227
+ result: result,
228
+ display: displayParts.join(' / '),
229
+ };
230
+ }
231
+ //# sourceMappingURL=audit_consumers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit_consumers.js","sour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,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtC,IAAI,SAAS;QAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IAEnC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACnE,KAAK,MAAM,CAAC,IAAI,IAAI;QAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAgB;QAC1B,OAAO;QACP,IAAI;QACJ,SAAS;QACT,OAAO;KACR,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,GAAG,IAAI,CAAC,MAAM,eAAe,OAAO,GAAG;QACvC,SAAS,OAAO,CAAC,KAAK,SAAS,OAAO,CAAC,IAAI,SAAS,OAAO,CAAC,IAAI,QAAQ,OAAO,CAAC,GAAG,EAAE;KACtF,CAAC;IACF,IAAI,SAAS;QAAE,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAEhD,OAAO;QACL,IAAI,EAAE,oBAAoB,CAAC,IAAI;QAC/B,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,MAA4C;QACpD,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;KAClC,CAAC;AACJ,CAAC"}
@@ -65,7 +65,7 @@ async function resolveRepoDir(repoDir, ctx) {
65
65
  * Specs
66
66
  * ============================================================ */
67
67
  export const GIT_COMMIT_SPEC = {
68
- name: 'forge.git_commit',
68
+ name: 'forge_git_commit',
69
69
  description: 'Commit staged changes (or all tracked changes with `all`=true) in the given git checkout. Returns the commit hash on success.',
70
70
  input_schema: {
71
71
  type: 'object',
@@ -79,7 +79,7 @@ export const GIT_COMMIT_SPEC = {
79
79
  requires_approval: true,
80
80
  };
81
81
  export const GIT_PUSH_SPEC = {
82
- name: 'forge.git_push',
82
+ name: 'forge_git_push',
83
83
  description: 'Push the current branch to the configured remote. Set `force`=true ONLY for force-push (irreversible -- gated by the V1.10 liveness check).',
84
84
  input_schema: {
85
85
  type: 'object',
@@ -94,7 +94,7 @@ export const GIT_PUSH_SPEC = {
94
94
  requires_approval: true,
95
95
  };
96
96
  export const GIT_PULL_SPEC = {
97
- name: 'forge.git_pull',
97
+ name: 'forge_git_pull',
98
98
  description: 'Pull from the configured remote. Fast-forward only by default.',
99
99
  input_schema: {
100
100
  type: 'object',
@@ -108,7 +108,7 @@ export const GIT_PULL_SPEC = {
108
108
  requires_approval: true,
109
109
  };
110
110
  export const GIT_LOG_SPEC = {
111
- name: 'forge.git_log',
111
+ name: 'forge_git_log',
112
112
  description: 'List the last N commits of the given checkout. Default 10, max 50.',
113
113
  input_schema: {
114
114
  type: 'object',
@@ -32,7 +32,7 @@ const VAULT_SLOT = 'github_token';
32
32
  const GITHUB_API = 'https://api.github.com';
33
33
  /* ------------------ Tool specs ------------------ */
34
34
  export const CREATE_GITHUB_REPO_SPEC = {
35
- name: 'forge.create_github_repo',
35
+ name: 'forge_create_github_repo',
36
36
  description: 'Create a new repository under the authenticated GitHub user. Requires vault slot github_token with repo scope. Returns the new repository metadata including clone_url.',
37
37
  input_schema: {
38
38
  type: 'object',
@@ -46,7 +46,7 @@ export const CREATE_GITHUB_REPO_SPEC = {
46
46
  requires_approval: true,
47
47
  };
48
48
  export const CLONE_REPO_SPEC = {
49
- name: 'forge.clone_repo',
49
+ name: 'forge_clone_repo',
50
50
  description: 'Clone a remote git repository to a local directory. Public repos need no auth. Private repos use the github_token slot when present. Returns the resolved target_dir + the first commit hash.',
51
51
  input_schema: {
52
52
  type: 'object',
@@ -59,7 +59,7 @@ export const CLONE_REPO_SPEC = {
59
59
  requires_approval: true,
60
60
  };
61
61
  export const BRANCH_STATUS_SPEC = {
62
- name: 'forge.branch_status',
62
+ name: 'forge_branch_status',
63
63
  description: 'Read the current git branch + dirty-tree status of a local checkout. Returns branch name, ahead/behind counters vs upstream when present, list of dirty files (max 50).',
64
64
  input_schema: {
65
65
  type: 'object',
@@ -37,7 +37,7 @@ let active = null;
37
37
  * Specs
38
38
  * ============================================================ */
39
39
  export const RUN_APP_SPEC = {
40
- name: 'forge.run_app',
40
+ name: 'forge_run_app',
41
41
  description: 'Launch the project dev server. Auto-detects the package manager (npm / yarn / pnpm) and the script (dev / start / serve). Returns pid + best-effort URL.',
42
42
  input_schema: {
43
43
  type: 'object',
@@ -51,7 +51,7 @@ export const RUN_APP_SPEC = {
51
51
  requires_approval: true,
52
52
  };
53
53
  export const STOP_APP_SPEC = {
54
- name: 'forge.stop_app',
54
+ name: 'forge_stop_app',
55
55
  description: 'Stop the running app spawned by forge.run_app. Returns the final logs tail.',
56
56
  input_schema: {
57
57
  type: 'object',
@@ -63,7 +63,7 @@ export const STOP_APP_SPEC = {
63
63
  requires_approval: true,
64
64
  };
65
65
  export const RESTART_APP_SPEC = {
66
- name: 'forge.restart_app',
66
+ name: 'forge_restart_app',
67
67
  description: 'Stop the running app + relaunch with the same (or new) options.',
68
68
  input_schema: {
69
69
  type: 'object',
@@ -47,7 +47,7 @@ const MANUAL_PATH_CANDIDATES = (lang) => {
47
47
  return manualBaseDirs().map((dir) => path.join(dir, fname));
48
48
  };
49
49
  export const MANUAL_OPEN_SPEC = {
50
- name: 'forge.manual.open',
50
+ name: 'forge_manual_open',
51
51
  description: 'Open the Yujin Forge user manual in the requested language (default: current user language). Resolves to docs/manuals/manual.<lang>.html and opens it through the reader pipeline so the user can navigate by voice. Available languages: es, en, pt, fr, ja, zh, hi, ar, de, it.',
52
52
  input_schema: {
53
53
  type: 'object',
@@ -45,7 +45,7 @@ export function _resetReaderForTests() {
45
45
  * Specs
46
46
  * ============================================================ */
47
47
  export const READER_OPEN_SPEC = {
48
- name: 'forge.reader.open',
48
+ name: 'forge_reader_open',
49
49
  description: 'Open a document for reading. Auto-detects format (txt / md / source / ...). Returns the doc_id + title + section count + first block.',
50
50
  input_schema: {
51
51
  type: 'object',
@@ -57,13 +57,13 @@ export const READER_OPEN_SPEC = {
57
57
  requires_approval: false,
58
58
  };
59
59
  export const READER_LIST_DOCS_SPEC = {
60
- name: 'forge.reader.list_documents',
60
+ name: 'forge_reader_list_documents',
61
61
  description: 'List all documents currently open in this chat session.',
62
62
  input_schema: { type: 'object', properties: {}, required: [] },
63
63
  requires_approval: false,
64
64
  };
65
65
  export const READER_READ_SECTION_SPEC = {
66
- name: 'forge.reader.read_section',
66
+ name: 'forge_reader_read_section',
67
67
  description: 'Return the blocks of a section. With no index, returns the current section under the cursor.',
68
68
  input_schema: {
69
69
  type: 'object',
@@ -76,7 +76,7 @@ export const READER_READ_SECTION_SPEC = {
76
76
  requires_approval: false,
77
77
  };
78
78
  export const READER_NEXT_BLOCK_SPEC = {
79
- name: 'forge.reader.next_block',
79
+ name: 'forge_reader_next_block',
80
80
  description: 'Advance the reader cursor one block forward. Returns the new block contents.',
81
81
  input_schema: {
82
82
  type: 'object',
@@ -88,7 +88,7 @@ export const READER_NEXT_BLOCK_SPEC = {
88
88
  requires_approval: false,
89
89
  };
90
90
  export const READER_SEARCH_SPEC = {
91
- name: 'forge.reader.search',
91
+ name: 'forge_reader_search',
92
92
  description: 'Full-text search across a document. Returns top hits sorted by match count.',
93
93
  input_schema: {
94
94
  type: 'object',
@@ -102,7 +102,7 @@ export const READER_SEARCH_SPEC = {
102
102
  requires_approval: false,
103
103
  };
104
104
  export const READER_BOOKMARK_SET_SPEC = {
105
- name: 'forge.reader.bookmark_set',
105
+ name: 'forge_reader_bookmark_set',
106
106
  description: 'Set a named bookmark at the current cursor position.',
107
107
  input_schema: {
108
108
  type: 'object',
@@ -115,7 +115,7 @@ export const READER_BOOKMARK_SET_SPEC = {
115
115
  requires_approval: false,
116
116
  };
117
117
  export const READER_BOOKMARK_JUMP_SPEC = {
118
- name: 'forge.reader.bookmark_jump',
118
+ name: 'forge_reader_bookmark_jump',
119
119
  description: 'Jump the cursor to a previously-set bookmark.',
120
120
  input_schema: {
121
121
  type: 'object',
@@ -128,7 +128,7 @@ export const READER_BOOKMARK_JUMP_SPEC = {
128
128
  requires_approval: false,
129
129
  };
130
130
  export const READER_RECAP_SPEC = {
131
- name: 'forge.reader.recap',
131
+ name: 'forge_reader_recap',
132
132
  description: 'Return the last N spoken blocks from the reader playback buffer. Default window 10. mode="summary" returns a Claude-generated 1-2 sentence summary instead of literal blocks (charges tokens; gated by env YF_ENABLE_CLAUDE_RECAP=1).',
133
133
  input_schema: {
134
134
  type: 'object',
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Chat tool surface for the PRODUCT_WORKFLOW.md state machine.
3
+ *
4
+ * Three tools that let Forge drive the entire 18-step methodology
5
+ * from inside the chat panel, without the user dropping to the CLI:
6
+ *
7
+ * forge_workflow_state(scope?) read workflow state (full or scoped)
8
+ * forge_workflow_set(group, patch) persist a patch under workflow.<group>
9
+ * forge_workflow_run_step(step) run an autonomous step
10
+ * (legacy_audit, coverage, manual_generate,
11
+ * handoff, metrics) without prompts
12
+ *
13
+ * Design notes:
14
+ * - State write goes through the same module the CLI verbs use
15
+ * (`src/workflow/state.ts`), so a chat session and a CLI session
16
+ * see the same yujin.forge.json.
17
+ * - `forge_workflow_run_step` only handles steps that do NOT
18
+ * require the user to answer questions (legacy_audit reads the
19
+ * project; coverage greps tests; manual_generate emits markdown
20
+ * from existing state). Interactive steps (triage, discover,
21
+ * clarify, approve) stay CLI-driven OR are driven by Forge
22
+ * asking the user in chat + calling forge_workflow_set with the
23
+ * collected answers.
24
+ * - Per SQ Sec 14, Forge calls forge_audit_consumers before any
25
+ * structural commit; this surface is read-mostly + persistence-
26
+ * safe so it does not trip that rule.
27
+ *
28
+ * ASCII-only.
29
+ */
30
+ import type { ToolContext, ToolResult, ToolSpec } from '../tools.js';
31
+ export declare const WORKFLOW_STATE_SPEC: ToolSpec;
32
+ export declare function runWorkflowState(args: {
33
+ scope?: string;
34
+ }, ctx: ToolContext): Promise<ToolResult>;
35
+ export declare const WORKFLOW_SET_SPEC: ToolSpec;
36
+ export declare function runWorkflowSet(args: {
37
+ group?: string;
38
+ patch?: Record<string, unknown>;
39
+ top_level?: boolean;
40
+ }, ctx: ToolContext): Promise<ToolResult>;
41
+ export declare const WORKFLOW_RUN_STEP_SPEC: ToolSpec;
42
+ export declare function runWorkflowRunStep(args: {
43
+ step?: string;
44
+ }, ctx: ToolContext): Promise<ToolResult>;
45
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/chat/tools/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAYrE,eAAO,MAAM,mBAAmB,EAAE,QAqBjC,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACxB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,UAAU,CAAC,CA+BrB;AAMD,eAAO,MAAM,iBAAiB,EAAE,QAkC/B,CAAC;AAWF,wBAAsB,cAAc,CAClC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EAC9E,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,UAAU,CAAC,CA4DrB;AAMD,eAAO,MAAM,sBAAsB,EAAE,QAwBpC,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACvB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,UAAU,CAAC,CA0ErB"}