@morning-start/dsh-code-toolkit 0.0.0-stage → 0.27.1
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/CHANGELOG.md +375 -0
- package/LICENSE +35 -0
- package/README.md +252 -2
- package/agents/caption/AGENT.md +165 -0
- package/agents/caption/examples/dispatch.md +83 -0
- package/agents/caption/examples/loop.md +66 -0
- package/agents/caption/examples/theater.md +40 -0
- package/agents/caption/references/dispatch.md +128 -0
- package/agents/caption/references/evidence.md +82 -0
- package/agents/caption/references/experts.md +141 -0
- package/agents/caption/references/flows.md +97 -0
- package/agents/caption/references/loop.md +75 -0
- package/agents/pua/AGENT.md +66 -0
- package/agents/pua/examples/run.md +41 -0
- package/agents/pua/references/flavors.md +33 -0
- package/agents/pua/references/methodology.md +32 -0
- package/agents/review/AGENT.md +112 -0
- package/agents/review/examples/clean.md +40 -0
- package/agents/review/examples/findings.md +49 -0
- package/agents/review/references/evidence.md +33 -0
- package/agents/review/references/output.md +59 -0
- package/agents/review/references/rubric.md +43 -0
- package/agents/review/references/severity.md +45 -0
- package/agents/scrub/AGENT.md +130 -0
- package/agents/scrub/examples/clean.md +70 -0
- package/agents/scrub/examples/report.md +66 -0
- package/agents/scrub/references/false-positives.md +92 -0
- package/agents/scrub/references/patterns.md +52 -0
- package/agents/scrub/references/redaction.md +53 -0
- package/agents/simplify/AGENT.md +160 -0
- package/agents/simplify/examples/apply.md +60 -0
- package/agents/simplify/examples/plan.md +65 -0
- package/agents/simplify/references/anti-patterns.md +45 -0
- package/agents/simplify/references/behavior-preservation.md +41 -0
- package/agents/simplify/references/conventions.md +34 -0
- package/agents/simplify/references/operations.md +51 -0
- package/agents/simplify/references/verification.md +74 -0
- package/cordis.patch.yml +23 -0
- package/icon.svg +8 -0
- package/index.js +207 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +62 -4
- package/src/command.js +328 -0
- package/src/delivery.js +48 -0
- package/src/i18n.js +164 -0
- package/src/journal.js +56 -0
- package/src/pua.js +48 -0
- package/src/report.js +202 -0
- package/src/runtime.js +94 -0
- package/src/selection.js +258 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Project conventions
|
|
2
|
+
|
|
3
|
+
The point of this file is that a simplifier should make code look **more** like its own repository, not more like the simplifier's taste.
|
|
4
|
+
|
|
5
|
+
## Read, in this order
|
|
6
|
+
|
|
7
|
+
1. `AGENTS.override.md` — highest precedence, usually local overrides.
|
|
8
|
+
2. `AGENTS.md` at the repository root, then in the nearest parent directory of the file you are editing.
|
|
9
|
+
3. `CLAUDE.md`, `.cursor/rules`, `.github/copilot-instructions.md` — configured fallbacks.
|
|
10
|
+
4. `CONTRIBUTING.md`, `STYLE.md`, lint config (`.eslintrc*`, `ruff.toml`, `rustfmt.toml`, `.editorconfig`).
|
|
11
|
+
5. The two or three files nearest the one you are editing — the strongest signal of all.
|
|
12
|
+
|
|
13
|
+
A more specific file beats a more general one. The user's explicit instruction beats every file.
|
|
14
|
+
|
|
15
|
+
## What to extract
|
|
16
|
+
|
|
17
|
+
- Formatting: quotes, semicolons, trailing commas, import order, line width.
|
|
18
|
+
- Naming: `camelCase` vs `snake_case`, verb-first function names, constant casing.
|
|
19
|
+
- Error handling: thrown errors vs result objects, error message style, whether `try/catch` is used at all.
|
|
20
|
+
- Logging: the logger, the level vocabulary, structured vs formatted.
|
|
21
|
+
- Comments: whether the project uses doc blocks, and in what shape.
|
|
22
|
+
- Tests: framework, file layout, naming, how mocks are built.
|
|
23
|
+
|
|
24
|
+
## Rules
|
|
25
|
+
|
|
26
|
+
- **Never introduce a second style.** If the file uses `function`, do not add arrow functions; if it uses `snake_case`, do not rename to `camelCase`.
|
|
27
|
+
- **Never "fix" a style the project has not declared wrong.** A style you dislike is not a finding.
|
|
28
|
+
- **A declared convention beats local inconsistency** only when the file is already the outlier; otherwise follow the file.
|
|
29
|
+
- **Lint config is the contract.** If the linter allows it, it is allowed.
|
|
30
|
+
- **Do not reformat untouched lines.** A diff that reformats a whole file hides the change you were asked to make.
|
|
31
|
+
|
|
32
|
+
## When conventions conflict
|
|
33
|
+
|
|
34
|
+
Say so in the plan and pick the narrower scope (the file over the repository), because the narrower one is what the reviewer will compare against.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# The six operations, in depth
|
|
2
|
+
|
|
3
|
+
Each operation lists what qualifies, what it looks like, and the test that decides whether it is in scope.
|
|
4
|
+
|
|
5
|
+
## 1. Remove redundancy
|
|
6
|
+
|
|
7
|
+
**Qualifies**: unreachable branches, unused imports and variables, assignments overwritten before any read, duplicated conditionals, a helper that only forwards its arguments, copy-pasted blocks that must stay in sync.
|
|
8
|
+
|
|
9
|
+
**Does not qualify**: code that looks unused but is reachable through reflection, string lookup, dynamic import, a public export, or a framework convention. Check before deleting.
|
|
10
|
+
|
|
11
|
+
**Test**: delete it, then prove nothing reads it. `grep` for the identifier; check the package's public surface; run the tests.
|
|
12
|
+
|
|
13
|
+
## 2. Flatten nesting
|
|
14
|
+
|
|
15
|
+
**Qualifies**: early returns replacing `if (ok) { …entire body… }`, `continue` replacing a wrapping `if` in a loop, a pyramid of four or more levels, a pass-through function whose only statement is a call.
|
|
16
|
+
|
|
17
|
+
**Does not qualify**: flattening that moves a side effect before a guard and changes what runs on the error path.
|
|
18
|
+
|
|
19
|
+
**Test**: every early return must preserve the same set of effects in the same order on every path. Draw the before/after paths for the error case, not just the happy case.
|
|
20
|
+
|
|
21
|
+
## 3. Improve readability
|
|
22
|
+
|
|
23
|
+
**Qualifies**: a name that describes the type instead of the meaning (`data`, `tmp`, `res2`); a boolean parameter that makes call sites unreadable (`save(x, true, false)`); a single-use temporary that only obscures the expression; related statements scattered by unrelated ones.
|
|
24
|
+
|
|
25
|
+
**Does not qualify**: renaming a public symbol (that is a breaking change, not a simplification); renaming to a longer name that says the same thing.
|
|
26
|
+
|
|
27
|
+
**Test**: the new name must let a reader skip the definition. If they still have to look, it is not clearer.
|
|
28
|
+
|
|
29
|
+
## 4. Clean comments
|
|
30
|
+
|
|
31
|
+
**Qualifies**: `// increment i`, commented-out code, a changelog in the file header, a comment that contradicts the code, a doc block whose parameters no longer exist.
|
|
32
|
+
|
|
33
|
+
**Does not qualify**: anything explaining *why* — a workaround, a non-obvious constraint, a link to an issue, a unit, a magic constant's origin, a warning about ordering.
|
|
34
|
+
|
|
35
|
+
**Test**: if removing the comment would let a future reader "fix" the code into a bug, keep it.
|
|
36
|
+
|
|
37
|
+
## 5. Sharpen logs
|
|
38
|
+
|
|
39
|
+
**Qualifies**: `console.log('done')` with no subject; a log that fires on a path where nothing failed; an error logged without the operation, the key, or the cause; a level that misleads (`info` for a failed write).
|
|
40
|
+
|
|
41
|
+
**Does not qualify**: changing log *content* that tests assert on, or that an operator greps for. Check the tests and the runbooks first.
|
|
42
|
+
|
|
43
|
+
**Test**: from the log line alone, can someone locate the problem? If not, it needs the object, the key, the count, or the reason.
|
|
44
|
+
|
|
45
|
+
## 6. Drop self-proving tests
|
|
46
|
+
|
|
47
|
+
**Qualifies**: `expect(true).toBe(true)`, an assertion on a mock's own return value, a test that asserts a constant equals itself, a snapshot nobody reads, a test that passes when the implementation is deleted.
|
|
48
|
+
|
|
49
|
+
**Does not qualify**: a test that looks trivial but pins a contract (an error message, a status code, a serialization shape), or a branch that is only covered here.
|
|
50
|
+
|
|
51
|
+
**Test**: break the implementation deliberately — if the test still passes, it was never testing anything.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Verification methods
|
|
2
|
+
|
|
3
|
+
Pick the strongest method the project actually supports. State which one you used, and what it does not cover.
|
|
4
|
+
|
|
5
|
+
## In order of strength
|
|
6
|
+
|
|
7
|
+
1. **The project's test suite, run before and after.** Both runs must be green. A test that was already failing is not your evidence — say so.
|
|
8
|
+
2. **A differential check on real input.** Run the old and new implementation on the same input, compare the output byte for byte (or structurally, if ordering is not guaranteed).
|
|
9
|
+
3. **A targeted test you write and keep.** If the change touches an untested path, a small test is a legitimate part of the change — but say that you added it, and do not add it to the "behaviour unchanged" column.
|
|
10
|
+
4. **A line-by-line audit against the checklist.** Weakest, and only honest when the project has no tests.
|
|
11
|
+
|
|
12
|
+
## Per language
|
|
13
|
+
|
|
14
|
+
- **JavaScript / TypeScript**: `npm test`, `node --test`, `tsc --noEmit`, `eslint`. Watch for tests that only run under a different Node version.
|
|
15
|
+
- **Python**: `pytest -q`, `python -m compileall`, `mypy` if configured.
|
|
16
|
+
- **Go**: `go test ./...`, `go vet`.
|
|
17
|
+
- **Rust**: `cargo test`, `cargo clippy`.
|
|
18
|
+
- **Java / Kotlin**: `mvn -q test`, `gradle test`.
|
|
19
|
+
- **C#**: `dotnet test`.
|
|
20
|
+
|
|
21
|
+
Run only what the project already defines. Do not add a test runner, a config file, or a dependency as part of a simplification — that is scope creep, and it changes the build.
|
|
22
|
+
|
|
23
|
+
## What counts as failure
|
|
24
|
+
|
|
25
|
+
- The suite fails after your change and passed before → revert that change.
|
|
26
|
+
- The suite fails both before and after → not your evidence; report the pre-existing failure.
|
|
27
|
+
- The command is unavailable (no network, no toolchain) → say so and fall back to the audit; never write "tests pass".
|
|
28
|
+
|
|
29
|
+
## Reporting
|
|
30
|
+
|
|
31
|
+
In the **apply** report, `Verification` needs the exact command and the result:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
- **Command**: `npm test -- --runInBand`
|
|
35
|
+
- **Result**: pass (34 tests, 0 failures)
|
|
36
|
+
- **Notes**: the suite does not cover `src/legacy/`, which this change touches.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A vague "verified" is worse than an honest "not verified, and here is why".
|
|
40
|
+
|
|
41
|
+
## When the project has no tests
|
|
42
|
+
|
|
43
|
+
A repository with no suite is not a licence to guess. Build a characterization
|
|
44
|
+
baseline **before the first edit**, and keep it reproducible:
|
|
45
|
+
|
|
46
|
+
1. **Compile / parse the tree** — `python -m compileall -q src`, `node --check`,
|
|
47
|
+
`tsc --noEmit`, `go build ./...`. A baseline that does not compile is itself
|
|
48
|
+
the finding.
|
|
49
|
+
2. **Import smoke** — import every touched module (or the app's entry point) so
|
|
50
|
+
import-time errors surface before and after.
|
|
51
|
+
3. **Run the real entry points on real input** — the CLI, the handler, the
|
|
52
|
+
script the project actually uses. Capture stdout, exit codes, and every file
|
|
53
|
+
it writes; hash them (`sha256sum`, `Get-FileHash`). This is the strongest
|
|
54
|
+
evidence available without a suite.
|
|
55
|
+
4. **Pin pure functions with a table** — call each touched function on a fixed
|
|
56
|
+
list of inputs (including the empty, boundary, and error cases) and record
|
|
57
|
+
input → output. Compare the table after the change; any difference is a
|
|
58
|
+
behaviour change, not a rounding detail.
|
|
59
|
+
|
|
60
|
+
Record the baseline commands and their output in the plan (or in the apply
|
|
61
|
+
report's `Verification`). After each batch, re-run the same commands and diff.
|
|
62
|
+
|
|
63
|
+
**If no baseline can be built** — no runnable entry point, no real input, no
|
|
64
|
+
toolchain — do not apply. Return the plan, name what is missing, and say what
|
|
65
|
+
would make it verifiable. An unverifiable edit is not a simplification; it is an
|
|
66
|
+
unreviewed change with a nicer name.
|
|
67
|
+
|
|
68
|
+
## One batch at a time
|
|
69
|
+
|
|
70
|
+
Apply one item, or one file group, then run the gate. Two independent edits under
|
|
71
|
+
a single gate cannot tell you which one broke it, and reverting both throws away
|
|
72
|
+
work that was correct. If a batch fails the gate, revert that batch and record
|
|
73
|
+
why — do not "fix forward" inside a simplification.
|
|
74
|
+
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Insert the code-toolkit Host plugin into the current profile.
|
|
2
|
+
#
|
|
3
|
+
# Every config key is optional; the defaults are what the commands use when the
|
|
4
|
+
# block below stays empty.
|
|
5
|
+
#
|
|
6
|
+
# reportDirectory absolute path for the journal default: $DSH_HOME/code-toolkit
|
|
7
|
+
# reviewModel model id for the review child default: the host's model
|
|
8
|
+
# simplifyModel model id for the simplify child default: the host's model
|
|
9
|
+
# scrubModel model id for the scrub child default: the host's model
|
|
10
|
+
# locale force the output language default: follow the host
|
|
11
|
+
# ledgerDirectory where caption keeps its ledger default: <project>/docs/caption
|
|
12
|
+
# (a relative path resolves against the project)
|
|
13
|
+
# runTimeoutMinutes release a hung `sub` run's slot after this many minutes
|
|
14
|
+
# default: 30; 0 disables the limit
|
|
15
|
+
# planMaxAgeMinutes how long an approved `report` plan stays usable by the
|
|
16
|
+
# next apply run default: 60; 0 disables the limit
|
|
17
|
+
#
|
|
18
|
+
# An invalid value (a relative reportDirectory, an empty model name) fails at
|
|
19
|
+
# load time instead of at the first command.
|
|
20
|
+
- insert:
|
|
21
|
+
- id: morning-start-code-toolkit
|
|
22
|
+
name: '@morning-start/dsh-code-toolkit'
|
|
23
|
+
config: {}
|
package/icon.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" role="img" aria-label="Code toolkit">
|
|
2
|
+
<g fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.6">
|
|
3
|
+
<path d="M 12.5 11.5 L 6.5 18 L 12.5 24.5" stroke="#5AA2FF"/>
|
|
4
|
+
<path d="M 23.5 11.5 L 29.5 18 L 23.5 24.5" stroke="#5AA2FF"/>
|
|
5
|
+
<path d="M 20.5 9.5 L 15.5 26.5" stroke="#E9EEF5" stroke-width="2.2"/>
|
|
6
|
+
<path d="M 12.5 29.5 L 23.5 29.5" stroke="#F2B25C" stroke-width="2.2"/>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { dirname, isAbsolute, join } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
import { outputLanguage, readHostLocale, resolveLocale, translate } from './src/i18n.js'
|
|
6
|
+
import { Journal } from './src/journal.js'
|
|
7
|
+
import { parseReport, renderReport } from './src/report.js'
|
|
8
|
+
import { buildPua, flavorList, resolveFlavor } from './src/pua.js'
|
|
9
|
+
import { runIsolatedAgent } from './src/runtime.js'
|
|
10
|
+
import { SessionCommand } from './src/command.js'
|
|
11
|
+
|
|
12
|
+
export const name = 'morning-start-code-toolkit'
|
|
13
|
+
export const inject = ['commands', 'subagents', 'systemPrompt', 'tools']
|
|
14
|
+
|
|
15
|
+
const ROOT = dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
|
|
17
|
+
/** The persona lives next to its reference files; the reader may open them on demand. */
|
|
18
|
+
function loadPersona(role) {
|
|
19
|
+
const directory = join(ROOT, 'agents', role)
|
|
20
|
+
return {
|
|
21
|
+
directory,
|
|
22
|
+
text: readFileSync(join(directory, 'AGENT.md'), 'utf8'),
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A minute-based config value as milliseconds; 0 disables the limit.
|
|
28
|
+
* `errorKey` names the message to throw when the value is not a number.
|
|
29
|
+
*/
|
|
30
|
+
function minutesToMs(minutes, fallback, errorKey) {
|
|
31
|
+
const value = Number(minutes ?? fallback)
|
|
32
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(translate('en', errorKey))
|
|
33
|
+
return value * 60_000
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function apply(ctx, config = {}) {
|
|
37
|
+
const fallbackLocale = resolveLocale(config.locale)
|
|
38
|
+
/** An explicit config.locale wins; otherwise the host's preference decides. */
|
|
39
|
+
const forcedLocale = config.locale === undefined ? undefined : resolveLocale(config.locale)
|
|
40
|
+
|
|
41
|
+
if (config.reportDirectory !== undefined && !isAbsolute(config.reportDirectory)) {
|
|
42
|
+
throw new Error(translate(fallbackLocale, 'error.reportDirectory'))
|
|
43
|
+
}
|
|
44
|
+
for (const key of ['reviewModel', 'simplifyModel', 'scrubModel']) {
|
|
45
|
+
if (config[key] !== undefined && !String(config[key]).trim()) {
|
|
46
|
+
throw new Error(translate(fallbackLocale, 'error.model'))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (config.ledgerDirectory !== undefined && !String(config.ledgerDirectory).trim()) {
|
|
50
|
+
throw new Error(translate(fallbackLocale, 'error.ledgerDirectory'))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const journal = new Journal(config.reportDirectory ?? Journal.defaultDirectory())
|
|
54
|
+
const personas = {
|
|
55
|
+
simplify: loadPersona('simplify'),
|
|
56
|
+
review: loadPersona('review'),
|
|
57
|
+
scrub: loadPersona('scrub'),
|
|
58
|
+
caption: loadPersona('caption'),
|
|
59
|
+
pua: loadPersona('pua'),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** agentId -> { controller, label, startedAt } for the isolated runs. */
|
|
63
|
+
const running = new Map()
|
|
64
|
+
|
|
65
|
+
ctx.effect(() => () => {
|
|
66
|
+
for (const entry of running.values()) entry.controller.abort()
|
|
67
|
+
running.clear()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const localeNow = () => forcedLocale ?? readHostLocale(ctx, fallbackLocale)
|
|
71
|
+
|
|
72
|
+
/** Where the caption ledger lives: relative to the project, or an absolute override. */
|
|
73
|
+
const ledgerDirectory = (cwd) => {
|
|
74
|
+
if (config.ledgerDirectory) {
|
|
75
|
+
return isAbsolute(config.ledgerDirectory) ? config.ledgerDirectory : join(cwd ?? ROOT, config.ledgerDirectory)
|
|
76
|
+
}
|
|
77
|
+
return cwd ? join(cwd, 'docs', 'caption') : join(ROOT, 'docs', 'caption')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Everything a command needs from the plugin, in one place. */
|
|
81
|
+
const host = {
|
|
82
|
+
ctx,
|
|
83
|
+
journal,
|
|
84
|
+
running,
|
|
85
|
+
runTimeoutMs: minutesToMs(config.runTimeoutMinutes, 30, 'error.runTimeout'),
|
|
86
|
+
planMaxAgeMs: minutesToMs(config.planMaxAgeMinutes, 60, 'error.planMaxAge'),
|
|
87
|
+
localeNow,
|
|
88
|
+
ledgerDirectory,
|
|
89
|
+
translate: (locale, key) => translate(locale, key),
|
|
90
|
+
deliver(agent, message) {
|
|
91
|
+
try {
|
|
92
|
+
agent.followup(message)
|
|
93
|
+
} catch {
|
|
94
|
+
/* session disposed or unavailable */
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
runIsolatedAgent: (agent, options) => runIsolatedAgent(ctx, agent, options),
|
|
98
|
+
parseReport,
|
|
99
|
+
renderReport,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const commands = [
|
|
103
|
+
new SessionCommand({
|
|
104
|
+
name: 'code-simplify',
|
|
105
|
+
command: 'simplify',
|
|
106
|
+
descriptionKey: 'cmd.simplify',
|
|
107
|
+
hintKey: 'hint.scope',
|
|
108
|
+
persona: personas.simplify,
|
|
109
|
+
model: config.simplifyModel,
|
|
110
|
+
forceDryRun: false,
|
|
111
|
+
followsPlan: true,
|
|
112
|
+
structured: false,
|
|
113
|
+
dryRunText: 'Produce the plan only. Change no files.',
|
|
114
|
+
}, host),
|
|
115
|
+
new SessionCommand({
|
|
116
|
+
name: 'code-scrub',
|
|
117
|
+
command: 'scrub',
|
|
118
|
+
descriptionKey: 'cmd.scrub',
|
|
119
|
+
hintKey: 'hint.scrub',
|
|
120
|
+
persona: personas.scrub,
|
|
121
|
+
model: config.scrubModel,
|
|
122
|
+
forceDryRun: false,
|
|
123
|
+
followsPlan: true,
|
|
124
|
+
structured: true,
|
|
125
|
+
dryRunText: 'Report only. Change no files, and never reproduce a secret in the report.',
|
|
126
|
+
}, host),
|
|
127
|
+
new SessionCommand({
|
|
128
|
+
name: 'code-review',
|
|
129
|
+
command: 'review',
|
|
130
|
+
descriptionKey: 'cmd.review',
|
|
131
|
+
hintKey: 'hint.review',
|
|
132
|
+
persona: personas.review,
|
|
133
|
+
model: config.reviewModel,
|
|
134
|
+
forceDryRun: false,
|
|
135
|
+
defaultScope: 'branch',
|
|
136
|
+
structured: true,
|
|
137
|
+
dryRunText: 'Report only. Change no files.',
|
|
138
|
+
}, host),
|
|
139
|
+
new SessionCommand({
|
|
140
|
+
name: 'code-caption',
|
|
141
|
+
command: 'caption',
|
|
142
|
+
kind: 'inject',
|
|
143
|
+
descriptionKey: 'cmd.caption',
|
|
144
|
+
hintKey: 'hint.caption',
|
|
145
|
+
persona: personas.caption,
|
|
146
|
+
buildText: ({ rawInput, agent, locale, host, installed }) => {
|
|
147
|
+
const cwd = agent.session?.header?.cwd
|
|
148
|
+
const ledger = host.ledgerDirectory(cwd)
|
|
149
|
+
const task = String(rawInput ?? '').trim()
|
|
150
|
+
|| '继续当前会话正在进行的任务:先读台账,再决定下一步。'
|
|
151
|
+
const head = ['# Caption loop', '', `Task: ${task}`]
|
|
152
|
+
if (cwd) head.push(`Working directory: ${cwd}`, `Ledger directory: ${ledger}`)
|
|
153
|
+
head.push(`Reference directory: ${personas.caption.directory}`)
|
|
154
|
+
// The protocol is already in this conversation; repeating it only adds a
|
|
155
|
+
// second copy for the agent to disagree with.
|
|
156
|
+
const body = installed
|
|
157
|
+
? 'The caption protocol is already installed earlier in this conversation. Continue under it: read the ledger head first, then take one step and prove it.'
|
|
158
|
+
: personas.caption.text
|
|
159
|
+
return [...head, '', body, '', outputLanguage(locale)].join('\n')
|
|
160
|
+
},
|
|
161
|
+
receipt: (rawInput, t, installed, agent) => t(installed ? 'caption.reinstalled' : 'caption.installed')
|
|
162
|
+
.replace('{dir}', ledgerDirectory(agent?.session?.header?.cwd)),
|
|
163
|
+
}, host),
|
|
164
|
+
new SessionCommand({
|
|
165
|
+
name: 'pua',
|
|
166
|
+
kind: 'inject',
|
|
167
|
+
descriptionKey: 'cmd.pua',
|
|
168
|
+
hintKey: 'hint.pua',
|
|
169
|
+
persona: personas.pua,
|
|
170
|
+
early: (rawInput, t) => (String(rawInput ?? '').trim() === 'list'
|
|
171
|
+
? { kind: 'success', text: flavorList(t('pua.list')) }
|
|
172
|
+
: null),
|
|
173
|
+
buildText: ({ rawInput, locale }) => buildPua(resolveFlavor(rawInput), personas.pua.text, outputLanguage(locale)),
|
|
174
|
+
receipt: (rawInput, t) => t('pua.installed').replace('{flavor}', resolveFlavor(rawInput).label),
|
|
175
|
+
}, host),
|
|
176
|
+
new SessionCommand({
|
|
177
|
+
name: 'code-status',
|
|
178
|
+
kind: 'local',
|
|
179
|
+
descriptionKey: 'cmd.status',
|
|
180
|
+
run: async ({ agent, t, host: h }) => {
|
|
181
|
+
const entry = h.running.get(agent.id)
|
|
182
|
+
if (entry) return { kind: 'success', text: `${t('status.running')}${entry.label}` }
|
|
183
|
+
|
|
184
|
+
const record = await h.journal.read(agent.session?.id ?? agent.id).catch(() => undefined)
|
|
185
|
+
if (!record) return { kind: 'success', text: t('status.none') }
|
|
186
|
+
if (record.state === 'running') return { kind: 'success', text: t('status.interrupted') }
|
|
187
|
+
if (record.state === 'submitted') {
|
|
188
|
+
return { kind: 'success', text: `${t('status.submitted')}${record.scope} · ${record.mode}` }
|
|
189
|
+
}
|
|
190
|
+
return { kind: 'success', text: `${t('status.last')}${record.scope} · ${record.mode}\n\n${record.result}` }
|
|
191
|
+
},
|
|
192
|
+
}, host),
|
|
193
|
+
new SessionCommand({
|
|
194
|
+
name: 'code-cancel',
|
|
195
|
+
kind: 'local',
|
|
196
|
+
descriptionKey: 'cmd.cancel',
|
|
197
|
+
run: ({ agent, t, host: h }) => {
|
|
198
|
+
const entry = h.running.get(agent.id)
|
|
199
|
+
if (!entry) return { kind: 'success', text: t('cancel.none') }
|
|
200
|
+
entry.controller.abort()
|
|
201
|
+
return { kind: 'success', text: t('cancel.done') }
|
|
202
|
+
},
|
|
203
|
+
}, host),
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
for (const command of commands) command.register(ctx)
|
|
207
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Code toolkit",
|
|
4
|
+
"description": "Five commands that work with no arguments. Review looks at the uncommitted changes (or the branch against its base when the tree is clean), reports, and fixes what it finds — add report for the report only. Simplify and scrub cover the whole project and write by default (add report for a plan only). Caption runs a hard task through an explicit loop with a ledger, and can create expert subagents mid-run for work that splits without colliding. Pua installs a protocol for changing method and showing evidence instead of shrugging. Add sub to run in an isolated agent instead. Prompts are organised as a layered skill-style tree, with a deterministic test suite and a model evaluation loop."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "代码工具箱",
|
|
4
|
+
"description": "五条命令,空输入即可用。审查默认看未提交的改动(都提交了就看当前分支相对基线的改动),出报告并修复发现的问题,加 report 只出报告。精炼与隐私清理默认扫整个项目并直接改(加 report 只出报告)。caption 把难任务装进显式循环:一步一验、过程落成台账,执行中可以创建专家子 agent 分派任务。pua 给会话装上「失败换方法、完成要证据」的协议。加 sub 改用独立 agent。提示词按 skill 分层组织,附确定性测试与模型评测流程。"
|
|
5
|
+
}
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morning-start/dsh-code-toolkit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.27.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"description": "Five commands for DeepSeek Harness: review and fix, behavior-preserving simplification, privacy scrubbing, a caption loop with a ledger, and a PUA protocol. Each runs in the current session by default (add sub for an isolated agent) and writes by default (add report for a report only).",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"icon": "./icon.svg",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dsh",
|
|
15
|
+
"dsh-plugin",
|
|
16
|
+
"dsh-plugins",
|
|
17
|
+
"deepseek-harness",
|
|
18
|
+
"code-toolkit",
|
|
19
|
+
"code-review",
|
|
20
|
+
"simplify",
|
|
21
|
+
"privacy",
|
|
22
|
+
"secret-scan",
|
|
23
|
+
"caption",
|
|
24
|
+
"pua",
|
|
25
|
+
"subagent"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./index.js",
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./locale/*.json": "./locale/*.json",
|
|
31
|
+
"./icon": "./icon.svg"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"src",
|
|
36
|
+
"agents",
|
|
37
|
+
"cordis.patch.yml",
|
|
38
|
+
"locale",
|
|
39
|
+
"icon.svg",
|
|
40
|
+
"README.md",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"test": "node evals/run.mjs",
|
|
46
|
+
"eval": "node evals/run.mjs --verbose",
|
|
47
|
+
"case": "node evals/case-setup.mjs",
|
|
48
|
+
"score": "node evals/score.mjs"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.19.0",
|
|
52
|
+
"dsh": ">=0.2.2-rc.1 <0.3.0-0"
|
|
53
|
+
},
|
|
54
|
+
"dsh": {
|
|
55
|
+
"manifestVersion": 1,
|
|
56
|
+
"bundle": {
|
|
57
|
+
"patch": "./cordis.patch.yml"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/morning-start/dsh-code-toolkit.git"
|
|
63
|
+
}
|
|
64
|
+
}
|