@orbit-build/cli 0.4.4 → 0.4.5
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.
- package/commands/math-draft.md +11 -0
- package/dist/index.js +103 -10
- package/package.json +4 -2
- package/skills/math-model-draft/SKILL.md +216 -0
- package/skills/math-model-draft/agents/openai.yaml +6 -0
- package/skills/math-model-draft/assets/project-template/code/always/__init__.py +1 -0
- package/skills/math-model-draft/assets/project-template/code/always/config.py +17 -0
- package/skills/math-model-draft/assets/project-template/code/always/data.py +23 -0
- package/skills/math-model-draft/assets/project-template/code/always/plotting.py +24 -0
- package/skills/math-model-draft/assets/project-template/code/always/validation.py +20 -0
- package/skills/math-model-draft/assets/project-template/code/finalize.py +55 -0
- package/skills/math-model-draft/assets/project-template/code/requirements.txt +11 -0
- package/skills/math-model-draft/assets/project-template/paper/AI/345/267/245/345/205/267/344/275/277/347/224/250/350/257/246/346/203/205.tex +34 -0
- package/skills/math-model-draft/assets/project-template/paper/ai-use-log.md +7 -0
- package/skills/math-model-draft/assets/project-template/paper/contest-profile.json +25 -0
- package/skills/math-model-draft/assets/project-template/paper/main.tex +53 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/abstract.tex +6 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/ai-disclosure.tex +3 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/appendix.tex +9 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/assumptions.tex +5 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/data.tex +19 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/evaluation.tex +9 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/problem-analysis.tex +3 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/problem-restatement.tex +3 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/references.tex +6 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/source-code.tex +1 -0
- package/skills/math-model-draft/assets/project-template/paper/sections/support-files.tex +3 -0
- package/skills/math-model-draft/references/code-and-output-style.md +91 -0
- package/skills/math-model-draft/references/cumcm-compliance.md +56 -0
- package/skills/math-model-draft/references/latex-figures-tables.md +60 -0
- package/skills/math-model-draft/references/modeling-quality.md +91 -0
- package/skills/math-model-draft/references/paper-architecture.md +125 -0
- package/skills/math-model-draft/references/paper-revision.md +76 -0
- package/skills/math-model-draft/references/project-architecture.md +65 -0
- package/skills/math-model-draft/scripts/audit_paper.py +185 -0
- package/skills/math-model-draft/scripts/bootstrap_project.py +275 -0
- package/skills/math-model-draft/scripts/build_paper.py +226 -0
- package/skills/math-model-draft/scripts/capture_environment.py +46 -0
- package/skills/math-model-draft/scripts/clean_project.py +46 -0
- package/skills/math-model-draft/scripts/finalize_project.py +49 -0
- package/skills/math-model-draft/scripts/inspect_inputs.py +193 -0
- package/skills/math-model-draft/scripts/package_support.py +52 -0
- package/skills/math-model-draft/scripts/project_utils.py +106 -0
- package/skills/math-model-draft/scripts/validate_project.py +313 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 生成、修订或审计证据一致的数模项目与 TeX/PDF
|
|
3
|
+
argumentHint: <项目目录;可附“生成/修订/仅审计”,留空使用当前目录>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
显式使用 `$math-model-draft` 处理 `$ARGUMENTS`;若路径为空则使用当前工作区。
|
|
7
|
+
默认一键完成“读题—建模—代码—运行—结果/图表—完整论文—AI声明—编译—
|
|
8
|
+
逐页检查—交付包”,不得停在脚手架、提纲或示例段落。自动判断生成、修订或审计模式,保护题目原件,以最新代码和程序生成的
|
|
9
|
+
JSON/CSV 为数值事实源,完成模型—代码—结果—图表—论文一致性核验、真实
|
|
10
|
+
TeX Live 编译和逐页排版检查。不要只润色或给提纲;不得编造代码中不存在的
|
|
11
|
+
模型、算法、数据和数值。仅在会改变模型方向或可能误删重要资料时询问。
|
package/dist/index.js
CHANGED
|
@@ -238526,7 +238526,8 @@ var DEFAULT_CONFIG = {
|
|
|
238526
238526
|
".agents/skills",
|
|
238527
238527
|
".claude/skills",
|
|
238528
238528
|
"~/.claude/skills",
|
|
238529
|
-
"~/.orbit/skills"
|
|
238529
|
+
"~/.orbit/skills",
|
|
238530
|
+
"@orbit/builtin-skills"
|
|
238530
238531
|
],
|
|
238531
238532
|
activation: "auto",
|
|
238532
238533
|
maxActive: 3,
|
|
@@ -249925,13 +249926,14 @@ import { z as z43 } from "zod";
|
|
|
249925
249926
|
import { dirname as dirname5 } from "path";
|
|
249926
249927
|
import { isAbsolute as isAbsolute22, join as join32, resolve as resolve42 } from "path";
|
|
249927
249928
|
import { homedir as homedir4 } from "os";
|
|
249928
|
-
import { promises as fs2 } from "fs";
|
|
249929
|
+
import { existsSync as existsSync53, promises as fs2 } from "fs";
|
|
249930
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
249929
249931
|
import { parse as parseYaml3 } from "yaml";
|
|
249930
249932
|
import { z as z53 } from "zod";
|
|
249931
249933
|
import { dirname as dirname42, join as join42 } from "path";
|
|
249932
249934
|
import { parse as parseYaml22 } from "yaml";
|
|
249933
249935
|
import { z as z63 } from "zod";
|
|
249934
|
-
import { existsSync as
|
|
249936
|
+
import { existsSync as existsSync62, lstatSync as lstatSync4, promises as fs22 } from "fs";
|
|
249935
249937
|
import { dirname as dirname6, isAbsolute as isAbsolute32, join as join52, win32 as win322 } from "path";
|
|
249936
249938
|
import { parse as parseYaml32 } from "yaml";
|
|
249937
249939
|
var ProjectIndexer = class {
|
|
@@ -251691,12 +251693,22 @@ function normalizePath2(path6) {
|
|
|
251691
251693
|
return path6.replace(/\\/g, "/");
|
|
251692
251694
|
}
|
|
251693
251695
|
function resolveSkillDirectory(cwd, directory) {
|
|
251696
|
+
if (directory === "@orbit/builtin-skills") {
|
|
251697
|
+
return resolveBundledSkillsDirectory();
|
|
251698
|
+
}
|
|
251694
251699
|
if (directory === "~") return homedir4();
|
|
251695
251700
|
if (directory.startsWith("~/") || directory.startsWith("~\\")) {
|
|
251696
251701
|
return resolve42(homedir4(), directory.slice(2));
|
|
251697
251702
|
}
|
|
251698
251703
|
return isAbsolute22(directory) ? resolve42(directory) : resolve42(cwd, directory);
|
|
251699
251704
|
}
|
|
251705
|
+
function resolveBundledSkillsDirectory() {
|
|
251706
|
+
const candidates = [
|
|
251707
|
+
new URL("../../cli/skills/", import.meta.url),
|
|
251708
|
+
new URL("../../../cli/skills/", import.meta.url)
|
|
251709
|
+
].map((candidate) => fileURLToPath2(candidate));
|
|
251710
|
+
return candidates.find((candidate) => existsSync53(candidate)) ?? candidates[0];
|
|
251711
|
+
}
|
|
251700
251712
|
function resolveSkillDirectories(cwd, directories) {
|
|
251701
251713
|
const resolved = /* @__PURE__ */ new Map();
|
|
251702
251714
|
for (const directory of directories) {
|
|
@@ -252304,7 +252316,7 @@ function stripQueryAndFragment(value) {
|
|
|
252304
252316
|
}
|
|
252305
252317
|
function readable(path6) {
|
|
252306
252318
|
try {
|
|
252307
|
-
if (!
|
|
252319
|
+
if (!existsSync62(path6)) return false;
|
|
252308
252320
|
const stats = lstatSync4(path6);
|
|
252309
252321
|
return !stats.isSymbolicLink() && (stats.isFile() || stats.isDirectory());
|
|
252310
252322
|
} catch {
|
|
@@ -256247,7 +256259,14 @@ function resolveContextWindowStatus(input) {
|
|
|
256247
256259
|
}
|
|
256248
256260
|
function isContextWindowError(error) {
|
|
256249
256261
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
256250
|
-
|
|
256262
|
+
if (isOutputTokenLimitError(message2)) return false;
|
|
256263
|
+
return /(?:maximum context length|context(?: length| window)?.*(?:exceed|too long|maximum|max)|prompt is too long|input tokens?.*(?:exceed|limit))/i.test(
|
|
256264
|
+
message2
|
|
256265
|
+
);
|
|
256266
|
+
}
|
|
256267
|
+
function isOutputTokenLimitError(error) {
|
|
256268
|
+
const message2 = error instanceof Error ? error.message : String(error);
|
|
256269
|
+
return /(?:model output.*(?:truncated|token limit)|output tokens?.*(?:exceed|limit)|finish(?:_reason)?.*(?:length|max_tokens)|configured output token limit)/i.test(
|
|
256251
256270
|
message2
|
|
256252
256271
|
);
|
|
256253
256272
|
}
|
|
@@ -258439,6 +258458,7 @@ var AgentLoop = class _AgentLoop {
|
|
|
258439
258458
|
fallbackModelForRun = null;
|
|
258440
258459
|
fallbackExpiresAfterAttempt = 0;
|
|
258441
258460
|
contextOverflowRetriesForRun = 0;
|
|
258461
|
+
outputLimitRetriesForRun = 0;
|
|
258442
258462
|
approvedToolScopes = /* @__PURE__ */ new Set();
|
|
258443
258463
|
terminalFailure = null;
|
|
258444
258464
|
verificationStatus = "not_run";
|
|
@@ -258668,6 +258688,7 @@ ${normalized}`);
|
|
|
258668
258688
|
this.fallbackModelForRun = null;
|
|
258669
258689
|
this.fallbackExpiresAfterAttempt = 0;
|
|
258670
258690
|
this.contextOverflowRetriesForRun = 0;
|
|
258691
|
+
this.outputLimitRetriesForRun = 0;
|
|
258671
258692
|
this.approvedToolScopes.clear();
|
|
258672
258693
|
this.terminalFailure = null;
|
|
258673
258694
|
this.verificationStatus = "not_run";
|
|
@@ -258773,9 +258794,17 @@ ${normalized}`);
|
|
|
258773
258794
|
attempt: this.state.attemptCount
|
|
258774
258795
|
});
|
|
258775
258796
|
if (this.state.attemptCount > 1 && Number.isFinite(this.getRunawayPromptInterval()) && (this.state.attemptCount - 1) % this.getRunawayPromptInterval() === 0) {
|
|
258776
|
-
const
|
|
258777
|
-
|
|
258797
|
+
const completedIterations = this.state.attemptCount - 1;
|
|
258798
|
+
const continueExec = this.options.autoContinueRunaway ? true : await this.interaction.askApproval(
|
|
258799
|
+
`Agent loop has run for ${completedIterations} iterations. Continue executing to prevent runaway costs?`
|
|
258778
258800
|
);
|
|
258801
|
+
if (this.options.autoContinueRunaway) {
|
|
258802
|
+
this.interaction.showText(
|
|
258803
|
+
picocolors3.gray(
|
|
258804
|
+
`\u25CF Automated evaluation checkpoint: continuing after ${completedIterations} iterations within configured limits.`
|
|
258805
|
+
)
|
|
258806
|
+
);
|
|
258807
|
+
}
|
|
258779
258808
|
if (!continueExec) {
|
|
258780
258809
|
this.interaction.showText(
|
|
258781
258810
|
"\u25CF Terminated by user to prevent runaway iterations."
|
|
@@ -259077,13 +259106,49 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
259077
259106
|
}
|
|
259078
259107
|
} else if (this.abortController?.signal.aborted) {
|
|
259079
259108
|
} else {
|
|
259109
|
+
const outputLimitReached = isOutputTokenLimitError(chatError);
|
|
259110
|
+
if (outputLimitReached && this.outputLimitRetriesForRun < 2) {
|
|
259111
|
+
this.outputLimitRetriesForRun++;
|
|
259112
|
+
this.state.history.push({
|
|
259113
|
+
id: `msg_output_limit_recovery_${Date.now()}`,
|
|
259114
|
+
role: "user",
|
|
259115
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
259116
|
+
content: [
|
|
259117
|
+
{
|
|
259118
|
+
type: "text",
|
|
259119
|
+
text: [
|
|
259120
|
+
"Orbit recovery instruction: the previous response exceeded the model's output-token allowance before its actions could be completed.",
|
|
259121
|
+
"Continue the same task without repeating discovery. Emit at most four tool calls in this response, keep each write bounded, and split remaining work across later turns.",
|
|
259122
|
+
"Do not stop at an outline; execute the next concrete batch now."
|
|
259123
|
+
].join(" ")
|
|
259124
|
+
}
|
|
259125
|
+
],
|
|
259126
|
+
metadata: { kind: "output_limit_recovery" }
|
|
259127
|
+
});
|
|
259128
|
+
this.sessionManager.saveHistory(this.state.history);
|
|
259129
|
+
this.interaction.showText(
|
|
259130
|
+
picocolors3.yellow(
|
|
259131
|
+
`\u26A0 ${activeModel2} exceeded its output limit; retrying with a bounded action batch (${this.outputLimitRetriesForRun}/2).`
|
|
259132
|
+
)
|
|
259133
|
+
);
|
|
259134
|
+
continue;
|
|
259135
|
+
}
|
|
259080
259136
|
const contextWindowRejected = this.config.context.autoCompact && this.contextOverflowRetriesForRun < 2 && isContextWindowError(chatError);
|
|
259081
259137
|
if (contextWindowRejected) {
|
|
259082
259138
|
this.contextOverflowRetriesForRun++;
|
|
259083
259139
|
const retryStatus = this.getContextWindowStatus(activeModel2);
|
|
259140
|
+
const adaptiveRatio = this.contextOverflowRetriesForRun === 1 ? 0.6 : 0.4;
|
|
259084
259141
|
const compacted = await this.compactHistory(
|
|
259085
259142
|
"automatic",
|
|
259086
|
-
Math.max(
|
|
259143
|
+
Math.max(
|
|
259144
|
+
256,
|
|
259145
|
+
Math.floor(
|
|
259146
|
+
Math.min(
|
|
259147
|
+
retryStatus.compactAtTokens * 0.5,
|
|
259148
|
+
retryStatus.estimatedHistoryTokens * adaptiveRatio
|
|
259149
|
+
)
|
|
259150
|
+
)
|
|
259151
|
+
)
|
|
259087
259152
|
);
|
|
259088
259153
|
if (compacted.changed) {
|
|
259089
259154
|
this.interaction.showText(
|
|
@@ -259118,6 +259183,8 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
259118
259183
|
} finally {
|
|
259119
259184
|
this.interaction.progress?.stop();
|
|
259120
259185
|
}
|
|
259186
|
+
this.contextOverflowRetriesForRun = 0;
|
|
259187
|
+
this.outputLimitRetriesForRun = 0;
|
|
259121
259188
|
if (toolCallsToExecute.length === 0 && responseText) {
|
|
259122
259189
|
const xmlToolCalls = parseXMLToolCalls(responseText);
|
|
259123
259190
|
const textToolCalls = xmlToolCalls.length > 0 ? [] : parseTextToolCalls(
|
|
@@ -270042,6 +270109,7 @@ import picocolors18 from "picocolors";
|
|
|
270042
270109
|
import { existsSync as existsSync13, readdirSync as readdirSync6 } from "fs";
|
|
270043
270110
|
import { basename as basename4, extname as extname2, join as join14 } from "path";
|
|
270044
270111
|
import { homedir as homedir8 } from "os";
|
|
270112
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
270045
270113
|
import { parse as parse3 } from "yaml";
|
|
270046
270114
|
import { z as z50 } from "zod";
|
|
270047
270115
|
var CommandMetadataSchema = z50.object({
|
|
@@ -270138,6 +270206,10 @@ function loadCustomCommands(cwd, reservedNames = [], options = {}) {
|
|
|
270138
270206
|
);
|
|
270139
270207
|
const merged = /* @__PURE__ */ new Map();
|
|
270140
270208
|
const userHome = options.homeDir || homedir8();
|
|
270209
|
+
const builtinDirectory = options.builtinDir === false ? void 0 : options.builtinDir || resolveBundledCommandsDirectory();
|
|
270210
|
+
if (builtinDirectory) {
|
|
270211
|
+
mergeDirectory(merged, builtinDirectory, "builtin", reserved);
|
|
270212
|
+
}
|
|
270141
270213
|
mergeDirectory(
|
|
270142
270214
|
merged,
|
|
270143
270215
|
join14(userHome, ".claude", "commands"),
|
|
@@ -270156,6 +270228,13 @@ function loadCustomCommands(cwd, reservedNames = [], options = {}) {
|
|
|
270156
270228
|
(a3, b3) => a3.name.localeCompare(b3.name)
|
|
270157
270229
|
);
|
|
270158
270230
|
}
|
|
270231
|
+
function resolveBundledCommandsDirectory() {
|
|
270232
|
+
const candidates = [
|
|
270233
|
+
new URL("../../commands/", import.meta.url),
|
|
270234
|
+
new URL("../commands/", import.meta.url)
|
|
270235
|
+
].map((candidate) => fileURLToPath3(candidate));
|
|
270236
|
+
return candidates.find((candidate) => existsSync13(candidate)) ?? candidates[0];
|
|
270237
|
+
}
|
|
270159
270238
|
function expandCustomCommand(command, rawArguments) {
|
|
270160
270239
|
const args = rawArguments.trim();
|
|
270161
270240
|
const positional = args ? args.split(/\s+/) : [];
|
|
@@ -291032,7 +291111,8 @@ Risk Warning: ${reason}`);
|
|
|
291032
291111
|
sessionId: options?.resumeSessionId,
|
|
291033
291112
|
requireSession: Boolean(options?.resumeSessionId),
|
|
291034
291113
|
disableStatusBar: !!options?.nonInteractive || !!options?.jsonl,
|
|
291035
|
-
nonInteractive: !!options?.nonInteractive
|
|
291114
|
+
nonInteractive: !!options?.nonInteractive,
|
|
291115
|
+
autoContinueRunaway: !!options?.autoContinueRunaway
|
|
291036
291116
|
}
|
|
291037
291117
|
);
|
|
291038
291118
|
return await loop.run();
|
|
@@ -292058,10 +292138,23 @@ async function runEval(cwd, suiteFile, options = {}) {
|
|
|
292058
292138
|
mode: "auto",
|
|
292059
292139
|
requireApprovalForWrite: false,
|
|
292060
292140
|
requireApprovalForBash: !value.allowCommands
|
|
292141
|
+
},
|
|
292142
|
+
agent: {
|
|
292143
|
+
...DEFAULT_CONFIG.agent,
|
|
292144
|
+
// Acceptance tasks commonly include implementation plus their
|
|
292145
|
+
// verification-repair loop. Keep them bounded, but do not inherit
|
|
292146
|
+
// the shorter conversational default that truncates long Skills.
|
|
292147
|
+
maxIterations: 50
|
|
292061
292148
|
}
|
|
292062
292149
|
},
|
|
292063
292150
|
task.mode === "multi",
|
|
292064
|
-
{
|
|
292151
|
+
{
|
|
292152
|
+
nonInteractive: true,
|
|
292153
|
+
// Eval already has explicit task, iteration, cost, worktree, and
|
|
292154
|
+
// verification bounds. Periodic UI prompts would otherwise abort
|
|
292155
|
+
// every long acceptance task without weakening tool approvals.
|
|
292156
|
+
autoContinueRunaway: true
|
|
292157
|
+
}
|
|
292065
292158
|
);
|
|
292066
292159
|
const checks = value.allowCommands ? await runVerificationChecks(worktree.path, task.verification) : [];
|
|
292067
292160
|
const changedFiles = readChangedFiles(worktree.path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbit-build/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"dist",
|
|
38
|
-
"README.md"
|
|
38
|
+
"README.md",
|
|
39
|
+
"commands",
|
|
40
|
+
"skills"
|
|
39
41
|
],
|
|
40
42
|
"publishConfig": {
|
|
41
43
|
"access": "public"
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: math-model-draft
|
|
3
|
+
description: Build, revise, or audit a mathematical-modeling competition project from problem statements, attachments, current code, machine-readable results, figures, TeX, PDFs, and reference papers. Produces evidence-linked Chinese LaTeX, runnable q1/q2 code, validated outputs, current figures, AI-use disclosure, and submission packages. Use explicitly for 数学建模、国赛/CUMCM、研究生数模、校赛、美赛中文稿、论文初稿或定稿审查、TeX/PDF 修订、模型—代码—结果—论文一致性核验。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build or revise a mathematical-modeling paper
|
|
7
|
+
|
|
8
|
+
Deliver a compilable, evidence-backed project, not an outline or generic prose.
|
|
9
|
+
Never invent a model, algorithm, datum, parameter, numerical result, validation,
|
|
10
|
+
or figure that the current code and artifacts do not support. Mark unresolved
|
|
11
|
+
facts visibly with `TODO[reason]`.
|
|
12
|
+
|
|
13
|
+
## Mandatory execution order for generation
|
|
14
|
+
|
|
15
|
+
After one project inventory, begin implementation immediately:
|
|
16
|
+
|
|
17
|
+
1. Trust bundled helpers as public interfaces. Do **not** read their source,
|
|
18
|
+
test verifiers, every template section, or all optional references first.
|
|
19
|
+
2. Do **not** probe or install the scientific Python stack up front. Use the
|
|
20
|
+
available dependencies; for a small deterministic task, prefer the standard
|
|
21
|
+
library. Add a dependency only when the selected model truly requires it.
|
|
22
|
+
3. Start the first substantive write within five tool calls after inventory.
|
|
23
|
+
Work in bounded batches: at most four write/edit calls per model response,
|
|
24
|
+
no giant all-project tool call, and leave enough output budget for valid
|
|
25
|
+
tool-call closure. Implement code/results first, then paper sections in
|
|
26
|
+
coherent groups; do not spend turns on cosmetic inspection between them.
|
|
27
|
+
4. Run `code/run_all.py`, repair its evidence, then call the finalizer without
|
|
28
|
+
reading the finalizer's implementation.
|
|
29
|
+
5. Spend remaining turns only on failed checks and rendered-page defects.
|
|
30
|
+
|
|
31
|
+
When the project-local finalizer exits with code 0, the strict build, audit,
|
|
32
|
+
page rendering, packaging, and validation are already complete. Stop tool use
|
|
33
|
+
immediately and return the required final report. Do not write scratch verifier
|
|
34
|
+
scripts, inspect build caches, re-parse the PDFs, or rerun checks after a
|
|
35
|
+
successful finalizer. A successful finalizer is the terminal condition.
|
|
36
|
+
|
|
37
|
+
Do not repeat environment, path, template, or helper probes that already
|
|
38
|
+
succeeded. A progress plan must not delay the first substantive write.
|
|
39
|
+
If `paper/input-inventory.json`, `paper/contest-profile.json`, `code/qN`, and
|
|
40
|
+
`paper/main.tex` already exist, the scaffold is ready: do not read the Skill
|
|
41
|
+
directory, helper sources, or every placeholder section. Read only the problem
|
|
42
|
+
inventory/data and the target files needed for the next bounded write batch.
|
|
43
|
+
Never create an environment-probe script; run the required project entry point
|
|
44
|
+
and react only to a concrete missing dependency.
|
|
45
|
+
|
|
46
|
+
## Guidance routing and round-trip budget
|
|
47
|
+
|
|
48
|
+
This `SKILL.md` contains the complete mandatory contract. Do not spend the
|
|
49
|
+
opening tool turns reading every reference file. Prepare and inspect the actual
|
|
50
|
+
project first, then read only the reference needed at the decision point:
|
|
51
|
+
|
|
52
|
+
- structure: `references/project-architecture.md` and `paper-architecture.md`;
|
|
53
|
+
- model/code quality: `modeling-quality.md` and `code-and-output-style.md`;
|
|
54
|
+
- existing paper: `paper-revision.md`;
|
|
55
|
+
- CUMCM compliance: `cumcm-compliance.md`;
|
|
56
|
+
- final typesetting: `latex-figures-tables.md`.
|
|
57
|
+
|
|
58
|
+
Batch independent reads, writes, and safe commands. Do not repeatedly probe the
|
|
59
|
+
same binary input: use `inspect_inputs.py` once, then consume its extracted text
|
|
60
|
+
and structured inventory. Resolve references relative to this `SKILL.md` if
|
|
61
|
+
`skill://math-model-draft/` is unavailable. Supplied current contest rules and
|
|
62
|
+
templates always outrank this Skill's defaults.
|
|
63
|
+
|
|
64
|
+
## Select the operating mode
|
|
65
|
+
|
|
66
|
+
The default `/math-draft <project>` path is a one-request, end-to-end generation:
|
|
67
|
+
read the problem, model every question, implement and run the code, generate
|
|
68
|
+
results and figures, write the complete paper, compile, inspect, and package it.
|
|
69
|
+
Do not stop after scaffolding, an outline, sample paragraphs, or formatting.
|
|
70
|
+
|
|
71
|
+
Inspect the project before editing and choose one mode automatically:
|
|
72
|
+
|
|
73
|
+
- **Generate** (default for a problem directory): create the skeleton and fill
|
|
74
|
+
every substantive section from the problem and computed evidence, then finish
|
|
75
|
+
the PDF and support package in the same run.
|
|
76
|
+
- **Revise**: TeX/PDF and code/results already exist. Preserve sound content and
|
|
77
|
+
make local additions or corrections; do not rewrite merely for style.
|
|
78
|
+
- **Audit**: the user asks only for findings. Run read-only checks and report;
|
|
79
|
+
do not change project files.
|
|
80
|
+
|
|
81
|
+
For revision, read every relevant problem/attachment, latest code directory,
|
|
82
|
+
`results/`, `figures/`, current TeX/PDF, and any excellent-paper directory.
|
|
83
|
+
Reference papers guide structure and comparison only; they are never a source
|
|
84
|
+
of this project's results.
|
|
85
|
+
|
|
86
|
+
## Establish sources of truth
|
|
87
|
+
|
|
88
|
+
Use this precedence for factual conflicts:
|
|
89
|
+
|
|
90
|
+
1. official problem, supplied data, and current contest rules;
|
|
91
|
+
2. current runnable code and configuration;
|
|
92
|
+
3. program-generated JSON/CSV/XLSX and validation artifacts;
|
|
93
|
+
4. figures generated from those artifacts;
|
|
94
|
+
5. TeX and compiled PDF;
|
|
95
|
+
6. excellent papers and secondary commentary.
|
|
96
|
+
|
|
97
|
+
Treat `question/` as immutable. Use JSON/CSV as the numerical fact source and
|
|
98
|
+
check every summary/body/table/figure/conclusion value for units, signs,
|
|
99
|
+
precision, constraints, and consistency. Prefer a reference paper's final
|
|
100
|
+
results table over its abstract when auditing that paper's own numbers.
|
|
101
|
+
In TeX, never write raw underscores or other special characters in paths and
|
|
102
|
+
identifiers; use a safe path command such as `\path{code/q1/model.py}` or escape
|
|
103
|
+
the character explicitly. Treat the finalizer's first file/line diagnostic as
|
|
104
|
+
the repair target instead of launching ad-hoc TeX probes.
|
|
105
|
+
|
|
106
|
+
## Run the workflow
|
|
107
|
+
|
|
108
|
+
Resolve `<skill-root>` to this Skill's directory and `<project-root>` to the
|
|
109
|
+
project being handled.
|
|
110
|
+
|
|
111
|
+
### 1. Inventory and configure
|
|
112
|
+
|
|
113
|
+
```powershell
|
|
114
|
+
python "<skill-root>/scripts/inspect_inputs.py" <project-root>
|
|
115
|
+
python "<skill-root>/scripts/bootstrap_project.py" <project-root> --questions <N>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The bootstrap is additive and idempotent. It may add missing q-folders and
|
|
119
|
+
orchestrator entries, but must not overwrite authored content. Review
|
|
120
|
+
`paper/contest-profile.json`; select `cumcm-2026` only when applicable. Do not
|
|
121
|
+
silently apply CUMCM limits to another contest.
|
|
122
|
+
|
|
123
|
+
### 2. Plan evidence before prose
|
|
124
|
+
|
|
125
|
+
Maintain `paper/evidence-map.yaml`. Every material claim needs an identifier,
|
|
126
|
+
an in-project `results/` source, a target `paper/sections/` file, and status
|
|
127
|
+
`TODO` or `verified`. Define each subproblem's variables, units, constraints,
|
|
128
|
+
parameter sources, candidate methods, selection reason, data dependencies,
|
|
129
|
+
outputs, and validation.
|
|
130
|
+
|
|
131
|
+
### 3. Implement and run
|
|
132
|
+
|
|
133
|
+
- Put shared configuration/loading/plotting/validation in `code/always` and
|
|
134
|
+
question-specific work in `code/qN`; keep each `main.py` orchestral.
|
|
135
|
+
- Validate raw data, fix seeds, record the environment, compare a transparent
|
|
136
|
+
baseline where complexity matters, and use appropriate sensitivity,
|
|
137
|
+
residual, uncertainty, cross-validation, or robustness checks.
|
|
138
|
+
- Run from a clean entry point and repair failures before asserting results.
|
|
139
|
+
- Save factual outputs in `results/qN`, paper-ready visuals in `figures/qN`,
|
|
140
|
+
and completed workbook deliverables in `results/qN`.
|
|
141
|
+
|
|
142
|
+
```powershell
|
|
143
|
+
python <project-root>/code/run_all.py
|
|
144
|
+
python "<skill-root>/scripts/capture_environment.py" <project-root>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 4. Write or revise from evidence
|
|
148
|
+
|
|
149
|
+
For every question, make the progression explicit: task interpretation,
|
|
150
|
+
variables and constraints, model choice and reason, equations, parameter
|
|
151
|
+
sources, algorithm, numerical results, interpretation, validation, conclusion,
|
|
152
|
+
and handoff to the next question. Keep the abstract informative: each question
|
|
153
|
+
must retain its model, algorithm, key values, and conclusion.
|
|
154
|
+
|
|
155
|
+
In revision mode, prefer surgical additions and corrections. Do not compress
|
|
156
|
+
the abstract, change global spacing, or replace large passages without factual
|
|
157
|
+
need. Ensure every figure is current, legible in Chinese, cited and interpreted
|
|
158
|
+
near first discussion, and free of clipping, overlap, drift, cross-question
|
|
159
|
+
misplacement, and abnormal whitespace. Check reference aliases, table labels,
|
|
160
|
+
paper-number shorthand, and bibliography numbering for mismatches.
|
|
161
|
+
|
|
162
|
+
If the appendix includes source code, regenerate it from the current code tree.
|
|
163
|
+
Whether support-file lists or source appendices are included is controlled by
|
|
164
|
+
the contest profile; official CUMCM requirements must not be disabled merely as
|
|
165
|
+
a stylistic preference.
|
|
166
|
+
|
|
167
|
+
### 5. Audit, build, package, and inspect every page
|
|
168
|
+
|
|
169
|
+
Use the one-command finalizer after the substantive code and paper are complete:
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
python <project-root>/code/finalize.py --run-code --strict-layout --render-pages
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The project-local launcher executes the active Skill's trusted finalizer without
|
|
176
|
+
requiring a shell command outside the workspace. It records the environment,
|
|
177
|
+
rebuilds with local TeX Live, audits and optionally
|
|
178
|
+
renders every page, packages support materials, and runs strict validation. Its
|
|
179
|
+
individual scripts may be run separately while repairing a failure.
|
|
180
|
+
|
|
181
|
+
Use the machine-readable audit report to resolve missing inputs, stale figures,
|
|
182
|
+
missing TeX assets, unresolved references, weak question sections, and stale
|
|
183
|
+
PDFs. Render the final PDF and inspect every page. There must be no blank page,
|
|
184
|
+
orphan heading, overflow, missing glyph, undefined reference, overfull/underfull
|
|
185
|
+
box, clipped figure/table, or inexplicable whitespace.
|
|
186
|
+
|
|
187
|
+
Clean only known caches and temporary render products after verification:
|
|
188
|
+
|
|
189
|
+
```powershell
|
|
190
|
+
python "<skill-root>/scripts/clean_project.py" <project-root> --apply
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Never remove original questions, current code, effective results, paper figures,
|
|
194
|
+
TeX sources, final PDFs, or unknown files.
|
|
195
|
+
|
|
196
|
+
## AI-use compliance
|
|
197
|
+
|
|
198
|
+
Using this Skill is itself AI assistance. For CUMCM 2026, default to the
|
|
199
|
+
official “used AI” declaration unless the project demonstrably predates use.
|
|
200
|
+
Keep the declaration immediately before references and generate the required
|
|
201
|
+
`AI工具使用详情.pdf`. Record tool/model, stage and purpose, prompting process,
|
|
202
|
+
adoption/manual changes, and verification. Never present an unofficial AIGC or
|
|
203
|
+
AIDC percentage from a secondary article as an official disqualification rule.
|
|
204
|
+
|
|
205
|
+
## Completion gate
|
|
206
|
+
|
|
207
|
+
Finish only when inputs are inventoried; `question/` fingerprint is unchanged;
|
|
208
|
+
all q1/q2/... paths align; code runs; every reported number is evidence-linked;
|
|
209
|
+
assumptions, units, limitations, and validation are explicit; figures and code
|
|
210
|
+
appendix are current; TeX compiles under local TeX Live; the final PDF passes
|
|
211
|
+
page-by-page inspection; package contents satisfy the active profile; and every
|
|
212
|
+
remaining TODO or manual decision is reported.
|
|
213
|
+
|
|
214
|
+
The final response should contain only: material changes, defects fixed,
|
|
215
|
+
numerical consistency result, compile/layout verification, remaining TODOs, and
|
|
216
|
+
absolute paths to final files.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Mathematical Modeling Draft"
|
|
3
|
+
short_description: "One-click complete modeling paper, code, PDF, and compliance package"
|
|
4
|
+
default_prompt: "Use $math-model-draft to read every problem and attachment in this project, complete all modeling and runnable q1/q2 code, generate verified results and figures, write the full evidence-linked LaTeX paper, add the current AI-use declaration, compile with local TeX Live, inspect every PDF page, and package the final delivery. Do not stop at scaffolding or an outline."
|
|
5
|
+
policy:
|
|
6
|
+
allow_implicit_invocation: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
CODE_ROOT = Path(__file__).resolve().parents[1]
|
|
7
|
+
PROJECT_ROOT = CODE_ROOT.parent
|
|
8
|
+
QUESTION_DIR = PROJECT_ROOT / "question"
|
|
9
|
+
RESULTS_DIR = PROJECT_ROOT / "results"
|
|
10
|
+
FIGURES_DIR = PROJECT_ROOT / "figures"
|
|
11
|
+
RANDOM_STATE = 2026
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def question_output_dirs(question: str) -> tuple[Path, Path]:
|
|
15
|
+
if not question.startswith("q") or not question[1:].isdigit():
|
|
16
|
+
raise ValueError(f"Invalid question name: {question}")
|
|
17
|
+
return RESULTS_DIR / question, FIGURES_DIR / question
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Iterable
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
from always.config import QUESTION_DIR
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def input_files(suffixes: Iterable[str]) -> list[Path]:
|
|
12
|
+
normalized = {suffix.lower() for suffix in suffixes}
|
|
13
|
+
return sorted(
|
|
14
|
+
path
|
|
15
|
+
for path in QUESTION_DIR.rglob("*")
|
|
16
|
+
if path.is_file() and path.suffix.lower() in normalized
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def require_columns(frame: pd.DataFrame, columns: Iterable[str]) -> None:
|
|
21
|
+
missing = sorted(set(columns) - set(frame.columns))
|
|
22
|
+
if missing:
|
|
23
|
+
raise ValueError(f"Missing required columns: {missing}")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def setup_plotting() -> None:
|
|
9
|
+
plt.rcParams["font.sans-serif"] = [
|
|
10
|
+
"Microsoft YaHei",
|
|
11
|
+
"SimHei",
|
|
12
|
+
"Noto Sans CJK SC",
|
|
13
|
+
"Arial Unicode MS",
|
|
14
|
+
]
|
|
15
|
+
plt.rcParams["axes.unicode_minus"] = False
|
|
16
|
+
plt.rcParams["figure.dpi"] = 140
|
|
17
|
+
plt.rcParams["savefig.dpi"] = 300
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def save_figure(path: Path) -> None:
|
|
21
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
plt.tight_layout()
|
|
23
|
+
plt.savefig(path, bbox_inches="tight")
|
|
24
|
+
plt.close()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def require_finite(values: np.ndarray, label: str) -> None:
|
|
11
|
+
if not np.isfinite(values).all():
|
|
12
|
+
raise ValueError(f"{label} contains non-finite values.")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def write_summary(path: Path, payload: dict[str, Any]) -> None:
|
|
16
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
17
|
+
path.write_text(
|
|
18
|
+
json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
|
19
|
+
encoding="utf-8",
|
|
20
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import runpy
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def resolve_finalizer() -> Path:
|
|
15
|
+
personal = Path.home() / ".orbit" / "skills" / "math-model-draft" / "scripts" / "finalize_project.py"
|
|
16
|
+
if personal.is_file():
|
|
17
|
+
return personal
|
|
18
|
+
orbit = shutil.which("orbit")
|
|
19
|
+
if orbit:
|
|
20
|
+
completed = subprocess.run(
|
|
21
|
+
[orbit, "skills", "list", "--json"],
|
|
22
|
+
cwd=PROJECT_ROOT,
|
|
23
|
+
text=True,
|
|
24
|
+
encoding="utf-8",
|
|
25
|
+
errors="replace",
|
|
26
|
+
stdout=subprocess.PIPE,
|
|
27
|
+
stderr=subprocess.PIPE,
|
|
28
|
+
check=False,
|
|
29
|
+
)
|
|
30
|
+
if completed.returncode == 0:
|
|
31
|
+
try:
|
|
32
|
+
payload = json.loads(completed.stdout)
|
|
33
|
+
except json.JSONDecodeError:
|
|
34
|
+
payload = {}
|
|
35
|
+
for skill in payload.get("skills", []):
|
|
36
|
+
if skill.get("name") != "math-model-draft":
|
|
37
|
+
continue
|
|
38
|
+
candidate = Path(str(skill.get("path", ""))).resolve().parent / "scripts" / "finalize_project.py"
|
|
39
|
+
if candidate.is_file():
|
|
40
|
+
return candidate
|
|
41
|
+
raise SystemExit(
|
|
42
|
+
"Active math-model-draft finalizer is missing. Run `orbit skills list` "
|
|
43
|
+
"and ensure the bundled or personal Skill is enabled."
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main() -> None:
|
|
48
|
+
finalizer = resolve_finalizer()
|
|
49
|
+
sys.path.insert(0, str(finalizer.parent))
|
|
50
|
+
sys.argv = [str(finalizer), str(PROJECT_ROOT), *sys.argv[1:]]
|
|
51
|
+
runpy.run_path(str(finalizer), run_name="__main__")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
main()
|