project-tiny-context-harness 0.2.60 → 0.2.62

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.
@@ -21,33 +21,38 @@ The output answers:
21
21
  For this exact plan, what must be true before a future executor can honestly say the task is complete?
22
22
  ```
23
23
 
24
- This Skill is generic. Do not embed business-specific rules, provider-specific rules, product-domain assumptions, artifact schemas, API names, UI names, status names, or one-off project logic in this Skill. If the user's plan contains a specific domain, derive acceptance items from that plan and the project Context during the current invocation only.
24
+ This Skill is generic. Do not embed business-specific rules, vendor-specific rules, product-domain assumptions, artifact schemas, concrete interface names, UI names, state names, or one-off project logic in this Skill. If the user's plan contains a specific domain, derive acceptance items from that plan and the project Context during the current invocation only.
25
25
 
26
26
  ## Required Outputs
27
27
 
28
- Every completed invocation must produce:
29
-
30
- 1. A preserved copy of the plan under `tmp/ty-context/plan-acceptance/`.
31
- 2. A rigorous acceptance checklist derived from the plan and relevant project Context.
32
- 3. A goal/target-mode prompt the user can paste directly into Codex.
28
+ Every completed invocation must produce:
29
+
30
+ 1. A preserved copy of the plan under `tmp/ty-context/plan-acceptance/`. The copied plan is the implementation/source plan, not acceptance proof.
31
+ 2. A rigorous full acceptance checklist under a separate `tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md` path. If the plan contains an explicit concrete acceptance checklist, reuse that plan-provided checklist verbatim; otherwise derive the checklist from the plan and relevant project Context. The full checklist is the complete acceptance standard.
32
+ 3. A goal/target-mode prompt the user can paste directly into Codex. The prompt may include a compact checklist summary for direction, priority and recovery navigation, but the full checklist owns the acceptance details.
33
+ 4. When a local audit path is referenced, it is temporary execution/progress state only, not Context and not proof by itself.
33
34
 
34
35
  Exception: if the Context confirmation gate below triggers, stop after materializing the plan and reading enough Context to explain the uncertainty. Ask the user for confirmation before producing the checklist or goal/target-mode prompt.
35
36
 
36
- The goal/target-mode prompt must be no longer than 3980 characters, including line breaks. This conservative budget keeps the prompt below Codex's 4000-character practical paste boundary even when character counting differs slightly. Keep the prompt information-dense: preserve required paths, core acceptance criteria, evidence rules, blockers and false-completion traps while using compact wording. Use the user's language when practical. For Chinese requests, use this shape:
37
-
38
- ```text
39
- 实施计划: tmp/ty-context/plan-acceptance/<plan>.md
40
- 可多开agent,agent名额不够了就关掉不用的。
41
- <验收清单>
42
- ```
43
-
44
- For English requests, use this shape:
45
-
46
- ```text
47
- Plan: tmp/ty-context/plan-acceptance/<plan>.md
48
- You may use multiple agents; if agent slots run low, close idle or unnecessary agents.
49
- <acceptance checklist>
50
- ```
37
+ The goal/target-mode prompt must be no longer than 3850 characters, including line breaks. This conservative budget keeps the prompt below Codex's 4000-character practical paste boundary even when character counting differs slightly. Keep the prompt information-dense: preserve required paths, core acceptance criteria, evidence rules, blockers and false-completion traps while using compact wording. Use the user's language when practical. For Chinese requests, use this shape:
38
+
39
+ ```text
40
+ 实施计划: tmp/ty-context/plan-acceptance/<plan>.md(source/implementation plan,非验收证明)
41
+ 可多开agent,agent名额不够了就关掉不用的。
42
+ 完整验收清单: tmp/ty-context/plan-acceptance/<plan>-acceptance-checklist.md(该文件是完整验收标准,验收以这个为准。完成前必须逐项检查,不满足则继续实现。)
43
+ 执行审计: tmp/ty-context/plan-acceptance/<plan>-local-audit.md(临时 progress state,非 Context/proof)
44
+ <验收清单>
45
+ ```
46
+
47
+ For English requests, use this shape:
48
+
49
+ ```text
50
+ Plan: tmp/ty-context/plan-acceptance/<plan>.md (implementation/source plan, not acceptance proof)
51
+ You may use multiple agents; if agent slots run low, close idle or unnecessary agents.
52
+ Full checklist: tmp/ty-context/plan-acceptance/<plan>-acceptance-checklist.md (complete acceptance standard; acceptance is judged against it; every item must be checked before completion)
53
+ Local audit: tmp/ty-context/plan-acceptance/<plan>-local-audit.md (temporary execution/progress state, not Context or proof)
54
+ <acceptance checklist>
55
+ ```
51
56
 
52
57
  This resource lifecycle line is part of the generated execution prompt. It authorizes parallel decomposition for the future executor while requiring unused agents to be closed when slots run low.
53
58
 
@@ -121,8 +126,8 @@ Rules:
121
126
  - If the user pasted the plan text, write the pasted plan exactly into `tmp/ty-context/plan-acceptance/<safe-plan-name>.md`.
122
127
  - Preserve the plan content. Do not summarize, normalize, reorder, translate, or edit it while materializing it.
123
128
  - Use a stable readable filename derived from the plan title, source filename, or user topic. Use lowercase letters, digits, hyphens, and `.md`.
124
- - If the source plan cannot be found or read, stop and report the missing source. Do not invent a plan.
125
- - The materialized plan is temporary execution input. It is not durable Context and not proof that any acceptance item passed.
129
+ - If the source plan cannot be found or read, stop and report the missing source. Do not invent a plan.
130
+ - The materialized plan is temporary implementation/source input. It is not durable Context, not acceptance proof and not proof that any acceptance item passed.
126
131
 
127
132
  Recommended paths:
128
133
 
@@ -133,8 +138,28 @@ tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md
133
138
  ```
134
139
 
135
140
  The local audit path is for the future goal/target-mode executor. This compiler may require the prompt to maintain it, but the file is a temporary recovery cache and not proof that any acceptance item passed.
136
-
137
- ## Step 2: Read Relevant Project Context
141
+
142
+ ## Step 2: Reuse Any Explicit Plan-Provided Checklist
143
+
144
+ After materializing the plan, inspect it for an explicit concrete acceptance checklist before generating a new checklist.
145
+
146
+ Plan-provided checklist reuse applies only when the plan contains a clearly labeled checklist or checklist table section, such as `Acceptance Checklist`, `Acceptance Criteria`, `验收清单`, `验收标准`, or equivalent heading, and that section contains concrete acceptance items rather than only saying that acceptance is needed.
147
+
148
+ When a plan-provided checklist is found:
149
+
150
+ - Copy the plan-provided acceptance checklist section into `tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md` as the full checklist.
151
+ - Preserve the extracted checklist verbatim, including the original language, item wording, order, IDs, Markdown tables, checkboxes, evidence notes, and blocker notes.
152
+ - Do not derive, strengthen, reorder, translate, normalize, merge, split, or add acceptance items.
153
+ - Do not prepend the generated `Acceptance Contract`, checklist table, self-test, or false-completion traps to the full checklist file when reusing a plan-provided checklist.
154
+ - If multiple explicit checklist sections exist, copy all of them into the full checklist file in source order.
155
+ - Keep the copied plan file and full checklist file separate, even if the checklist already appears inside the plan.
156
+ - Continue to read relevant Context only as needed to explain ambiguities, conflicts, the goal/target-mode prompt, and any required local-audit or false-completion guidance. Do not use Context to expand the reused checklist unless the user separately asks for an audit or rewrite.
157
+ - If the plan-provided checklist is too large for the 3850-character prompt budget, keep it intact in the full checklist file and make the prompt reference that file as the acceptance authority; do not invent a compact replacement checklist with new criteria.
158
+ - Skip Steps 5 and 6 for the full checklist file unless the user separately asks for a checklist audit or rewrite.
159
+
160
+ When no explicit concrete plan-provided checklist exists, continue with the generated-checklist flow below.
161
+
162
+ ## Step 3: Read Relevant Project Context
138
163
 
139
164
  Read only the Context needed for the plan's impacted surfaces. Use Context to identify what the project says the system should mean.
140
165
 
@@ -150,7 +175,7 @@ Extract:
150
175
  - Known non-goals and forbidden dependencies.
151
176
  - Existing implementation entry points.
152
177
 
153
- ## Step 3: Run The Context Confirmation Gate
178
+ ## Step 4: Run The Context Confirmation Gate
154
179
 
155
180
  After reading the plan and relevant Context, decide whether generating an acceptance checklist would require guessing or silently accepting many durable fact changes. If yes, stop and ask the user to confirm details before continuing.
156
181
 
@@ -171,11 +196,11 @@ When the gate triggers:
171
196
  - Include the materialized plan path if already written.
172
197
  - State the specific Context files or Context roles that made confirmation necessary.
173
198
  - Offer a concrete default only when it is safe and reversible; otherwise ask for an explicit decision.
174
- - Resume from Step 2 after the user answers.
199
+ - Resume from Step 3 after the user answers.
175
200
 
176
201
  Do not trigger this gate merely because the plan is large. If the Context impact is clear, bounded, and the checklist can represent the durable Context updates as acceptance items without guessing, continue.
177
202
 
178
- ## Step 4: Compile The Acceptance Contract
203
+ ## Step 5: Compile The Acceptance Contract
179
204
 
180
205
  Before the detailed checklist, write a compact contract:
181
206
 
@@ -187,17 +212,22 @@ Before the detailed checklist, write a compact contract:
187
212
  - Completion definition: <what must be true>
188
213
  - Core surfaces: <code/API/UI/data/runtime/artifact/test/context/etc.>
189
214
  - Explicit non-goals: <items>
190
- - External blockers: <accounts/session/credentials/network/cloud/manual approval/etc.>
191
- - Evidence standard: <accepted proof types>
192
- ```
215
+ - External blockers: <accounts/session/credentials/network/cloud/manual approval/etc.>
216
+ - Evidence standard: <accepted proof types>
217
+ - Current-state claims: <which "current", "generated", "synced", "tested", "accepted" or runtime claims require current evidence>
218
+ - Evidence ledger required: <whether the checklist or future executor must maintain current evidence by item>
219
+ - Invalid completion evidence: <stale artifacts, code-only edits, partial tests, unexercised runtime, mismatched read paths or other evidence that cannot prove completion>
220
+ ```
193
221
 
194
222
  If the plan uses broad words such as `all`, `complete`, `maximum`, `maximized`, `accepted`, `formal`, `production`, `real`, `current`, or `verified`, convert them into explicit inventory and evidence requirements.
195
223
 
196
- ## Step 5: Build The Full Acceptance Checklist
197
-
198
- Treat the checklist as the set of falsifiable acceptance items a future executor must satisfy. It is not a progress log.
199
-
200
- Create a checklist table with these columns:
224
+ ## Step 6: Build The Full Acceptance Checklist
225
+
226
+ Treat the checklist as the set of falsifiable acceptance items a future executor must satisfy. It is not a progress log.
227
+
228
+ Use this generated-checklist step only when Step 2 did not find an explicit concrete plan-provided checklist. If Step 2 found one, the full checklist file is the verbatim extracted checklist and this step is skipped.
229
+
230
+ Create a checklist table with these columns:
201
231
 
202
232
  ```markdown
203
233
  | ID | Acceptance item | Source | Scope | Required evidence | Verification method | Fail / not accepted if |
@@ -214,9 +244,28 @@ Column rules:
214
244
  - `Verification method`: concrete command, check, inspection path, API call, UI check, artifact validation, or manual proof.
215
245
  - `Fail / not accepted if`: concrete invalidation case.
216
246
 
217
- Each item must be evidence-bound and falsifiable. Split combined requirements into separate rows.
218
-
219
- ## Hard Blocker Handling
247
+ Each item must be evidence-bound and falsifiable. Split combined requirements into separate rows.
248
+
249
+ For current-state or evidence-heavy plans, also require the future executor to maintain an Evidence Ledger table:
250
+
251
+ ```markdown
252
+ | AC | Expected state | Current observed state | Current evidence | Evidence location / API / UI / command | Conclusion | Gap / blocker |
253
+ |---|---|---|---|---|---|---|
254
+ ```
255
+
256
+ Allowed `Conclusion` values:
257
+
258
+ - `proven`
259
+ - `unproven`
260
+ - `stale-evidence`
261
+ - `runtime-disconnected`
262
+ - `implementation-drift`
263
+ - `blocked`
264
+ - `deferred-by-explicit-scope`
265
+
266
+ Missing ledger evidence means incomplete, not complete. Do not let missing evidence, old evidence, partial evidence or evidence from a different read path satisfy a current-state claim.
267
+
268
+ ## Hard Blocker Handling
220
269
 
221
270
  Treat any unresolved required blocker as non-completion. A checklist may describe blocked acceptance work, but blocked work is still not accepted until the required evidence exists.
222
271
 
@@ -258,7 +307,7 @@ When user input is still required, the blocker request must be the smallest conc
258
307
  - Acceptance impact if the blocker remains unresolved.
259
308
  - Allowed fallback, deferred or narrowed-scope option, if the plan or Context permits one.
260
309
 
261
- Do not replace this with broad requests such as "provide the token", "send the AppSecret" or "give me the configuration credentials" when a narrower page, field, runtime setup step or delegated user action would satisfy the blocker.
310
+ Do not replace this with broad requests such as "provide the token", "send the secret value" or "give me the configuration credentials" when a narrower page, field, runtime setup step or delegated user action would satisfy the blocker.
262
311
 
263
312
  ## Generic Acceptance Dimensions
264
313
 
@@ -342,18 +391,28 @@ After the checklist, include traps that a future executor must not mistake for c
342
391
 
343
392
  Use generic wording. Do not add business-specific traps to the Skill itself.
344
393
 
345
- Template:
346
-
347
- ```markdown
348
- ## False-Completion Traps
349
-
350
- - <activity> is not enough unless <acceptance proof> also exists.
351
- - <partial proof> cannot prove <full acceptance item>.
352
- - <old/stale/mismatched evidence> cannot prove current completion.
353
- - <surface A> passing does not prove <surface B> unless the checklist links them.
354
- ```
355
-
356
- ## Suggested Execution Order
394
+ Template:
395
+
396
+ ```markdown
397
+ ## False-Completion Traps
398
+
399
+ - <activity> is not enough unless <acceptance proof> also exists.
400
+ - <partial proof> cannot prove <full acceptance item>.
401
+ - <old/stale/mismatched evidence> cannot prove current completion.
402
+ - <surface A> passing does not prove <surface B> unless the checklist links them.
403
+ ```
404
+
405
+ For evidence-ledger plans, keep the traps generic and cover these cases when relevant:
406
+
407
+ - Code-only changes without current execution or acceptance evidence.
408
+ - UI/API shell behavior without the backing data, runtime or artifact evidence required by the checklist.
409
+ - Stale artifacts or stale runtime evidence.
410
+ - Evidence from a mismatched read path, service path, artifact path or runtime instance.
411
+ - Unexercised runtime or unexercised fallback behavior.
412
+ - Partial tests, smoke-only checks or dry runs when the plan requires broader current proof.
413
+ - API/UI/data/test contradictions that remain unresolved.
414
+
415
+ ## Suggested Execution Order
357
416
 
358
417
  Suggest an execution order that prioritizes the highest-risk proof first:
359
418
 
@@ -387,16 +446,18 @@ Every generated checklist must pass this self-test:
387
446
 
388
447
  ## Goal/Target-Mode Prompt Generation
389
448
 
390
- After compiling the checklist, produce a paste-ready goal/target-mode prompt.
449
+ After reusing a plan-provided checklist or compiling a generated checklist, produce a paste-ready goal/target-mode prompt.
391
450
 
392
- Hard requirements:
393
-
394
- - The prompt must be no longer than 3980 characters including line breaks. Treat 3980 as the effective hard budget and preserve information density; do not drop required paths, core acceptance categories, blocker rules, evidence rules or false-completion traps merely to be short.
395
- - The first line must identify the plan path.
396
- - Use `实施计划: <path>` for Chinese prompts and `Plan: <path>` for English prompts.
397
- - The second line must be a resource lifecycle instruction: `可多开agent,agent名额不够了就关掉不用的。` for Chinese prompts or `You may use multiple agents; if agent slots run low, close idle or unnecessary agents.` for English prompts.
398
- - The remaining content must be the acceptance checklist or a compact version of it.
451
+ Hard requirements:
452
+
453
+ - The prompt must be no longer than 3850 characters including line breaks. Treat 3850 as the effective hard budget and preserve information density; do not drop required paths, core acceptance categories, blocker rules, evidence rules or false-completion traps merely to be short.
454
+ - The first line must identify the plan path.
455
+ - Use `实施计划: <path>` for Chinese prompts and `Plan: <path>` for English prompts. The line must say the plan is the implementation/source plan and not acceptance proof.
456
+ - The second line must be a resource lifecycle instruction: `可多开agent,agent名额不够了就关掉不用的。` for Chinese prompts or `You may use multiple agents; if agent slots run low, close idle or unnecessary agents.` for English prompts.
457
+ - The remaining content must be the acceptance checklist or a compact version of it.
399
458
  - The prompt must be self-contained enough for goal/target-mode execution.
459
+ - The prompt must identify the full checklist path and say it is the complete acceptance standard. Chinese prompts must include this exact sentence: `该文件是完整验收标准,验收以这个为准。完成前必须逐项检查,不满足则继续实现。` English prompts must say the full checklist is the complete acceptance standard, acceptance is judged against it, and every item must be checked before completion.
460
+ - If the prompt uses a compact checklist summary, say the full checklist owns details and acceptance authority; the compact summary owns direction, priority and recovery navigation; overlap is allowed; conflicts are resolved in favor of the full checklist.
400
461
  - The prompt must identify a local audit path, normally `tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md`, and require the future executor to read it before resuming, keep it current during execution, and use it only as target-mode acceptance progress state.
401
462
  - The prompt must require the local audit to record overall status (`complete`, `incomplete`, `blocked` or `narrowed-scope-complete`), each core AC status and current evidence, commands with result/time/failure reason, artifact or evidence paths, blockers and missing evidence, acceptance impact, explicit deferred or narrowed scope, and stale/partial/smoke/dry-run/research evidence that cannot prove full completion.
402
463
  - The prompt must say that local audit is not Context, not product-quality proof, not a global task manager, and not a replacement for project tests, CI, review, human acceptance, Task Contract or workflow-contract `plan.md`.
@@ -405,15 +466,17 @@ Hard requirements:
405
466
  - Do not include Markdown tables inside the prompt if they make it too long.
406
467
  - Prefer short numbered items over verbose prose.
407
468
  - If the full checklist is too large, write the full checklist to `tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md`, then compress the goal/target-mode prompt by increasing information density while preserving all core acceptance categories.
408
- - The compact prompt may reference the full checklist path, but it must still include the core completion criteria directly.
469
+ - If the full checklist came from a plan-provided checklist and is too large, keep the extracted checklist unchanged in the full checklist file and compress the prompt by referencing the full checklist path, not by rewriting or adding criteria.
470
+ - The compact prompt may reference the full checklist path, but it must still include the core completion criteria directly and state that the summary is direction/priority/recovery navigation, not the acceptance authority.
409
471
 
410
472
  Recommended compact Chinese prompt shape:
411
473
 
412
474
  ```text
413
- 实施计划: tmp/ty-context/plan-acceptance/<plan-slug>.md
475
+ 实施计划: tmp/ty-context/plan-acceptance/<plan-slug>.md(source/implementation plan,非验收证明)
414
476
  可多开agent,agent名额不够了就关掉不用的。
415
- 完整验收清单: tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md
416
- 执行审计: tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md
477
+ 完整验收清单: tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md(该文件是完整验收标准,验收以这个为准。完成前必须逐项检查,不满足则继续实现。)
478
+ 执行审计: tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md(临时 progress state,非 Context/proof)
479
+ 本摘要只负责 direction/priority/recovery navigation;允许与完整 checklist 重叠,冲突时以完整 checklist 为准。
417
480
 
418
481
  验收清单:
419
482
  AC1 <核心完成定义,包含验收证据>
@@ -437,10 +500,11 @@ AC14 完成前审计:逐条对照实施计划和完整 checklist;每个 core
437
500
  Recommended compact English prompt shape:
438
501
 
439
502
  ```text
440
- Plan: tmp/ty-context/plan-acceptance/<plan-slug>.md
503
+ Plan: tmp/ty-context/plan-acceptance/<plan-slug>.md (implementation/source plan, not acceptance proof)
441
504
  You may use multiple agents; if agent slots run low, close idle or unnecessary agents.
442
- Full checklist: tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md
443
- Local audit: tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md
505
+ Full checklist: tmp/ty-context/plan-acceptance/<plan-slug>-acceptance-checklist.md (complete acceptance standard; acceptance is judged against it; every item must be checked before completion)
506
+ Local audit: tmp/ty-context/plan-acceptance/<plan-slug>-local-audit.md (temporary progress state, not Context or proof)
507
+ This summary is only direction, priority and recovery navigation; overlap with the full checklist is allowed, and the full checklist wins conflicts.
444
508
 
445
509
  Acceptance checklist:
446
510
  AC1 <core completion definition with required evidence>
@@ -460,17 +524,18 @@ AC14 Final audit: compare every item against the plan and full checklist; every
460
524
 
461
525
  Do not count these as completion: code-only changes, plan-only updates, partial tests, stale or partial evidence, infrastructure without acceptance proof, runtime not configured/exercised, artifact not accepted by validator, API/UI not reflecting accepted evidence, unexercised fallback, unresolved hard blockers, or contradictions between API/UI/data/tests.
462
526
  ```
463
-
464
- Before final response, check the prompt length. If it exceeds 3980 characters, compress by tightening wording and referring to the full checklist path while preserving required paths, core AC categories, blocker/evidence rules and false-completion traps; then check again.
527
+
528
+ Before final response, check the prompt length. If it exceeds 3850 characters, compress by tightening wording and referring to the full checklist path while preserving required paths, core AC categories, blocker/evidence rules and false-completion traps; then check again.
465
529
 
466
530
  ## Final Response Requirements
467
531
 
468
- For completed checklist runs, the final response must include:
469
-
470
- - `tmp/ty-context/plan-acceptance/` plan path.
471
- - Full checklist path if a full checklist file was written.
472
- - The paste-ready goal/target-mode prompt in a code block.
473
- - Any unresolved ambiguity that affects checklist accuracy.
532
+ For completed checklist runs, the final response must include:
533
+
534
+ - `tmp/ty-context/plan-acceptance/` plan path.
535
+ - Full checklist path if a full checklist file was written.
536
+ - Whether the full checklist was reused from a plan-provided checklist or generated by this Skill.
537
+ - The paste-ready goal/target-mode prompt in a code block.
538
+ - Any unresolved ambiguity that affects checklist accuracy.
474
539
 
475
540
  If the Context confirmation gate triggers, the response must ask for the needed confirmation instead of including the checklist or goal/target-mode prompt.
476
541
 
@@ -488,6 +553,8 @@ Do not use the checklist to mark the task complete.
488
553
 
489
554
  Do not hide missing source files, ambiguous plan scope, or external blockers.
490
555
 
491
- Do not rewrite the user's plan while copying it into `tmp/ty-context/plan-acceptance/`.
492
-
493
- Do not use a short sample, stale artifact, old result, or current implementation convenience to reduce a plan that asked for full completion.
556
+ Do not rewrite the user's plan while copying it into `tmp/ty-context/plan-acceptance/`.
557
+
558
+ Do not rewrite, strengthen, reorder, translate, normalize, or add items to a plan-provided checklist when the plan already includes an explicit concrete checklist.
559
+
560
+ Do not use a short sample, stale artifact, old result, or current implementation convenience to reduce a plan that asked for full completion.
@@ -0,0 +1,21 @@
1
+ import type { SourcePackMode } from "../lib/source-pack-types.js";
2
+ export interface ExportContextArgs {
3
+ full: boolean;
4
+ code: boolean;
5
+ all: boolean;
6
+ sourceMode?: SourcePackMode;
7
+ taskName?: string;
8
+ check: boolean;
9
+ output?: string;
10
+ profile?: string;
11
+ includeContext: string[];
12
+ includeCode: string[];
13
+ bundleStrategy?: "auto" | "area" | "topdir" | "config";
14
+ maxPackFiles?: number;
15
+ maxBundleCharacters?: number;
16
+ redactionStrict: boolean;
17
+ prune?: number;
18
+ help: boolean;
19
+ }
20
+ export declare function parseArgs(args: string[]): ExportContextArgs;
21
+ export declare function helpText(): string;
@@ -0,0 +1,149 @@
1
+ export function parseArgs(args) {
2
+ const parsed = {
3
+ full: false,
4
+ code: false,
5
+ all: false,
6
+ check: false,
7
+ includeContext: [],
8
+ includeCode: [],
9
+ redactionStrict: false,
10
+ help: false
11
+ };
12
+ for (let index = 0; index < args.length; index += 1) {
13
+ const arg = args[index];
14
+ if (arg === "--full")
15
+ parsed.full = true;
16
+ else if (arg === "--code")
17
+ parsed.code = true;
18
+ else if (arg === "--all")
19
+ parsed.all = true;
20
+ else if (arg === "--code-index")
21
+ parsed.sourceMode = "code-index";
22
+ else if (arg === "--source-pack")
23
+ parsed.sourceMode = "source-pack";
24
+ else if (arg === "--code-bundles")
25
+ parsed.sourceMode = "code-bundles";
26
+ else if (arg === "--check")
27
+ parsed.check = true;
28
+ else if (arg === "--help" || arg === "-h")
29
+ parsed.help = true;
30
+ else if (arg === "--redaction-strict")
31
+ parsed.redactionStrict = true;
32
+ else if (arg === "--task-context")
33
+ index = readValue(args, index, "export-context --task-context requires a name", (value) => {
34
+ parsed.sourceMode = "task-context";
35
+ parsed.taskName = value;
36
+ });
37
+ else if (arg.startsWith("--task-context=")) {
38
+ parsed.sourceMode = "task-context";
39
+ parsed.taskName = inlineValue(arg, "--task-context", "export-context --task-context requires a name");
40
+ }
41
+ else if (arg === "--output")
42
+ index = readValue(args, index, "export-context --output requires a path", (value) => (parsed.output = value));
43
+ else if (arg.startsWith("--output="))
44
+ parsed.output = inlineValue(arg, "--output", "export-context --output requires a path");
45
+ else if (arg === "--profile")
46
+ index = readValue(args, index, "export-context --profile requires an id", (value) => (parsed.profile = value));
47
+ else if (arg.startsWith("--profile="))
48
+ parsed.profile = inlineValue(arg, "--profile", "export-context --profile requires an id");
49
+ else if (arg === "--include-context")
50
+ index = readValue(args, index, "export-context --include-context requires a repo-relative path or glob", (value) => parsed.includeContext.push(value));
51
+ else if (arg.startsWith("--include-context="))
52
+ parsed.includeContext.push(inlineValue(arg, "--include-context", "export-context --include-context requires a repo-relative path or glob"));
53
+ else if (arg === "--include-code")
54
+ index = readValue(args, index, "export-context --include-code requires a repo-relative path or glob", (value) => parsed.includeCode.push(value));
55
+ else if (arg.startsWith("--include-code="))
56
+ parsed.includeCode.push(inlineValue(arg, "--include-code", "export-context --include-code requires a repo-relative path or glob"));
57
+ else if (arg === "--bundle-strategy")
58
+ index = readValue(args, index, "export-context --bundle-strategy requires auto, area, topdir or config", (value) => (parsed.bundleStrategy = parseBundleStrategy(value)));
59
+ else if (arg.startsWith("--bundle-strategy="))
60
+ parsed.bundleStrategy = parseBundleStrategy(inlineValue(arg, "--bundle-strategy", "export-context --bundle-strategy requires auto, area, topdir or config"));
61
+ else if (arg === "--max-pack-files")
62
+ index = readValue(args, index, "export-context --max-pack-files requires a positive integer", (value) => (parsed.maxPackFiles = parseInteger(value, "--max-pack-files", false)));
63
+ else if (arg.startsWith("--max-pack-files="))
64
+ parsed.maxPackFiles = parseInteger(inlineValue(arg, "--max-pack-files", "export-context --max-pack-files requires a positive integer"), "--max-pack-files", false);
65
+ else if (arg === "--max-bundle-characters")
66
+ index = readValue(args, index, "export-context --max-bundle-characters requires a positive integer", (value) => (parsed.maxBundleCharacters = parseInteger(value, "--max-bundle-characters", false)));
67
+ else if (arg.startsWith("--max-bundle-characters="))
68
+ parsed.maxBundleCharacters = parseInteger(inlineValue(arg, "--max-bundle-characters", "export-context --max-bundle-characters requires a positive integer"), "--max-bundle-characters", false);
69
+ else if (arg === "--prune")
70
+ index = readValue(args, index, "export-context --prune requires a non-negative integer", (value) => (parsed.prune = parseInteger(value, "--prune", true)));
71
+ else if (arg.startsWith("--prune="))
72
+ parsed.prune = parseInteger(inlineValue(arg, "--prune", "export-context --prune requires a non-negative integer"), "--prune", true);
73
+ else
74
+ throw new Error(`unknown export-context argument: ${arg}`);
75
+ }
76
+ validateParsedArgs(parsed);
77
+ return parsed;
78
+ }
79
+ export function helpText() {
80
+ return `ty-context export-context:
81
+ export-context --full [--output tmp/ty-context/context-exports/<name>.md] [--check]
82
+ export-context --code [--output tmp/ty-context/context-exports/<name>.md] [--check]
83
+ export-context --all [--check]
84
+ export-context --code-index [--profile <id>] [--include-code <path-or-glob>] [--check]
85
+ export-context --source-pack [--profile <id>] [--bundle-strategy auto|area|topdir|config] [--max-pack-files 5] [--max-bundle-characters <n>] [--redaction-strict] [--prune <count>] [--check]
86
+ export-context --code-bundles [--profile <id>] [--include-code <path-or-glob>] [--max-pack-files 5] [--check]
87
+ export-context --task-context <name> [--profile <id>] [--include-context <path-or-glob>] [--include-code <path-or-glob>] [--max-pack-files 5] [--redaction-strict] [--check]
88
+
89
+ Creates temporary Markdown artifacts for copying or external-tool ingestion.
90
+ --full exports the project Context summary as a full-project-context artifact.
91
+ --code exports one current implementation snapshot as a code-level-implementation artifact.
92
+ --all exports both default artifacts in one command.
93
+ Source Pack modes write timestamped directories plus latest/ under tmp/ty-context/context-exports/**.
94
+ --source-pack and --task-context are bounded to at most 5 files; --max-pack-files cannot exceed 5.
95
+ Profiles are export selectors read from <harnessRoot>/config.yaml; verification entries are listed, not executed.
96
+ Secret redaction is always enabled; --redaction-strict fails if redaction was required.
97
+ The artifact must stay under tmp/ty-context/context-exports/** and must not be referenced from project_context/context.toml.`;
98
+ }
99
+ function validateParsedArgs(parsed) {
100
+ const modeCount = Number(parsed.full) + Number(parsed.code) + Number(parsed.all) + Number(parsed.sourceMode !== undefined);
101
+ if (modeCount > 1) {
102
+ throw new Error("export-context accepts exactly one mode: --full, --code, --all, --code-index, --source-pack, --code-bundles or --task-context");
103
+ }
104
+ if (parsed.all && parsed.output) {
105
+ throw new Error("export-context --all writes two default artifacts; --output is only supported with --full or --code");
106
+ }
107
+ if (parsed.sourceMode && parsed.output) {
108
+ throw new Error("export-context --output is only supported with legacy --full or --code single-artifact modes");
109
+ }
110
+ if (!parsed.sourceMode && hasSourcePackOnlyOptions(parsed)) {
111
+ throw new Error("profile/include/bundle/max/prune/redaction-strict options are only supported with Source Pack modes");
112
+ }
113
+ }
114
+ function readValue(args, index, message, apply) {
115
+ const value = args[index + 1];
116
+ if (!value || value.startsWith("--")) {
117
+ throw new Error(message);
118
+ }
119
+ apply(value);
120
+ return index + 1;
121
+ }
122
+ function inlineValue(arg, flag, message) {
123
+ const value = arg.slice(`${flag}=`.length).trim();
124
+ if (!value)
125
+ throw new Error(message);
126
+ return value;
127
+ }
128
+ function parseBundleStrategy(value) {
129
+ if (value === "auto" || value === "area" || value === "topdir" || value === "config")
130
+ return value;
131
+ throw new Error("export-context --bundle-strategy must be one of auto, area, topdir or config");
132
+ }
133
+ function parseInteger(value, flag, allowZero) {
134
+ const parsed = Number.parseInt(value, 10);
135
+ if (!Number.isInteger(parsed) || String(parsed) !== value.trim() || parsed < 0 || (!allowZero && parsed === 0)) {
136
+ throw new Error(`export-context ${flag} requires ${allowZero ? "a non-negative" : "a positive"} integer`);
137
+ }
138
+ return parsed;
139
+ }
140
+ function hasSourcePackOnlyOptions(parsed) {
141
+ return Boolean(parsed.profile ||
142
+ parsed.includeContext.length > 0 ||
143
+ parsed.includeCode.length > 0 ||
144
+ parsed.bundleStrategy ||
145
+ parsed.maxPackFiles ||
146
+ parsed.maxBundleCharacters ||
147
+ parsed.redactionStrict ||
148
+ parsed.prune !== undefined);
149
+ }